Part Number Hot Search : 
AD7416 3641AG A205A 4LS02 C85FABBA 97M00 MPC9315 2SC438
Product Description
Full Text Search
 

To Download AP082201 Datasheet File

  If you can't view the Datasheet, Please click here to try to view without PDF Reader .  
 
 


  Datasheet File OCR Text:
 Microcontrollers ApNote
AP082201.EXE available
AP0822
additional file
Generating sinusoidal Three-Phase-Currents for Induction Machines with a time-optimized Algorithm for the Capture Compare Unit of the C504
This application note proposes a time optimized algorithm for three-phase induction drive control by the Siemens microcontroller C504. Three sinewave phase currents can easily be generated and controlled by the on-chip Capture Compare Unit (CCU), requiring very few CPU computing time (about 30% at 20 kHz PWM frequency in open-loop mode).
Authors: K. Scheibert (HL MC AT) / M. Seth / A. Hollmann
Semiconductor Group
6.97, Rel. 01
Generating sinusoidal three-phase currents with the CCU of C504
Table of Contents: 1 2 2.1 2.2 2.3 2.4 2.5 2.6 3 3.1 3.2 3.3 4 4.1 4.2 4.3 4.4 4.5 4.6 4.7 4.8 Introduction .............................................................................................................3 Fundamentals of Operating....................................................................................4 Controlling Three-Phase Induction Motors ...............................................................4 Generating Variable Motor Currents by Using Pulse Width Modulation (PWM).......5 Power Amplification of Controller Output Signals by Semiconductor Bridges ..........6 Sinusoidal Weighted PWM .......................................................................................7 Half Bridge Driving with Dead Time Control .............................................................8 Principle of Generating Sinusoidal Weighted PWM Signals with the C504..............9 Hardware Description ...........................................................................................11 Three-Phase Motor .................................................................................................11 Motor Interface ........................................................................................................12 Open Loop Motor Control........................................................................................13 C504 Controller Software Description.................................................................14 Calculation of Period- and Offset-Values for Compare Timer 1..............................14 Considerations concerning the Resolution for the Sine Table Pointers..................14 Changing the Amplitude without using any Multiplication-Instruction .....................17 Generating the Memory Sine Tables ......................................................................20 Compare Timer 1 Interrupt Service Routine Tasks.................................................22 Main Program Task.................................................................................................23 Flow-Charts.............................................................................................................24 Conclusion ..............................................................................................................29
AP0822 ApNote - Revision History Actual Revision : Rel.01 Previous Revison: None Page of Page of Subjects changes since last release actual Rel. prev. Rel. Original Version
Semiconductor Group
2 of 29
AP08220 06.97
Generating sinusoidal three-phase currents with the CCU of C504
1. Introduction
Generating three-phase sine wave currents for induction machines with microcontrollers requires a lot of CPU-time, depending on the PWM-frequency and the desired resolution. In order to minimize CPU-load, Siemens provides the C504 microntroller with a special peripheral - the onchip Capture Compare Unit (CCU). With this unit, three independent pulse width modulated output signals can be generated with a minimum of CPU-load. This application note introduces an algorithm for generating three-phase signals, whereby multiplications are avoided (see chapter 4 C504 Software Description). With this algorithm, there has been realized a resolution of 7-bit for a 20 kHz PWM period (50 s between two different consecutive PWM-values) and an amplitude resolution of 6-bit between 0 - 100%. The CPU load for calculation of new PWM compare values for three phases of an induction machine within one PWM period of 50 s (20kHz) is about 15 s, which corresponds to 30% calculation time. The sinewave frequency can be choosen up to 127 Hz in 1 Hz steps for both rotation directions. If the frequency is below 1 Hz, the output is switched off to avoid feeding DC-current into the machine. If a frequency change is desired, a second algorithm, also written in assembler code, handles the acceleration or deceleration, which can be choosen between 1 Hz/sec and 30 Hz/sec in 0.3 Hz/sec steps. The communication between C504 and host PC is realized via the serial interface (USART). The algorithm is written in C language. The motor speed (frequency), the output amplitude (0...100%, 1% steps) and the acceleration/deceleration-speed can be choosen with the host PC. The C504 software is programmed in a modular way and due to the CPU-load of only 30 percent, additional sw-tasks (e.g. sw.-control algorithms for a closed-loop system) can be easily realized.
Semiconductor Group
3 of 29
AP08220 06.97
Generating sinusoidal three-phase currents with the CCU of C504
2. Fundamentals of Operating
2.1 Controlling Three-Phase Induction Motors Usually, induction machines are supplied directly from the 50/60Hz three-phase AC voltage line, where amplitude and frequency are constant.
/t Diagram
Period Time (1/f) Amplitude
0 t
1/3 T (120)
Phase U
Phase V
Phase W
Figure 1: Three-Phase Sine Wave Currents for Induction Motors
Semiconductor Group
4 of 29
AP08220 06.97
Generating sinusoidal three-phase currents with the CCU of C504
With supplying from the line, the drive cannot be regulated in a simple way. The delivered torque and speed of an induction machine are determined by the amplitude and frequency of the driving AC voltage. Rotation speed of the shaft strongly depends on the AC frequency, and torque strongly depends on the AC current amplitude. Knowing this, a proper working open loop control can be realized by applying three sine waves with constant electrical phase shift of 120 to each other - but with variable amplitude and frequency. As rotor slip (difference between rotor frequency and stator frequency) can vary as a function of these parameters, it is difficult to regulate exactly the rotation speed. In many applications, where a rotor frequency deviation of a few per cents does not matter (e.g. fan, driven by three-phase induction machine), the proposed open loop control is a low cost and very powerful solution.
2.2 Generating Variable Motor Currents by Using Pulse Width Modulation (PWM) There are different ways of generating variable actor currents with a microcontroller. One is to generate a pulse width modulated rectangle voltage and to integrate it with large time constant, e.g. by low-pass filtering. The result is a constant voltage proportional to the ratio of high to low time (duty cycle) in one period. The application of this principle to electric motors leads to:
V
PWM Voltage
Motor Integrates t
Motor Winding Current
t
Figure 3: Variable Current via PWM The efficiency of the whole power circuit is much higher with switched power transistor drivers than with analog power amplifiers. The integrating effect of a standard motor with high PWM frequency (about 20kHz, which is beyond the audible range) allows the use of switching patterns, which can easily be generated by the Capture Compare Unit (CCU) of the Siemens C504 8-bit microcontroller.
Semiconductor Group
5 of 29
AP08220 06.97
Generating sinusoidal three-phase currents with the CCU of C504
2.3 Power Amplification of Controller Output Signals by Semiconductor Bridges Each phase of the AC motor is driven by an independent half bridge that amplifies the controllers output signal. One single half bridge consists of two switching elements (MOSFETs, IGBTs, etc.), which are connected as shown in figure 4:
+Vb
High Side
T1
Output
Low Side
T2
-Vb
Figure 4: Single Half Bridge If the high side transistor is switched on and the other is turned off, the positive supply voltage (+Vb) is applied to the output. If the low side transistor is switched on and the high side is off, output voltage will be negative (-Vb). The average output voltage will directly depend on the duty cycle if both transistors are activated alternately (push-pull-driving). In this way the microprocessor unit is able to generate any lowfrequent signal shape, e.g. sine wave.
Semiconductor Group
6 of 29
AP08220 06.97
Generating sinusoidal three-phase currents with the CCU of C504
2.4 Sinusoidal Weighted PWM Three-phase induction motors need three sinusoidal phase currents - with 120 phase shift to each other - for adequate and smooth rotating. Therefore, so called `sine wave weighted PWM' is used in this application. For any phase angle, the duty cycle of each PWM signal is generated as a function of the desired sine value.
V
PWM Voltage (High Side)
Sinusoidal Phase Current
t V Motor Integrates
PWM Voltage (Low Side)
t
t
Figure 5: Sine Wave Weighted PWM Voltage generates Sinusoidal Phase Current
Semiconductor Group
7 of 29
AP08220 06.97
Generating sinusoidal three-phase currents with the CCU of C504
2.5 Half Bridge Driving with Dead Time Control In this application, both transistors of a half bridge are switched alternately (push-pull-driving). The average output voltage can be varied between plus and minus of the rectified line voltage, depending on the applied duty cycle. However, the transistor's switching times must be taken into account. In order to prevent the half bridge from conducting short circuit current - when one transistor is already switched on, and the other is not yet quite switched off - a so called dead time between these two events must be implemented.
Half Bridge Switching without Dead Time Control
Control Voltage
Half Bridge Switching with Dead Time Control
Uon T1 Uoff Uon T2 Uoff Transistor Conductance T1 Goff Gon T2 Goff Supply Current Short Circuit! Dead Time Gon
on
off
Figure 6: Half Bridge Switching with and without Dead Time Control
Semiconductor Group
8 of 29
AP08220 06.97
Generating sinusoidal three-phase currents with the CCU of C504
2.6 Principle of Generating Sinusoidal Weighted PWM Signals with the C504 The C504 microcontroller can be easily programmed to provide up to three independent sine waves by using the PWM capability of its on-chip Capture Compare Unit (CCU). The center aligned (symmetrical) up to three PWM channels with dead time are generated by the 16-bit wide compare timer 1 as follows: An up/down counter counts from 0 up to a programmable 16-bit period value stored in the special function register (SFR) CCPx. When reaching it, the count direction is changed from up-counting to down-counting. When it becomes 0, the count direction will be switched to upwards again. This is similar to the function of a triangle generator. Additionally, compare timer 1 over/underflow interrupt requests are activated. The PWM output signals for the three phases of an induction machine are specified by the three compare values stored in three independent 16-bit compare registers CCx0/CCx1/CCx2. If compare timer 1 oversteps the 16-bit compare values for the three PWM output signals, the corresponding outputs toggle and the compare match interrupts requests for the three PWM signals are activated. As a result, up to three digital rectangle signals are generated (the duty cycle of one PWM channel corresponds to the position of the compare value between offset and period value). The switching frequency is identical to the counter underflow frequency (e.g. 20kHz). This signals control the high side transistors of the single half bridges. Furthermore, complementary output signals are generated, which control the low side switches. A global programmable dead time for each PWM channel, in which both switches are turned off can be programmed by an additional 16-bit offset value stored in SFR CT1OFx. The principle for one PWM channel is shown in figure 7.
Semiconductor Group
9 of 29
AP08220 06.97
Generating sinusoidal three-phase currents with the CCU of C504
counter value
overflow interrupt request
Period Value
compare match interrupt request
Compare Value
Offset Value
underflow interrupt request
t PWM Output High Side Signal (Active Low) high low
Low Side Signal (Active Low) t
high low
Dead Time
Figure 7: Principle of PWM Signal Generation with Dead Time
Once the parameters period value, offset value, three compare values and a start bit for compare timer 1 are set, the CCU requires no CPU access for running permanently and generating three independent rectangle signals with constant pulse widths. For the motor has to be fed by sine wave currents, the CPU of the C504 has to set periodically the three compare values of the CCU, that are necessary for sinusoidal PWM output signals (refer to figure 5) after each PWM period. This can be done in the corresponding compare timer 1 underflow interrupt service routine.
Semiconductor Group
10 of 29
AP08220 06.97
Generating sinusoidal three-phase currents with the CCU of C504
3. Hardware Description
This application consists of four functional units:
* * * *
A standard PC The open loop motor control (with the Siemens C504 8-bit microcontroller) The motor interface A three-phase induction motor
User Interface
Open Loop Control
Motor Interface
Three Phase Motor
Async. Serial PC Link C504
Digital Signals
Three Phase Inverter
Three Phases
Figure 8: Hardware Block Diagram in Open Loop Configuration
3.1 Three-Phase Motor The motor can be a three-phase induction or synchronous machine. The nominal motor power can vary in a wide range, and it is restricted in this application only by the power capability of the driver transistors. The hard- and software in this application works with any number of motor pole pairs.
Semiconductor Group
11 of 29
AP08220 06.97
Generating sinusoidal three-phase currents with the CCU of C504
3.2 Motor Interface The motor interface consists of the motor signal amplifier and its power supply. An AC converter is used in this application, for being an adequate way to drive 400 VAC three-phase motors. It's build up by three IGBT (insulated gate bipolar transistor) single half bridges, which are driven by the C504 via opto couplers. This structure needs DC link voltage for the ability to generate sine waves with variable frequency. So a DC-link and a large capacitor are necessary for supplying the IGBTs by the 230V 50/60Hz line. The capacitor value has to be high enough for minimizing the ripple, which appears when rectifying the AC line voltage. Additionally, it's a low impedance buffer for the switching bridge.
DC-Link Capacitor
Three Phase Bridge (IGBT's)
T1 T3 T5
D1
D3
to Line
L 230 VAC N T2 D2 D4 T4 T6 325 VDC
to Motor
U V W
C
Opto Couplers
Udrive Digital CCU Control Signals from C504 (PWM)
O1...O6
Figure 9: Simplified AC Converter Schematic Diagram
Semiconductor Group
12 of 29
AP08220 06.97
Generating sinusoidal three-phase currents with the CCU of C504
3.3 Open Loop Motor Control The following block diagram shows the digital control unit C504 for three-phase motor control. For this application the following internal peripheral resources are used:
* * *
USART for RS232 host computer communication timer 2 as baud rate generator CCU (Capture Compare Unit) for PWM output and timer interrupt generation
C504 Microcontroller
RAM
Settings CC0
to Bridge:
P1.2 P1.3 P1.4 P1.5 P1.6 P1.7 COUT0
CPU
Interrupts
CC1
CCU
COUT1 CC2 COUT2
U High U Low V High V Low W High W Low
To Host via RS232
P3.0 P3.1
RxD TxD
Timer 2/ USART
Figure 10: Open Loop Motor Control with the C504, using its CCU
Semiconductor Group
Data
13 of 29
AP08220 06.97
Generating sinusoidal three-phase currents with the CCU of C504
4. C504 Software Description
Fundamental Considerations The most important task of the C504 is to generate three sine waves with variable frequency and amplitude in very short time frames. This chapter describes how the C504 software basically meets this requirement: 4.1 Calculation of Period- and Offset-Values for Compare Timer 1 To compute the period value of compare timer 1, two conditions have to match: First: In this application the pulse width modulation frequency has been choosen to:
fPWM = 20 kHz
This means that every 50 s compare timer 1 has to generate an interrupt. Second: The compare registers of the CCU needs time-dependent different compare values refering to the desired sine waves (see page 7 and page 9). These compare values can not be computed by the C504 in a reasonable time, therefore the values are periodically read out from a sine table in memory which means, that the compare values are 8-bit. Therefore, the period value of compare timer 1 and the offset value should not exceed the sum of 255 to ensure that the whole PWM duty-cycle can be used (see page 9).
PERIOD =
fOSC 40 MHz = = 250 prescaler f PWM 2 420 kHz2
To match both conditions the prescaler has to divide the system oscillator signal by 4. (The factor 2 is necessary because compare timer 1 operates in mode 1 up/down counting). With prescaler = 4 the counter is increased every fosc/prescaler = 0,1 s. With a required dead time of 1 s the offset value is:
OFFSET =
dead _ time fOSC 1s40 MHz = = 10 prescaler 4
4.2 Considerations concerning the Resolution for the Sine Table Pointers For accessing the look-up table values in short time, the sine table should be not longer than 256 bytes for one period because the pointer (named angle variable) can be an 8-bit value and easily handled by the 8-bit C504. To generate the sine waves, the angle variable is increased every interrupt and points to a value in the sine table which is read out and moved to the compare value register. The lowest frequency to be generated is 1 Hz. Due to the angle variable being increased every 50 s and pointing to another compare value in the sine table, the frequency of the output signal will be:
frequency =
1 = 78.125 Hz 25650 s
14 of 29 AP08220 06.97
Semiconductor Group
Generating sinusoidal three-phase currents with the CCU of C504
That means for lower frequencies pointing on the same sine table value more than one time e.g. for 1 Hz about 78 times. The best solution for this problem is to take a 16-bit pointer angle variable with only the high byte being the pointer to the sine table. Supposing the 16-bit angle variable will be increased by one every 50 s it takes
6553650s = 327 s .
to access every value in the table once, that means the lowest frequency then results to 0.305Hz (which corresponds to the minimum value of the 16-bit resolution for the electrical rotating field of the induction machine). To generate any other frequency every 50s a certain delta value has to be added to the angle variable computed as follows:
delta =
frequency frequency65536 = frequency6553650s = 0.305 Hz 20kHz
angle = angle + delta
In figure 11, a simplified model for the generation of a sine wave output signal by using the above described mechanism is shown.
Semiconductor Group
15 of 29
AP08220 06.97
Generating sinusoidal three-phase currents with the CCU of C504
memory contents (decimal)
Memory Sine Table
255
255
190 160
126 126
92
126
offset = 10 value
x0 x1 x2
x20
every 50 s: angle = angle + delta 8-bit (HB) 8-bit (LB) angle
period value 255 190 compare value
x254 x255 memory address (decimal)
CCU
+
Pointer 8-bit
delta angle
0 output voltage Vmax
50s
time one PWM period
e.g. =00000010
CCx output 0 time
output voltage Vmax
signal-shape after low pass filter
0
50s
time
Figure 11: Simplified Model for the Generation of a Sine Wave Output Signal; the Model shows not how the Amplitude can be adjusted.
Semiconductor Group
16 of 29
AP08220 06.97
Generating sinusoidal three-phase currents with the CCU of C504
4.3 Changing the Amplitude without using any Multiplication-Instruction With the 8-bit CPU of the C504, one signed 8-bit x 8-bit multiplication takes a lot of cycles. This leads to a relatively long execution time, which cannot be tolerated in all cases. Furthermore, if a higher resolution shall be used, even more computing power is needed. The proposed algorithm is based on an addition theorem for sine waves. It can be used to reduce computing time for signed multiplication. The following equation describes one of the desired three-phase sine waves at the induction machine:
U = A sinB
B corresponds to the angle variable high byte, sin B corresponds to the value in the sine table to be multiplied with the amplitude A, U corresponds to the value moved to the compare register. To avoid the multiplication, following equation shows a solution:
1 U = A sinB = cos(arccosA) sinB = cosA' sinB = [sin( B - A' ) + sin( B + A' )] 2
with:
A' = arccos A
cos a sin b = 1 [sin(b - a) sin(b + a)] (addition theorem) 2
The multiplication of A and sinB is now transfered with an addition theorem into the operations B-A' and B+A' and two sine table accesses. Figure 12 gives a impression why the equation can be used. Two examples of an addition of two sine waves are shown. In the first case the sine wave have no phase shift. In the second case the sine waves are 180 phase shifted. Due to this addition, the desired amplitude between 0 and 2 can be obtained by adapting the phase shift between the two sine waves. The factor 1/2 is necessary to transfer the range to 0....1.
Semiconductor Group
17 of 29
AP08220 06.97
Generating sinusoidal three-phase currents with the CCU of C504
+1
+1
-1
-1
+
+1 +1 -1 -1
+
+2
=
+2
=
-2
-2
sin X + sin X = 2*sin X
sin X + sin(X+180) = 0
Figure 12: Two Examples for the Addition of two Sine Waves.
Semiconductor Group
18 of 29
AP08220 06.97
Generating sinusoidal three-phase currents with the CCU of C504
The procedure of generating the sinusoidal frequency works as follows: The host PC sends the desired amplitude A and frequency to the MCU. The delta and the angle variables are computed like mentioned above. To get A' the arccos A has to be calculated or better taken from a look-up table like the sine values. Then A' is added to and substract from the angle variable high byte (=B) yielding two new pointers to the sine table. Both values out of the table are added and then divided by two . The result (=U) is moved to the compare register and directly corresponds to the amplitude. (Hint: The division by two can be saved by appropriate sine table values, see next page). Some considerations about the amplitude resolution: The angle variable high byte identical to B covers a range of 360 with 8-bit = 0...255 (memory space of sine table). The amplitude A covers a range of 0...100% and therefore arccos A only covers a range from 0...90 which is a fourth of 360. Compared with 0...255, A' only varies between 0...64 (memory space of arccos table) which means the resolution of the amplitude is maximum 6-bit. The result is an amplitude resolution of 100%/64 = 1,56%. A disadvantage of this procedure is that the memory space of the sine table and the amplitude-resolution are linked directly. To enhance the resolution, the sine table length has to be extended above 8-bit and either the pointer part of the angle variable. But a pointer with more than 8 bit is more difficult to handle with the C504 resulting in an increase of CPU-time. On the other hand, the obtained resolution in angle and amplitude is without any doubt high enough to meet the requirements of midrange control algorithms for induction machines. Increasing the resolution will lead to an unproportional higher CPU load. Better results can be achieved if the remaining CPU time is used for closed-loop current control. The proposed 8-bit solution shows an interesting compromise between required computing power and resolution.
Semiconductor Group
19 of 29
AP08220 06.97
Generating sinusoidal three-phase currents with the CCU of C504
4.4 Generating the Memory Sine Tables The sine table is computed out of a 1/4 sine wave part stored in the field variable sine_src (include file sine.h). In this field the range 0...90 is represented in 255 memory bytes which means the whole sine period would take 1024 bytes space in memory and a 10-bit pointer variable. As in this application, only a 256 byte long sine table is desired according to an 8 bit pointer, an algorithm (function init_sine_tbl) takes only every fourth value to generate the memory sine table. Additionally, the algorithm multiplicates the contents of every memory place with 1/2 and adds the offset value. As result, the data range for the PWM compare values within the sine table gets a resolution of 7-bit. These measures are made once before the microcontroller starts to communicate with the host PC and save some instructions during run time. The following equation gives reasons for the multiplication with 0.5. The addition of the offset value is neccesary to ensure the dead time (see page 9 ).
U = A sin B =
1 1 1 [sin( B - A' ) + sin( B + A' )] = sin( B - A' ) + sin( B + A' ) 2 2 2
The finally generated memory sine tables consist of 256 bytes, each byte with a data range between the offset value 10 and 125 (dez.). The fastest way to generate three 120 phase shifted sine waves is to provide three 120 shifted sine tables in memory. That means the same angle variable points to different tables with different values for the three compare registers of the CCU. Figure 13 shows the generation of the three sine waves with an arccos table and three phase-shifted sine tables. The procedure is executed every 50 s within the compare timer 1 interrupt service routine and takes about 15 s CPU calculation time (which corresponds to 30% CPU load).
Semiconductor Group
20 of 29
AP08220 06.97
Generating sinusoidal three-phase currents with the CCU of C504
15
87
0
Arccos Table
64
Angle Pointer = B
35
A'
0 0 75 100 A' A'
these values are moved to the CCU compare registers
B-A'
B+A'
220
0.5*sin(B+A')
125
desired amplitude from host PC e.g. A = 75 (75%)
+
Sine Table R
10 125
0.5*sin (B-A')
125
Sine Table S
10 125
Sine Table T
10 0 256
60
Figure 13: Generating of three Sine Waves with three 120 Phase-Shifted Sine Tables R, S, T and one Arccos Table in Memory.
Semiconductor Group
21 of 29
AP08220 06.97
Generating sinusoidal three-phase currents with the CCU of C504
4.5 Compare Timer 1 Interrupt Service Routine Tasks The CCU compare register values are updated periodically every 50 s in the compare timer 1 underflow interrupt service routine. This task takes about 15 s, which corresponds to 30% of CPU-load. If a frequency change is required, a second task has to be started. To accelerate or decelerate the induction machine, the electrical rotating field for the induction machine has to be increased or decreased with a certain adjustable rate. To handle this task, every x ms for one PWM period (depending on the desired acceleration or deceleration speed), the delta value is increased or decreased until the new frequency of the rotating field is reached. With regard to a rotation direction change, the frequency can be decreased down to zero. To avoid feeding DC current to the machine, the delta variable is observed and the CCU output is switched off if delta is below 1Hz. During the acceleration/deceleration task, the CPU-load is temporally extended every x ms up to 60% (30 s calculation time) for one PWM period.
Semiconductor Group
22 of 29
AP08220 06.97
Generating sinusoidal three-phase currents with the CCU of C504
4.6 Main Program Task The C504 main program, first, initializes the on-chip peripherals, and then, runs an endless loop. This loop serves as an interface between the user commands from the host PC and compare timer 1 interrupt routine. Figure 14 gives a quick survey of the used command codes and the affected variables:
Command Code 0x80 0x81 0x82 0xC0 0xC1 0xC2 0xC3 0xC4 0xC5
Description send identification byte to host send actual frequency to host send amplitude to host get new frequency for CW* rotation from host get new frequency for CCW* rotation from host get amplitude from host get acceleration value from host get deceleration value from host get rotation flag from host
Corresponding Variables delta value, rotate power delta value delta value power up_step down_step rotate
* CW = clockwise CCW = counterclockwise Figure 14: Controller Command Codes from Host PC
Semiconductor Group
23 of 29
AP08220 06.97
Generating sinusoidal three-phase currents with the CCU of C504
4.7 Flow-Charts This chapter shows the flow-charts of the C504 software for controlling a three-phase induction machine. Figure 15 shows the RS232 interrupt service routine, which is necessary for receiving bytes via serial link from the host PC (sending bytes via serial link is performed directly in the main program) and the first part of the main program flow-chart. Figure 16 and 17 contains the remaining main program flow-charts. In Figure 18, the timer interrupt flow-chart can be found.
Semiconductor Group
24 of 29
AP08220 06.97
Generating sinusoidal three-phase currents with the CCU of C504
Start
RS232 Transmit/ Receive Interrupt
Initialize memory sine tabel
Clear RS232 Transmit Interrupt Bit
RS232 Receive Interr. Bit Set ?
Yes
Initialize RS232 Interface
No Latch Received Byte in Receive Buffer
Initialize Capture Compare Unit
Clear RS232 Receive Interrupt Bit
Initialize Interrupt Handling
Set RS232 Receive Flag
RS232 Receive Flag Set ?
No
Leave Interrupt
Yes Clear RS232 Receive Flag
Is Receive Buffer 0x80 ?
Yes
Send Identification Byte 0x5A to RS232
No
A
B
Figure 15:
Controller Program Flow-Chart and RS 232 Interrupt Service Routine
Semiconductor Group
25 of 29
AP08220 06.97
Generating sinusoidal three-phase currents with the CCU of C504
A
B
Is Receive Buffer 0x81 ?
Yes
Is Motor Rotation Switched On ?
Yes
Send Actual Frequency [Hz] to RS232
No
No Send 0x00 [Hz] to RS232
Is Receive Buffer 0x82 ?
Yes
Is Wave Generation Enabled ?
Yes
Send Power Value [%] to RS232
No
No Send 0x00 [%] to RS232
Is Receive Buffer 0xC0 ?
Yes
RS232 Receive Flag Set ?
Yes
Clear RS232 Receive Flag
No
No
Get New Frequency (for CW Rotating) from Receive Buffer Indicate frequency change Decide acceler. or deceler.
Is Receive Buffer 0xC1 ?
Yes
RS232 Receive Flag Set ?
Yes
Clear RS232 Receive Flag
No
No
Get New Frequency ( for CCW Rotating) from Receive Buffer Indicate frequency change Decide acceler. or deceler.
Is Receive Buffer 0xC2 ?
Yes
RS232 Receive Flag Set ?
Yes
Clear RS232 Receive Flag
No
No
Get New Power from Receive Buffer and fetch corresponding arccos value
C
Figure 16: Controller Program Flow-Chart (continued)
D
Semiconductor Group
26 of 29
AP08220 06.97
Generating sinusoidal three-phase currents with the CCU of C504
C
D
Is Receive Buffer 0xC3 ?
Yes
RS232 Receive Flag Set ?
Yes
Clear RS232 Receive Flag
No
No
Get Acceleretion Value from Receive Buffer
Is Receive Buffer 0xC4 ?
Yes
RS232 Receive Flag Set ?
Yes
Clear RS232 Receive Flag
No
No
Get Deceleration Value from Receive Buffer
Is Receive Buffer 0xC5 ?
Yes
RS232 Receive Flag Set ?
Yes
Clear RS232 Receive Flag
No
No
Get Rotation Flag from Receive Buffer
Rotate Flag Set ?
No Set Motor Frequency = 0
Yes
Figure 17:
Controller Program Flow-Chart (continued)
Semiconductor Group
27 of 29
AP08220 06.97
Generating sinusoidal three-phase currents with the CCU of C504
Compare Timer 1 Interrupt
anlge = angle + delta
calculate angle + arccos(power)
calculate angle - arccos(power) load CCU with new sine wave values
decrement interrupt counter
Yes
frequency change ?
No No
decrease frequency ?
15s
Yes
interrupt counter = 0?
No
16...17s
Yes
No
increase frequency delta < delta_new
Yes
No
Decrea. frequency delta > delta_new?
Yes
frequency change finished
delta = delta + up_step
frequency change finished
delta = delta down_step
Yes
dissable power output 30s
ABS (frequency) < 1Hz ?
No
enable power output
leave interrupt
Figure 18: Controller Program Flow-Chart - Compare Timer 1 Interrupt Service Routine
Semiconductor Group
28 of 29
AP08220 06.97
Generating sinusoidal three-phase currents with the CCU of C504
4.8 Conclusion The versatile structure of the on-chip Capture Compare Unit of the Siemens microcontroller C504 allows an easy generation of three sine wave currents, dedicated to the control of inductance drives. Thanks to a time-optimized algorithm, all control tasks can be handled in a very efficient way, requiring only few CPU-computing time. The proposed communication protocol (via serial channel) with a host PC shows the flexibility of the combination of the well known C500 family with a new powerful Capture Compare Unit. This application note proposes a HW- and SW- structure dedicated for AC drive control. Due to the integrated peripherals in the C504, very few external components are necessary, so the total system costs are reduced. The implementation of this open-loop induction drive control algorithms with low CPU load shows the first step towards closed-loop control solutions for mid-range applications. The adapted structure of the C504 leads to a very interesting compromise between system costs and its performance.
Semiconductor Group
29 of 29
AP08220 06.97


▲Up To Search▲   

 
Price & Availability of AP082201

All Rights Reserved © IC-ON-LINE 2003 - 2022  

[Add Bookmark] [Contact Us] [Link exchange] [Privacy policy]
Mirror Sites :  [www.datasheet.hk]   [www.maxim4u.com]  [www.ic-on-line.cn] [www.ic-on-line.com] [www.ic-on-line.net] [www.alldatasheet.com.cn] [www.gdcy.com]  [www.gdcy.net]


 . . . . .
  We use cookies to deliver the best possible web experience and assist with our advertising efforts. By continuing to use this site, you consent to the use of cookies. For more information on cookies, please take a look at our Privacy Policy. X