CHAPTER 1 INTRODUCTION 1. POWER

0 downloads 0 Views 2MB Size Report
The first high power electronic devices were mercury-arc valves. In modern ... predict the diode voltage drop across the diode with respect to current flow.

CHAPTER 1 INTRODUCTION

1. POWER ELECTRONICS DRIVES Power electronics is the application of solid-state electronics to the control and conversion of electric power. It also refers to a subject of research in electronic and electrical engineering which deals with the design, control, computation and integration of nonlinear, time-varying energy-processing electronic systems with fast dynamics. The first high power electronic devices were mercury-arc valves. In modern systems the conversion is performed with semiconductor switching devices such as diodes, thyristors and transistor The power conversion systems can be classified according to the type of the input and output power •

AC to DC (rectifier)



DC to AC (inverter)



DC to DC (DC-to-DC converter)



AC to AC (AC-to-AC converter)

1.1 Diode Unipolar, uncontrolled, switching device used in applications such as rectification and circuit directional current control. Reverse voltage blocking device, commonly modelled as a switch in series with a voltage source, usually 0.7 VDC. The model can be enhanced to include a junction resistance, in order to accurately predict the diode voltage drop across the diode with respect to current flow

1.2 Silicon-controlled rectifier (SCR) This semi-controlled device turns on when a gate pulse is present and the anode is positive compared to the cathode. When a gate pulse is present, the device operates like a standard diode. When the anode is negative compared to the cathode, the device turns off and blocks positive or negative voltages present. The gate voltage does not allow the device to turn off. 1

1.3 Thyristor The thyristor is a family of three-terminal devices that include SCRs, GTOs, and MCT. For most of the devices, a gate pulse turns the device on. The device turns off when the anode voltage falls below a value (relative to the cathode) determined by the device characteristics. When off, it is considered a reverse voltage blocking device.

1.4 Gate turn-off thyristor (GTO) The gate turn-off thyristor, unlike an SCR, can be turned on and off with a gate pulse. One issue with the device is that turn off gate voltages are usually larger and require more current than turn on levels. This turn off voltage is a negative voltage from gate to source, usually it only needs to be present for a short time, but the magnitude s on the order of 1/3 of the anode current. A snubber circuit is required in order to provide a usable switching curve for this device. Without the snubber circuit, the GTO cannot be used for turning inductive loads off. These devices, because of developments in IGCT technology are not very popular in the power electronics realm. They are considered controlled, uni-polar and bi-polar voltage blocking

1.5 TRIAC The triac is a device that is essentially an integrated pair of phase-controlled thyristor connected in inverse-parallel on the same chip.Like an SCR, when a voltage pulse is present on the gate terminal, the device turns on. The main difference between an SCR and a Triac is that both the positive and negative cycle can be turned on independently of each other, using a positive or negative gate pulse. Similar to an SCR, once the device is turned on, the device cannot be turned off. This device is considered bi-polar and reverse voltage blocking.

1.6 Bipolar junction transistor (BJT) The BJT cannot be used at high power; they are slower and have more resistive losses when compared to MOSFET type devices. To carry high current, BJTs must have relatively large base currents, thus these devices have high power losses when compared to MOSFET devices. BJTs along with MOSFETs, are also considered unipolar and do not block reverse voltage very well, unless installed in pairs with protection diodes. 2

1.7 Power MOSFET The main benefit of the power MOSFET is that the base current for BJT is large compared to almost zero for MOSFET gate current. Since the MOSFET is a depletion channel device, voltage, not current, is necessary to create a conduction path from drain to source. The gate does not contribute to either drain or source current

1.8 Insulated-gate bipolar transistor (IGBT) These devices have the best characteristics of MOSFETs and BJTs. Like MOSFET devices, the insulated gate bipolar transistor has a high gate impedance, thus low gate current requirements. Like BJTs, this device has low on state voltage drop, thus low power loss across the switch in operating mode. Similar to the GTO, the IGBT can be used to block both positive and negative voltages

3

CHAPTER 2 LITERATURE REVIEW

Currently, the STM8S Discovery is the cheapest way to break into microcontroller (MCU) development. With the inclusion of a touch-sensitive electrode, it’s a refreshing change from the array of cheap demo kits. The programmable microcontroller was the STM8S105C6, one of ST’s 8-bit MCUs featuring a clock speed of up to 16MHz and 32KB of flash, and is pretty standard, with 38 I/O pins, a 10 bit ADC and debugging ability. One neat feature is the programmer can be snapped off and used separately from the rest of the board.

Setup:The Discovery comes preloaded with a demo program which demonstrates the use of the touch sensor and an included LED. It can be run by simply connecting the board to a computer via a USB A to B cable (not included). If you place a finger on (or even just very close to) the sensor, the LED will flash at different rates.

For the price, this kit is very efficient. It is recommend to lecturers for use in the teaching labs but the lack of beginner support is a potential sticking point. The ability to develop touch applications would no doubt help in MCU programming. For those interested in touch sensitive applications with a small budget however, this is very useful.

Figure 1 4

2.1 Papers Followed Title: Speed control of dc motor using PID controller implementation with visual basic Appears in: University of Malaysia Year of Publication: 10 November 2008 Authors: Nurul izzati binti padak jabo

Title: Speed control of dc motor Appears in: International journal of engineering science and research technology Year of Publication: August 2015 Authors: Prabha malviya,menka dubey

2.2 Methods Used To control dc motor using the PID controller,there are two techniques used 1. Armature control 2 field control

5

CHAPTER 3 CONVENTIONAL SYSTEMS 3. STUDY OF TWO EXISTING MODELS AVAILABLE IN THE MARKET

3.1 Speed control of dc motor using PIC controller In the project, 2 DS18B20 temperature sensors are used. They are configured in 12bit resolution, so delay between 2 calculations is about ~750ms. If you read about PID controller, you realize that you cannot calculate PID controller results every x microcontroller, because it has integral part which is used to sum all the errors in period.

3.2 Speed control of dc motor using ATML microcontroller The project provides the efficient and simple method to control speed of DC motor using ATMEGA16 microcontroller and L298N motor driver IC. With the use of ATMEGA16 and l298N we can drive the dc motor at desired speed having a feedback loop and in this project we have used proportional integral and derivative method in which errors are not only solved but also taken to its minimal value with very low amount of error oscillation

6

CHAPTER 4 STM8SVLDISCOVERY KIT

4.1 General Overview The STM8SVLDISCOVERY is a quick start evaluation kit which helps you to discover the STM8S value line features, and to develop your own application. It is based on an STM8S003 and includes an embedded debugger, ST-LINK, and a user button.

Figure 2

Table 1

7

Figure 3

4.2 Key Features  STM8S003K3T6 microcontroller  8 KB Flash, 1 KB RAM, 128 bytes EEPROM  Powered by USB cable between PC and STM8SVLDISCOVERY  Selectable power of 5 V or 3.3 V  Push button, B1  User LED, LD1  Extension header for all I/Os  Wrapping area for users own application  Embedded ST-LINK for STM8S  USB interface for programming and debugging  SWIM debug support

8

4.3 Hardware Description

Fig 4

Fig 5

9

4.4 Architecture

Figure 6

10

Figure 7

SWIM connector CN7 Pin

CN2

Designation

1

VDD_TARGET

VDD from application

2

SWIM

SWIM data input/output

3

GND

Ground

4

SWIM_RST

SWIM reset

Table 2 11

4.5 Pin Details

Figure 8 CN1 pin out Pin (chip)

Pin name

Type

CN1 pin

Main function

1

1

NRST

I/O Reset

2

2

OSCIN/PA1

I/O Port A1

3

3

OSCOUT/PA2 I/O Port A2

4

4

GND

S

Digital ground

5

4

GND

S

Digital ground

6

5

VCAP

S

1.8 V regulator capacitor

NC

6

VDD

S

Digital power supply

7

7

PA3

I/O Port A3

8

8

PF4

I/O Port F4

Alternate function

Timer 2 - channel 3 / SPI master slave

12

CN2 pin 1

Pin (chip) 17

Pin name PE5

Type

CN2 pin out Main function

Alternate function

I/O Port E5

SPI master slave

2

18

PC1

I/O Port C1

3

19

PC2

I/O Port C2

Timer 1 - channel 1 / UART2 synchronous clock Timer 1 - channel 2

4

20

PC3

I/O Port C3

Timer 1 - channel 3

5

21

PC4

I/O Port C4

Timer 1 - channel 4

6

22

PC5

I/O Port C5

SPI clock

7

23

PC6

I/O Port C6

SPI master out / slave in

8

24

PC7

I/O Port C7

SPI master in / slave out

CN3 pin

Pin (chip)

Pin name

Type

CN3 pin out Main function

Alternate function

1

9

PB7/B1

IO

Port B7

2

10

PB6

IO

Port B6

3

11

PB5

I/O Port B5

I2C data

4

12

PB4

I/O Port B4

I2C clock

5

13

PB3

I/O Port B3

6

14

PB2

I/O Port B2

7

15

PB1

I/O Port B1

8

16

PB0

I/O Port B0

Analog input 3 / Timer 1 external trigger Analog input 2 / Timer 1 inverted channel 3 Analog input 1 / Timer 1 inverted channel 2 Analog input 0 / Timer 1 inverted channel 1

13

CN4 pin

Pin (chip)

Pin name

Type

CN4 pin out Main function

Alternate function Timer 1 - break input /

1

25

PD0/LD1

I/O Port D0

2

26

PD1/SWIM

I/O Port D1

SWIM data interface

3

27

PD2

I/O Port D2

Timer 2 - channel 3

4

28

PD3

I/O Port D3

Timer 2 - channel 2 / ADC external trigger Timer 2 - channel 1 /

5

29

PD4

I/O Port D4

BEEP output

6

30

PD5

I/O Port D5

UART1 data transmit

7

31

PD6

I/O Port D6

UART1 data receive

8

32

PD7

I/O Port D7

Top level interrupt / Timer 1 - channel 4

configurable clock output

Table 3

14

4.6 Internal Connections

Figure 9

15

4.7 Power selection The power supply is provided by a USB connector. Jumper JP1 selects the VDD value (5 V or regulated 3.3 V)

Figure 10

LEDs The ST-LINK provides two LEDs: ●

LD1: Green LED LD1 is connected to the I/O PD0 of STM8S003K3.



LD2: Red LED LD2 indicates communication between PC and ST-LINK.

Push button Push button B1 is connected to the I/O PB7 of STM8S003K3

16

CHAPTER 5 STM8 SOFTWARE DEVELOPMENT TOOLCHAIN 5.1 Overview To develop, compile and run an application software on an STM8S microcontroller, the following software toolchain components are required: ● Integrated development environment (IDE) composed of the ST Visual Develop (STVD) and the ST Visual Programmer software interface (STVP) ●

Compilers

● Firmware libraries: they are optional, and allow to easily create a new application

5.2 ST Visual Develop (STVD) STVD is a full-featured development environment. It is a seamless integration of the Cosmic and Raisonance C compilers for STM8 microcontroller family. These compilers are free when developing code up to 16 Kbytes. STVD main features are: ● Seamless integration of C and ASM compilers ● Full-featured debugger ● Project management ● Syntax highlighting editor ● Integrated programming interface

5.3 ST Visual Programmer (STVP) STVP is a easy-to-use graphical interface allowing to read, write and verify the code and data programmed in your STM8 microcontroller Flash program memory, data EEPROM and option bytes. STVP also features a project mode for saving programming configurations and automating programming sequences.

17

5.4 C and assembly compilers The C and assembly compilers are seamlessly integrated into the STVD development environment. They allow to directly configure and control the building of your application from an easy-to-use graphical interface.

The supported compilers are the following:  Cosmic C compiler for STM8 (free version up to 16 Kbytes of code) for more information, refer to http://www.cosmicsoftware.com.  Raisonance C compiler for STM8 (free up to 16 Kbytes of code) For more information, refer to http://www.raisonance.com.  STM8 assembler linker

5.5 Firmware libraries The STM8S standard firmware library is a complete package consisting of drivers for all the standard peripherals of Performance line STM8S20x and Access line STM8S10x microcontrollers. It is written in strict ANSI-C code and is fully MISRA C 2004 compliant. This firmware offers a complete and robust solution to manage capacitive sensing keys, wheels, and sliders.

The stm8s.h header file contains the definitions of constants and register structures for all peripherals. Uncomment #define USE_STDPERIPH_DRIVER when using the STM8S standard firmware library.

In addition, stm8s.h must be included in your main() routine.

18

The stm8s_conf.h file of the STM8S standard firmware library is used to configure the library by enabling the peripheral functions that are only used by your application. In stm8s_conf.h, some peripheral define statements are conditioned by supported devices. For example:

#if defined(STM8S208) || defined(STM8S207) || defined(STM8S105) #define _TIM3 (1) #endif

In stm8s_conf.h, the HSE value define statement may be adjusted to the oscillator frequency or to the external clock generator frequency. It is also conditioned by supported devices. Make sure you have the correct value for the STM8SDISCOVERY external oscillator (expressed in Hz). For example:

#define HSE_VALUE ((u32)16000000) The peripheral interrupt function file, stm8s_it.c, must be modified to include the code to handle the interrupts used by your application. The stm8s_type.h file includes common types and constants used by the peripheral drivers. Each peripheral driver is made up of the following files: ● The source code stm8s_.c containing all the software functions required to use the corresponding peripheral. ● The header stm8s_.h including the peripheral function prototypes as well as the variables, constant and structures used within these functions.

The flow that must be followed to create your application software using the STM8S standard firmware library is described in Section 5.3: Creating your STVD project.

stm8s_conf.h peripheral define statements 19

Figure 11

5.6 Creating a STVD project All projects must be created starting from STM8S-Discovery_dev development package. This section explains step by step how to create your own application project. The firmware libraries can be used or not according to the kind of application code to develop. The best way to proceed is to start from the Project_template directory: 1.

Extract the content of STM8S-Discovery_dev.zip file on your PC.

2.

Copy the Project_template directory and rename it My_own_project .

Figure 12

20

5.7 Selecting the debug instrument

Figure 13

5.8 Creating the STVD workspace for project

Figure 14 21

5.9 Checking the selected compiler

Figure 15

Select the MCU

Figure 16 22

Copy stm8s.h to Include Files/FWLib

Figure 17

Linking the libraries to your STVD project No libraries linked

Figure 18

23

Linking the STM8S standard firmware library - step 1

Figure 19

Linking the STM8S standard firmware library - step 2

Figure 20

24

Figure 21

5.10 Building, debugging and running the application Once we have developed our application code, created our workspace environment, and launched STVD, we can start building, debugging and programming our application to the target microcontroller.

Building the application Once our project is created, the build context is enabled by default. It allows to access all the commands required to set up, customize, and build our application. The build configuration is available by selecting Build>Configurations from the STVP main menu toolbar. It allows to change the application building settings.

Two preset configurations are available in STVD: Debug This configuration creates a version of our application that allows using all the STVD advanced debugging features. When using this configuration, output files are saved in the Debug directory in our workspace directory.

25

Release This configuration creates a version of our application that uses the default optimization for our toolset. This version of our application is ready to be programmed to our target microcontroller.

Selecting the project configuration

Figure 22

Once the building options are correctly configured, configure our project settings:

a) Select Project > Settings from the STVD main menu toolbar.

b) The Project settings window opens and displays all the options of your toolset compiler, assembler, and linker. We can then customize these options.

26

Building your project

Figure 23

Building successful message

Figure 24

27

Debugging the application 1.

Select Debug Instrument > Target settings from the STVD main menu toolbar.

2.

Select Swim ST-LINK, which is our debug instrument.

3.

Click Apply to confirm and OK to close the window.

4. Select Debug > Start Debugging to start our debug session and access the debug context. STVD then connects to our debug instrument, loads the code into the microcontroller Flash memory, and provides access to the debug commands and menus. We can now start debugging our application.

Figure 25

Watch window

Figure 26 28

CHAPTER 6 WORKED CODES ON STM8S003K3

6.1 Blinking LED STM8 family of controllers provides a lot of variety to our 8-bit controller based projects. STM8 family includes member devices of all price, packages and features. So, the developers have the option to choose the right controller depending upon specific application and cost constraints. But, when it comes to software tools, options are kind of limited. If you are working on Windows environment, you can either choose Cosmic or Raisonance compilers and both of them require license. After setting up the STM8S library we are ready to build our first project. Here's how to set up Code::Blocks, build a very simple program and flash it to the device. Step 1 Run the ST visual develop program

From the File Menu create a new Empty Workspace ( The second icon )

29

Figure 27

Give the Workspace filename as Adventure and use the folder button to set the workspace location , I've set it to C:\sm8Adventure but you can set it anywhere.

Figure 28 30

Now right click on the newly created workspace and select Add New Project to Workspace... you will get the following dialog.

Figure 29

Select New Project and use

The folder button to create a new folder called blink. We need to do this otherwise the IDE will place other new project files in the same workspace directory, this way we keep our projects separate.

31

Figure 30 Now fill in the rest. The project name is blink and we set the tool chain to be ST Link, the tool chain root is set automatically and need not be changed.

Figure 31 Now, after Selecting the proper MCU we can get the column as below. A Stub project has now been created with the default directory structure and auto generated files. In the main.c file, the following program is being written. 32

6.2 LED Blinking Code // core header file from our library project: #include "stm8s.h"

int main(void) { // Reset GPIO port D to a default state GPIO_DeInit(GPIOD); // Set operation mode for port D / pin 0 // (connected to the onboard LED) GPIO_Init(GPIOD, GPIO_PIN_0, GPIO_MODE_OUT_PP_LOW_FAST); // The main loop while(1) { uint16_t i; // Always use standardized variable types... for(i=0;i