author: International Team
publisher: Daniel Garrido
licence: Creative Commons
place: University of Southern Denmark- Odense
@fomenting colaborational knowledge
1. PROJECT
Generator control
International team:
Esta obra está bajo una licencia de Creative Commons.
2. TABLE OF CONTENTS
I.GENERAL DESCRIPTION……………………………………………….. 3
II.GENERAL IDEA OF THE PROJECT…………………………………....4
III.GENERAL SCHEMA OF THE CONNECTIONS…………………….. 5
IV.PROBLEMS TO SOLVE………………………………………………….7
V.THEORETICAL INTRODUCTION…………………………………….. 7
VI.DC MOTOR- GENERATOR (MEASUREMENT)…………………... 14
VII.POWER ELECTRONICS SUPPLY: H- BRIDGE ELECTRONIC
CIRCUIT…………………………………………………………………….. 25
VIII.HEX BUFFER (NON- INVERTING) CD 4010C…………………… 34
IX.DC- DC CONVERTER…………………………………………………. 36
X.SERVOMOTOR- MAXON DC MOTOR………………………………. 38
XI.MICROCONTROLLER………………………………………………... 40
XII.TRANSDUCER………………………………………………………… 50
XIII.LabVIEW- CONTROL APPLICATION……………………………. 56
XIV.SUMMARY…………………………………………………………….. 64
XV.BIBLIOGRAPHY……………………….. ……………………………. .65
2
3. I. GENERAL DESCRIPTION
This project consists of control and supervision of generators. The generator, we have, shall
drive in ”Stand-alone”, together with a ”Rigid grid” or together with a “twin generator”. The
generator is mechanical connected to a compound motor. The compound motor is the primary drive
force. The generated voltage frequency controls from the velocity of the DC-motor, while the
amplitude of the tension is controlled from the magnetic voltage.
The controller gets the power supply scald from a 3-phase transformer. This AC shall be
rectified to a DC voltage. This gives power supply to the DC-servomotors. The electronic circuits are
controlled by a microcontroller.
The Data part includes:
Design, analysis and modelling of the DC-servomotor drive and SCADA
The electrical power includes:
Analysis, modelling and test of DC- motor and synchrony generator, transformer and power
grid.
Steps of paralleling the synchronous generator to the grid (prime mover – DC
motor):
On the output has to be 400V, 50Hz.
To control voltage, frequency and power we can adjust by changing:
armature voltage of DC motor
field current of DC motor
field current of synchronous generator
1) Switch on DC power supply
2) Apply DC power supply to DC motor
3) Adjust armature voltage of DC motor
4) Adjust field current of synchronous generator until on the output will be 400V
5) Check lamps brightness (the phase sequence is correct the lamps will have the same
brightness)
6) Adjust the speed to 50Hz (by changing the field current of DC motor) unless synchroscope
would show that the speed is “too fast” or “too slow”
7) Synchronization – switch on to the grid
8) Power control – change the field current of synchronous generator
3
4. II. GENERAL IDEA OF THE PROJECT
DSP
DEBBUGER
LAB VIEW
SOFTWARE
SERIAL
BUS
NI- USB 6008
CONVERTER
DATA
ACQUISITON
TRANSDUCER
ADMC401
MICROCONTROLLER
PWM
SIGNAL
DIGITAL
AND
ELECTRONICS ANALOG
TESTERS
REAL
H
VALUES
BRIDGE
MACHINES
GRID
SERVOMOTORS
DC MOTOR- GENERATOR
4
7. IV. PROBLEMS TO SOLVE
POWER ELECTRONICS SUPPLY: H- BRIDGE
DC- DC CONVERTER
HEX BUFFER (NON- INVERTING) CD 4010C
MICROCONTROLLER ADMC 401
SERVOMOTOR- MAXON DC MOTOR
MEASUREMENT
NI- USB 6008 A/D CONVERTER
TRANSDUCERS: TAS 331-DG, TAS 311-DG, MIQ96, MTR-1
LAB VIEW: FRONT PANEL AND BLOCK DIAGRAM
V. THEORETICAL INTRODUCTION
1. Synchronous generators principles
Fig. V1 Synchronous generator
A synchronous generator rotates with the constant speed in the steady state;
It is a doubly excited machine (the rotor poles (field windings) are excited by the dc current,
the stator (armature) windings are connected to the ac supply);
When the field current (excitation current) flows through the rotor field winding, it establishes
a sinusoidally distributed flux in the air gap. If the rotor is now rotated by the prime mover (dc
motor), a revolving field is producing in the air gap (excitation field). The rotating flux so
produced will change the flux linkage of the armature windings and will induce voltages in the
stator windings (excitation voltages).
The rotor speed and frequency of the induced voltage are related by:
120 f
n
p
, where n – rotor speed in rpm, p – number of poles.
The excitation voltage ( E f ) is proportional to the speed ( f ), excitation flux ( ), the latter
in turn ( N ) depends on the excitation current ( I f ):
E f 4,44 f N K w
7
8. , where K w – winding factor
The variation of the excitation voltage with the field current is shown in figure 2.
With increasing the field current I f , flux does not increase linearly with I f , because of the
saturation of the magnetic circuit.
Fig. V2 The magnetization characteristic of the synchronous machine
The equivalent model of the synchronous generator:
Fig. V3 The equivalent model of the synchronous generator (OCC)
E f I a jX ar E ar
, where I f – field current, I a – current in the stator, f – flux in the air gap, E f – voltage by f ,
Ear – armature reaction voltage, X ar - reactance of armature reaction or magnetizing reactance.
Power (P, Q) and torque (T):
Fig. V4 Equivalent circuit per phase
8
9. , where: Vt – terminal voltage, X s X ar X al , ( X s – synchronous reactance, R a – stator winding
resistance, X al - leakage reactance), Z s Ra jX s ( Z s – synchronous impedance)
3Vt E f
P3 sin
Xs
2
3 Vt E f 3 Vt
Q3 cos VAR
Xs Xs
P3
T
syn
– power or torque angle
Fig. V5 Power and torque characteristics
2. The infinite bus
The transmission of power is normally at high voltage levels (hundreds of kilovolts) to
achieve higher efficiency;
A transformer is used to step up the voltage to the infinite bus;
The synchronous generator and infinite bus must have the same:
Voltage
Frequency
Phase
Phase sequence
These conditions can be checked by synchroscope (running too fast or too slow – frequency of
the incoming machine is higher or lower than that of the infinite bus) and synchronizing lamps
(if the phase sequence is correct the lamps will have the same brightness, if not – the lamps
will brighten and darken in step);
Fig. V6 Diagram of paralleling a synchronous generator with the infinite bus using synchronizing lamps
9
10. 3. DC motors principles
The armature winding is placed on the rotor and field windings are placed on the stator.
The voltage induced in the armature winding is alternating.
A mechanical commutator and a brush assembly function as rectifier or inverter, making the
armature terminal voltage unidirectional.
DC motors can provide a wide range of accurate speed and torque control.
Speed control in a dc machine can be achieved by following methods:
1) Armature voltage control (smooth variation of speed control, armature circuit resistance
Ra and field current If remain constant, armature terminal voltage Vt is varied to change
the speed, as Vt increases – the speed increases linearly);
2) Field control (armature circuit resistance Ra and armature terminal voltage Vt remain
constant, field current If is varied to change the speed, the speed varies inversely with the
field current);
3) Armature resistance control (charging resistance of the armature circuit with fixed other
parameters);
The common method of control is the use of a separately excited dc motor with constant field
excitation. The speed is controlled by changing the voltage applied to the motor terminals.
Fig. V7 Separately excited dc motor
The voltage (Vt), armature current (Ia), speed (ωm) and torque (T) are related as follows
(separately excited dc motor):
E a K a m Vt I a Ra
T Ka Ia
V I a Ra
m t
Ka
Vt Ra
m T
K a ( K a ) 2
, where: E a – armature induced voltage, – magnetic flux, K a – armature constant
Fig. V8 Torque- speed characteristics
10
11. 4. The DC motor speed controller
The purpose of a motor speed controller is to drive a motor at the demanded speed. The
controller may or may not actually measure the speed of the motor. If the controller measures the
speed of the motor, it is called a Feedback Speed Controller or Closed Loop Speed Controller, if not it
is called an Open Loop Speed Controller. Feedback speed control is better, but more complicated.
The speed of a DC motor is directly proportional to the supply voltage, so e.g. if we reduce the
supply voltage from 12 Volts to 5 Volts, the motor will run more slowly.
The speed controller works by varying the DC voltage sent to the motor. It could do this by simply
adjusting the value of the voltage sent to the motor, but this is quite inefficient. A better way is to
switch the motor's supply on and off very quickly. If the switching is fast enough, the motor doesn't
notice it, it only notices the average effect. The motor won’t have time to change speed much, so the
speed will be quite steady. This is the principle of switch mode speed control (PWM – Pulse Width
Modulation). In our project we used onboard microcontroller which has PWM outputs.
As the amount of time that the voltage is on increases compared with the amount of time that
it is off, the average speed of the motor increases.
This on-off switching is performed by power MOSFETs (that the H-Bridge contains). A
MOSFET (Metal-Oxide-Semiconductor Field Effect Transistor) is a device that can turn very large
currents on and off under the control of a low signal level voltage.
5. PWM- pulse width modulation
Pulse width modulation (PWM) is a technique in which a series of digital pulses is used to
control an analog circuit. The length and frequency of these pulses determines the total power
delivered to the circuit. PWM signals are most commonly used to control DC motors.
The digital pulse train that makes up a PWM signal has a fixed frequency and varies the pulse
width to alter the average power of the signal. The ratio of the pulse width to the period is referred to
as the duty cycle of the signal.
Fig. V9 PWM signals of varying duty cycles
Fig. V10 Definition of a general square wave
11
12. PWM uses square wave whose duty cycle is modulated resulting in the variation of the average
value of the waveform. If we consider a square waveform f(t) with a low value y min , a high value ymax
t on
and a duty cycle D (figure V10), the average value of the waveform is given as:
T
T
1
y
T f (t )dt
0
As f(t) is a square wave, its value is y max for 0 t D T and y min for D T t T .
The above expression then becomes:
DT T
1 D T y max T (1 D) y min
y ( y max dt y min dt ) D y max (1 D ) y min
T 0 DT
T
This expression can be simplified by assuming y min 0 ,
y D y max
From this equation, it is obvious that the average value of the signal y is directly depended on the
duty cycle D.
To generate PWM signal we need sawtooth or triangle waveform and a comparator. When the
value of the reference signal – sine wave is more than the modulation waveform, the PWM signal is in
the high state, otherwise it is in the low state (fig. V11).
Fig. V11 Principle of the PWM signal generating
Sigma – Delta modulation: the output signal is subtracted from a reference signal to form an
error signal. This error is integrated, and when the integral of the error exceed the limits, the output
changes state.
12
13. Fig. V12 Principle of the sigma- delta PWM
Microcontrollers are the digital circuits that can generate PWM signals to control an electrical
motor. They normally use a counter that increments periodically (it is connected directly or indirectly
to the clock of the circuit) and is reset at the end of every period of the PWM. When the counter value
is more than the reference value, the PWM output changes state from high to low.
Important facts:
1) To increase speed you increase pulse width, so you increase motor voltage.
2) Frequencies between 20 Hz and 18 kHz may produce audible screaming from the speed
controller and motors.
3) RF interference emitted by the circuit will be worse the higher the switching frequency is.
4) Each switching on and off of the speed controller MOSFETs results in a little power loss.
Therefore the greater the time spent switching compared with the static on and off times, the
greater will be the resulting switching loss in the MOSFETs.
5) The higher the switching frequency, the more stable is the current waveform in the motors.
This waveform will be a spiky switching waveform at low frequencies, but at high frequencies
the inductance of the motor will smooth this out to an average DC current level proportional to
the PWM demand. This spikyness will cause greater power loss in the resistances of the wires,
MOSFETs, and motor windings than a steady DC current waveform.
13
14. VI. DC MOTOR- GENERATOR (MEASUREMENT)
Measurements for finding the relations between the active, reactive, apparent power and DC
motor and synchronous generator currents
DC MOTOR SYNCHRONOUS GENERATOR
Fig. VI1 DC motor as prime mover for the synchronous generator (synchronous generator as
mechanical load for DC motor)
EQUATIONS
DC MOTOR SYNCRONOUS GENERATOR
V1 I arm1 Z1 Ef1 Ef 2 I arm 2 Z 2 V2
P1 3 I arm1 V1 cos P2 3 I arm 2 V2 cos
120 f1
n
2p
Ef1 n K E p1 P K p f1 50 Hz
V1 Z I Q K Q V1 400V
n 1 arm1
K E p1 K E p1
p1 K I arm1
V1 Z I
n 1 arm1
K1 I field 1 K1 I field 1
USING THE EQUATIONS TO SOLVE CURRENTS FROM P AND Q
VALUES
The way the system gets this final relations between currents and P and Q using the
expressions shown below:
14
15. 120 f1 P1
n I arm11
P K p f1 50 Hz 2p 3 V1 cos
P f n Iarm DC MOT
Ef1 f I arm1
V1 Z I
n 1 arm1
K1 I field 1 K1 I field 1
Ifield DC MOT
Q K Q V1 400V Ef 2 I arm 2 Z 2 V2 Ef 2 f I arm 2
Q VG EfG Ifield GEN
S 3 V I
Fig. VI2 Relations between currents of motor, generator and powers
Those expressions should be checked in real world by doing tests of dc motor and
synchronous generator. We then will get the constant relations found in the equations.
OPEN AND SHORT CIRCUIT TESTS OF SYNCHRONOUS GENERATOR
a) Open – circuit test (terminals are open, no load) – terminal voltage is measured
Ef (V2 -fig. VI1), field current is varied If (If2 – fig. VI1)
Fig. VI3 Circuit for this type of test
Values that we measured in the laboratory:
I field (A) 0 0,01 0,02 0,032 0,045 0,053 0,064
Ef (V) 2,32 9,88 16,6 28,52 41,1 45,3 53,7
Ef (V) / 3 - per phase
Ef (V) 1,34 5,7 9,58 16,45 23,71 26,14 30,98
0,081 0,092 0,1 0,114 0,123 0,136
67,7 77,3 84,7 97,4 110 116,7
Ef (V) / 3
39,06 44,6 48,80 56,19 63,46 67,33
15
16. Fig. VI4 Open- circuit test
b) Short – circuit test (terminals are shorted) field current is varied If, armature
current is measured Iarm
Fig. VI5 Circuit for this test
Values that we measured in the laboratory:
I field (A) 0 0,012 0,021 0,034 0,052 0,075 0,094 0,103 0,126 0,136
I arm (A) 0,01 0,037 0,091 0,143 0,209 0,299 0,365 0,427 0,490 0,531
Error measured: I arm m = I arm m – I arm m (I field (0))
I arm (A) 0 0,027 0,081 0,133 0,199 0,289 0,355 0,417 0,480 0,521
Fig. VI6 Short- circuit test
IMPEDANCE
We obtain the impedance of the synchronous generator from the figures mentioned before:
y 4,9536 x Ef 4,9536 Ifield (V) (fig VI4)
y 0,0491 x Iarm 0,0491 Ifield (A) (fig VI6)
Ef 4,9536
Zs = 100,88
Iarm 0,0491
R measured = 2,4 Ω
16
17. Xs ( Zs) 2 ( R) 2 (100,88) 2 (2,4) 2 100,85 H
Fig. VI7 Impedance Zs, Terminal voltage Ef, amature current Iarm as function of field current
TESTING RELATIONS CURRENTS – SPEED OF DC MOTOR (in laboratory)
TEST 1.
VT [V] IA [A] N [rpm] Ωm kg Pout [W] Vload M [N*m]
[rad/s] [V]
0 0,0 0 0,000 0,000 0,000 0,000 0,000
20 0,5 160 1,005 0,300 1,480 0,012 1,473
40 1,0 314 1,973 0,450 4,360 0,037 2,210
60 1,5 483 3,035 0,600 8,941 0,053 2,946
80 2,0 633 3,977 0,750 14,647 1,500 3,683
100 2,8 807 5,071 0,850 21,166 20,000 4,174
120 3,5 695 6,063 1,000 29,769 40,000 4,910
140 4,0 1127 7,081 1,150 39,986 75,000 5,647
160 4,8 1300 8,168 1,300 52,136 86,000 6,383
180 5,5 1463 9,192 1,450 65,447 97,500 7,120
200 6,0 1625 10,210 1,600 80,210 108,000 7,856
TEST 2.
I arm DC I field DC V arm DC V field DC Speed n V dc supply
[A] [A] [V] [V] [rpm] [V]
2,44 0,13 16,3 25,97 340 30
2,05 0,16 25,3 32 543 37
1,86 0,189 30,8 35,9 600 42
1,33 0,29 59,2 57,8 835 66
1,15 0,39 81 79,5 902 87
1,07 0,508 106 97,5 988 112,6
1,06 0,62 131,4 119,1 1082 137,6
1,06 0,75 160 144 1217 166
1,07 0,85 185 165,7 1335 191,3
1,12 0,98 211,4 189,8 1463 218
1,14 1,06 230 206,2 1554 237
1,17 1,13 247,8 221,8 1638 254,8
1,21 1,227 268,8 240,6 1737 276,6
17
18. Fig. VI8 DC motor speed dependence on the armature current
In this graphic we can see that the speed increases with increasing of the armature current. The
equation we can deduce is:
Fig. VI9 DC motor speed dependence on the field current
In this graphic we can see how field current influences on the speed are highly change by the
currents. The equation we can deduce is:
TESTING ARMATURE CURRENT INFLUENCE OF DC MOTOR ON REAL,
REACTIVE AND APPARENT POWER OF GRID
Measured values:
GEN DC MOTOR GRID DC M GEN Dc sup
I field I arm I field P [W] Q[VAR] S [VA] Varm V field V field
[A] [A] [A] [V] [V] [V]
0,976 3,26 0,406 46 191,64 199,3 163 120 147
0,969 3,478 0,405 64 195 184 180 120 147
0,961 3,959 0,403 123 152 198 136,5 120 147
0,958 4,09 0,402 137 153 203 136 118 147
0,932 5,31 0,395 308 68,52 320 135 117 147
0,930 6,3 0,391 441 138 469 136 118 147
0,924 6,77 0,389 473 134,75 500 135 112 147
0,895 9,49 0,377 796,2 316,30 877,2 135 111 147
0,894 9,63 0,377 800 315 857 135 116 147
18
19. Fig. VI10 Powers dependence on the armature current (DC motor)
In this graphic we can see that P, Q and S are highly depend on the DC motor armature
current. The equations we can deduce are:
Fig. VI11 Currents dependence on real power
In this graphic we can see that only armature current of dc motor changes with real power. The
equation we can deduce is:
TESTING FIELD CURRENT INFLUENCE OF SYNCHRONOUS
GENERATOR ON REAL, REACTIVE POWER, ARMATURE AND FIELD
CURRENTS OF DC MOTOR
Measured values:
GEN DC MOTOR GRID DC M GEN
I field I arm I field P [W] Q S [VA] V arm V field
[A] [A] [A] [VAR] [V] [V]
0,945 7,05 0,387 504 71 506 134 120
0,975 7,08 0,387 495 167 518 134 120
0,998 7,13 0,387 491 244 550 134 122
1,054 7,07 0,386 494 439 661 134 130
1,098 7,08 0,385 486 612 785 134 140
1,13 7,16 0,388 490 739 893 134 143
19
20. Fig. VI12 Powers dependence on the field current (synchronous generator)
In this graphic we can see how P,Q, S depend on the generator field current. The equations we
can deduce are:
Fig. VI13 Currents dependence on real power
In this graphic we conclude that there are no changes in the DC Motor currents when the
Generator field current is changed.
TESTING FIELD CURRENT INFLUENCE OF DC MOTOR ON REAL,
REACTIVE POWER, ARMATURE AND FIELD CURRENTS OF DC MOTOR
AND SYNCHRONOUS GENERATOR
Measured values:
GEN DC MOTOR GRID DC M GEN
I field I arm I field P [W] Q S [VA] V arm V field
[A] [A] [A] [VAR] [V] [V]
1,16 3,54 0,42 74 904 909 138 150
1,158 4,4 0,398 162 887 903 134 140
1,14 5,2 0,378 254 829 865 131 150
1,13 6,17 0,358 353 751 824 127 150
1,11 7,06 0,342 427 694 818 124 150
1,10 7,8 0,32 487 647 803 121 150
1,09 8,7 0,31 555 569 790 118 150
20
21. Fig. VI14 Powers dependence on the field current (DC motor)
In this graphic we can see how P,Q, S depend on the DC motor field current. The equations
we can deduce are:
Fig. VI15 Currents dependence on real power
In this graphic we can see that only armature current of dc motor changes with real power. The
equation we can deduce is:
AFTER THE TESTS WE TRY TO FIND THE REAL RELATIONS
120 f1 P1
n I arm11
P K p f1 50 Hz 2p 3 V1 cos
P f n Iarm DC MOT
Ef1 f I arm1
V1 Z I
n 1 arm1
K1 I field 1 K1 I field 1
Ifield DC MOT
21
22. Q K Q V1 400V Ef 2 I arm 2 Z 2 V2 Ef 2 f I arm 2
Q VG EfG Ifield GEN
S 3 V I
RELATION BETWEEN P AND CURRENTS
As is shown in the fig. VI4:
E f f ( I fieldGEN ) E f 495,36 I fieldGEN
Z GEN 100,88 495,36 I fieldGEN I armGEN Z GEN VGEN
495,36 I fieldGEN I armGEN 100,88 VGEN VGEN 495,36 I fieldGEN I armGEN 100,88
S
I armGEN
3 400
As is shown in the figure:
81, 343 I fieldGEN 367, 47
SGEN 81, 343 I fieldGEN I armGEN
3 400
I armGEN 0,1174 I fieldGEN 53,506
VGEN 495,36 I fieldGEN 11,84 I fieldGEN 53,5V
QGEN K (VGEN 400V )
QGEN K (495,36 I fieldGEN 11,84 I fieldGEN 53, 5V 400V )
QGEN K (485,51 I fieldGEN 453,506V )
As is shown in the Plot n:
QGEN 139,144 I fieldGEN 108,33 K Q 0, 2865
22
23. EQUATIONS AFTER OPERATIONS WITH TEST VALUES
120 f1 P1
n I arm11
P K p f1 50 Hz 2p 3 V1 cos
P f n Iarm DC MOT
Ef1 f I arm1
V1 Z I
n 1 arm1
K1 I field 1 K1 I field 1
Ifield DC MOT
CONCLUSION
P1
I arm11
P K p f1 50 Hz 3 V1 cos
P f n Iarm DC MOT
Ef1 f I arm1
V1 Z I
n 1 arm1
K1 I field 1 K1 I field 1
Ifield DC MOT
RELATION BETWEEN Q AND CURRENTS
As is shown in the Plot n:
E f f ( I fieldGEN ) E f 495,36 I fieldGEN
As is shown in the Plot n
Z GEN 100,88 495,36 I fieldGEN I armGEN Z GEN VGEN
495,36 I fieldGEN I armGEN 100,88 VGEN VGEN 495,36 I fieldGEN I armGEN 100,88
S
I armGEN
3 400
As is shown in the Plot n:
81, 343 I fieldGEN 367, 47
SGEN 81, 343 I fieldGEN I armGEN
3 400
I armGEN 0,1174 I fieldGEN 53,506
VGEN 495,36 I fieldGEN 11,84 I fieldGEN 53,5V
23
24. QGEN K (VGEN 400V )
QGEN K (495,36 I fieldGEN 11,84 I fieldGEN 53, 5V 400V )
QGEN K (485,51 I fieldGEN 453,506V )
As is shown in the Plot n:
QGEN 139,144 I fieldGEN 108,33 K Q 0, 2865
EQUATIONS AFTER OPERATIONS WITH TEST VALUES
S 3 V I
Q K Q V1 400V Ef 2 I arm 2 Z 2 V2 Ef 2 f I arm 2
Q VG EfG Ifield GEN
QGEN 0, 2865(VGEN 400V ) E f 11,84 I fieldGEN 53, 5V VGEN E f 495,36 I fieldGEN
CONCLUSION
Q QGEN 139,144 I fieldGEN C (c f ( P ))
Ifield GEN
24
25. VII. POWER ELECTRONICS SUPPLY: H- BRIDGE
ELECTRONIC CIRCUIT
A) GENERAL FIGURE:
Fig. VII1Scheme of H- bridge
B) TRUTH TABLE:
V6 V5 Result
0 0 stop
0 1 reverse
1 0 forward
1 1 not allowed
0 logic LOW, 0V
1 logic HIGH, 5V
25
26. C) OPERATING PRINCIPLES:
Forward mode:
V6 1 -> Vce (Q 2) 0V saturated -> I c (Q 2) I c max -> V gs (M 2) 12V ->
Vds ( M 2) 0V saturated -> I d ( M 2) I d max -> Vd ( M 2) 12V -> V5 0V ->
Vce (Q1) 12V clogged -> I c (Q 2) 0 A -> V gs (M 3) 0V -> Vds ( M 3) 12V clogged ->
I d ( M 3) 0 A -> V gs (M 4) 11V from voltage divider -> Vds ( M 4) 0V saturated ->
Vd ( M 4) 0V -> V gs (M 1) 0V -> I d ( M 1) 0 A -> Vds ( M 1) 12V clogged, DC motor
rotates in forward direction
Reverse mode:
V6 0 -> Vce (Q 2) 12V clogged-> I c (Q 2) 0 A -> V gs (M 2) 0V ->
Vds ( M 2) 12V clogged -> I d ( M 2) 0 A -> Vd ( M 2) 0V -> V5 1V ->
Vce (Q1) 0V saturated -> I c (Q 2) I c max -> V gs (M 3) 12V -> Vds ( M 3) 0V saturated ->
I d ( M 3) I d max -> V gs (M 4) 0V -> Vds ( M 4) 12V clogged -> Vd ( M 4) 12V ->
V gs ( M 1) 11V from voltage divider -> I d ( M 1) I d max -> Vds ( M 1) 0V saturated, DC motor
rotates in reverse direction
Stop mode:
V6 0 -> Vce (Q 2) 12V clogged-> I c (Q 2) 0 A -> V gs (M 2) 0V ->
Vds ( M 2) 12V clogged -> I d ( M 2) 0 A -> Vd ( M 2) 0V -> V5 0V ->
Vce (Q1) 12V clogged -> I c (Q 2) 0 A -> Vds ( M 3) 12V clogged -> I d ( M 3) 0 A ->
Vd ( M 3) 0V M4 and M3 unpolarizated, DC motor doesn’t rotate
Not allowed mode:
V6 1 -> Vce (Q 2) 0V saturated -> I c (Q 2) I c max -> V gs (M 2) 12V ->
Vds ( M 2) 0V saturated -> I d ( M 2) I d max -> Vd ( M 2) 12V -> V5 1V ->
Vce (Q1) 0V saturated -> I c (Q 2) I c max -> V gs (M 3) 12V -> Vds ( M 3) 0V saturated ->
I d ( M 3) I d max -> Vd ( M 3) 12V
So Transistors M1, M4 are also saturated which shorts power supply!!! Not recommended.
26
27. D) CHARACTERISTIC SIGNALS:
FORWARD AND REVERSE MODE
- control voltage signals
- dc motors voltage and current
27
28. STOP MODE
- control voltage signals
- DC motor’s voltage and current
28
29. NOT ALLOWED MODE
- control voltage signals
- DC motor’s voltage and current
29
30. E) CHOSEN INTEGRATED CIRCUIT:
To build power electronic supply which drives each DC servomotor we have chosen IC type
L298. The l298 id is an integrated monolithic circuit. It is a high voltage, high current dual full- bridge
driver designed to accept standard TTL logic levels and drive inductive loads such as relays,
solenoids, dc and stepping motors. Two enable inputs are provided to enable or disable the device
independently of the inputs signals. The emitters of the lower transistors of each bridge are connected
together and the corresponding external terminal can be used for the connection of an external sensing
resistor. An additional supply input is provided so that the logic works at the lower voltage. The block
diagram of this circuit is as following:
Fig. VII2 Block diagram
THE TRUTH TABLE OF THIS IC AS FOLLWING:
Inputs Function
C=H; D=L Forward
Ven=H C=L; D=H Reverse
C=D Fast Motor Stop
Ven=L C=X; D=X Free Running Motor Stop
30
31. PIN FUNCTIONS OF THIS IC ARE AS FOLLOWING (refer to the
block diagram):
MW. 15 Name Function
Between this pin and ground is connected the
1; 15 Sense A; Sense B
sense resistor to control the current of the load
Outputs of the Bridge A; the current that
2; 3 Out 1; Out 2 flows through the load connected between
these two pins is monitored at pin 1
Supply Voltage for the Power Output Stages.
4 Vs A non- inductive 100nF capacitor must be
connected between this pin and ground
5; 7 Input 1; Input 2 TTL Compatible Inputs of the Bridge A
TTL Compatible Enable Input; the L state
6; 11 Enable A; Enable B disables the bridge A (enable A) and/or the
bridge B (enable B)
8 GND Ground
Supply Voltage for the Logic Blocks. A
9 VSS 100nF capacitor must be connected between
this pin and ground
10; 12 Input 3; Input 4 TTL Compatible Inputs of the Bridge B
Outputs of the Bridge B. The current that
13; 14 Out 3; Out 4 flows through the load connected between
these two pins is monitored at pin 15
- N. C. Not Connected
PIN CONNECTIONS (top view):
Fig. VII3 Pin connections
31
32. TYPICAL ELECTRICAL PARAMETERS OF THIS IC:
F) PRACTICAL APPLICATION:
We are able to use one piece of IC L298 to drive two servomotors. According to general ideas
of our project we have to control three servomotors. That is why we use 2 pieces of L298. On the
following scheme we present practical circuit with all necessary external elements. The scheme shows
application for only one DC servomotor, because the rest is exactly the same. As an external power
supply we use standard adjustable laboratory DC supply.
Fig. VII4 Scheme of practical circuit
32
33. Description:
- the levels of control voltage signals are: L=0V, H=5V
- diodes D1, D2, D3, D4– reduce current spikes from motor switching, we use typical
Schottky’s diodes type: 1N5819 40V- peak repetitive reverse voltage, 25A non-
repetitive peak surge current
- capacitors which bypass power supply: C=100nF
- the value of Vs should respect total voltage drop on internal transistors and output
current. Our servomotor operates at 12V and 60mA. So lets take maximum voltage
drop as 1V, so Vs~13V, Vss=5V
- we don’t use sensing output
- to enable circuit Enable input is H
- each unused input called NC is connected to GND
- each unused output is connected to GND through 10MΩ resistor
- control voltage wire connections are as short as possible to avoid parasite induction
G) H- BRIDGE’S TEST:
Fig. VII5 H- Bridghe’s tests
Tests confirmed that H- Bridge was a good idea to use in our project to control the motor. In
the pictures above we can see two situations: when the motor is turning in right way- green diode
shows that and when the motor is turning in opposite way- red diode.
33
34. VIII. HEX BUFFER (NON- INVERTING) CD 4010C
In our project we used the buffer in front of the H – bridge, because higher current
productivity was needed to drive bridge properly (on the inputs of circuit L298 are placed bipolar
transistors that demand certain level of gate current, microprocessor can’t provide enough current to
activate H- Bridge). As the buffer we used CMOS 4010 integrated circuit.
General Description
The CD 4010 C hex buffer is monolithic complementary MOS integrated circuit. The N- and P-
channel enhancement mode transistors provide a symmetrical circuit with output swings essentially
equal to the supply voltage. This results in high noise immunity over a wide supply voltage range. No
DC power other than that caused by leakage current is consumed during static conditions. The gates
may be used as hex buffers, CMOS to DTL or TTL interface or as CMOS current drivers. Conversion
ranges are from 3V to 15V providing Vcc ≤ Vdd. The device also has buffered outputs which improve
transfer characteristics by providing very high gain.
Features
Wide supply voltage range: 3V to 15V
Low power typ.100nW
High noise immunity
High current sinking capability: min 8mA at V0=0,5V and Vdd=10V
Applications
Industrial control
Automotive
Data terminals
Medical electronics
Remote metering
Computers
Alarm systems
Instrumentation
Fig. VIII1 Connection and schematic diagrams
34
35. Fig. VIII2 Typical application
Absolute maximum ratings (limits beyond which damage to the device may occur):
Voltage at any pin Vss –0,3V to Vss +15,5V
Operating temperature range -45°C to +85°C
Power dissipation (Pd)
Dual- In- Line 700mW
Small Outline 500mW
Lead temperature Tl (soldering, 10s) 260°C
Operating Range (Vdd) Vss +3V to Vss +15V
35
36. IX. DC- DC CONVERTER
DC - DC converter allows us regulate dc power supply of the servomotors. This circuit
provides greater output current than the input current that we need to drive the servomotors.
VCC
Q1 Q2 Q3 high power and high current
control signal gain transistors
L1
M
C1 S1
D1
Fig. IX1 DC- DC Converter (S1 => DC motor)
We used DC- DC converter to increase the output current coming from H- Bridge using high
power transistors. So now we are able to use the power supply to provide the current for servomotors.
This system can operate with very small input currents, so we can regulate heat on the H-bridge by
regulating the current on output. Transistors will do all the work in that system.
To minimize the ripple on output we can use a low- pass filter. The only thing we have to do is
to assume the minimum frequency of the signal applied to input to control the servo motors. Our goal
is to build a filter that has a low resonance frequency lower than the minimum frequency that we can
generate from the microcontroller.
We used C = 470µF , L = 28,8µH for filter circuit in our test experiment. The test has shown
that we can easily drive a motor that needs 1,6A of the starting current. We can control also the speed
of motor changing the duty cycle of the input signal (the test signal was a square signal with Vpp=5V
and Voffset=5V to be able to use transistor correctly).
Another possibility was to use DC- DC converter alone to control DC servomotors by
changing the duty cycle with microcontroller, but using an H- Bridge makes it easier to work with
servomotors and control the generator.
Driving motor in both two ways
We encountered a small problem in this type of controlling. The problem was to drive the
motor in both ways forward and backward. We overcame this problem with something like a dual DC-
DC converter (figure VIII2). Both DC- DC converters should be driven by two independent voltage
otherwise ground will be a big problem that will cause a fatal error in circuit by equalizing both plus
and minus nodes of servomotor and stopping the motor.
36
37. control signal
high power and high current Q4 Q5 Q6
Q1 Q2 Q3 U1
control signal gain transistors
V2
V1 D1
L1
M
C1 S1
D2 L2
Fig. IX2 Dual DC- DC Converter
This system will make possible to drive also bigger motors by such low current electronic
devices.
Example of calculating the minimum value of circuit inductance:
Vd 5V , V0 12V assuming e.g. fs = 20kHz, I0 = 1A, C = 470µF and the ideal circuit components
V0 12 1
2,4V
Vd 5 1 D
D 0,58 0,6
1
Ts 50s
fs
TsV0
I0 D (1 D) 2 (Boundary mode)
2L
TV
Lmin s 0 D (1 D) 2 28,8H
2 I 0b
THE FORMULA FOR RESONANCE FREQUENCY
1 1
f res 1,37 kHz
2 LC 2 28,8 10 6 470 10 6
In the experiment we calculated the resonance frequency to build the filter. That frequency
should be lower than possible applied frequency range to the input of dc-dc converter.
37
38. X. SERVOMOTOR- MAXON DC MOTOR
Knowledge about basic servomotor features allows us design electronic device properly
(H–Bridge and DC- DC converter as well).
Fig. X1 Maxon DC motor
Fig. X2 Operating ranges
, whre n– speed, M– torque, I– current
Fig. X3 Short term operation
38
39. , where:
ON- Motor in operation
OFF- Motor inoperative
Î- max. peak current
Ipermiss.- max. permissible continuous current
Ton- ON time
T- cycle time ton + toff
D- Duty cykle in percent
Important parameters of the motor:
power rating (reccomended uotput power range) P [W]
nominal voltage U [V]
no load speed n0 [rpm] (motor turns at nominal voltage without speed, speed is proportional to
applied voltage)
starting torque M [mNm]
speed / torque gradient Δn / ΔM [rpm/mNm] (calculating at 25°C winding temperature)
no load current I0 [mA] – (depends on brush and gearing friction)
starting current Ia [mA] - proportional to starting torque
terminal resistance R [Ω] (at 25°C, determines starting current)
maximum permissible speed nmax [rpm]
maximum permissible continuous current Ipermiss [mA] (operating motor continuosly at
25°C)
max permissible continuous torque Mperm [mNm]
max output power Pmax [mW] (at 25°C rotor temperature)
max efficiency η [%] (the higher efficiency - nearer to no load speed)
torque constant Km [mNm/A]
speed constant Kn [rpm/V]
mechanical time constant τm [ms] (the time required the motor to accelerate from standstill to
63% of its no load speed, after 4τ rotor will reach 99% of no load speed)
moment of interia Jr [gcm2]
terminal inductance L [mH] (measured at 1kHz, sinusoidal.)
thermal resistance Rth [K/W] (from housing to ambient air)
Fig. X4 Motor parameters
39
40. XI. MICROCONTROLLER
The ADMC401 processor board is intended as a compact, highly integrated evaluation and
software development platform for the ADMC401 controller. The processor board permits access
through a UART connection to the Motion Control Debugger software that operates under Windows.
The Motion Control Debugger is used to download executable code, examine the contents of registers,
program memory and data memory, run executable modules, set breakpoints and enable single- step
operation.
In our project we have 3 electronic bridges. Each of them needs two PWM signals so
eventually the project requires using six PWM signals. The ADMC401 Analog devices equipment has
this possibility.
In this part of our report we are wondering about performance of the microcontroller and also
trying to find out suitable source code.
Power supply requirements
The ADMS401 processor board contains a 4- way terminal block for connection of external power
supplies. For correct operation, the following supplies were required:
+5V ± 5%, 300 mA (VDD)
+5V ± 5%, 30 mA (+AVDD)
-5V ± 5%, 30 mA (-AVDD)
Ground
The VDD supply powers the digital logic circuits of the processor board, including the
ADMC401 controller. In addition, it is used as the analog voltage supply of the ADMC401 and as the
input to the dc- dc converter that provides the isolated supply for the UART interface. The processor
board is laid out with separate analog and digital ground planes that are connected by a link (JP2)
close to the power supply terminal block for noise immunity. This link should not be removed. An
LED on the processor board indicated correct connection of the VDD supply. The +AVDD and
–AVDD supplies power the operational amplifiers used in the analog interface section. These
amplifiers correctly offset the analog inputs to the board for interface to the ADC inputs of the
ADMC401. Appropriate decoupling capacitors are provided on the processor board for all three power
supply inputs (VDD, +AVDD and –AVDD) to reduce noise coupling from the external power
supplies. However, for best performance, well- regulated external power supplies and correct wiring
are recommended.
Fig. XI1 Power supply connector of ADMC401 processor board
40
41. A) THE SINGLE UPDATE MODE AND DOUBLE UPDATE MODE
The PWM generation Unit of ADMC401 can be programmed to operate in two distinct
operating modes: single update mode or double update mode. We will be using the second one,
because it gives for us more capabilities. This mode is enabled by setting bit 6 of the MODECTRL
register. The performance and capability of double update mode are as a following:
The switching period is controlled by the PWMTM register according to:
Ts = 2*PWMTM * tck
, where tck is the DSP clock rate (38.5 ns at a 26 MHz CLKOUT rate)
The moments of interrupt are given by the PWMSYNC signal. It is produced by the internal
PWM Generation Unit every:
Tsync = PWMTM * tck
The width of PWMSYNC pulse is still controlled by the PWMSYNCWT register. As we can see,
moments of interrupts appear twice per switching period. After that microprocessor reads new duty
cycles values from suitable registers. PWMSYNC interrupt is generated within the ADMC401 by the
rising edge of signal. The PWMSYNC pulse is produced on the dedicated PWMSYNC pin.
New duty cycle’s values can be written to the PWMCHA, PWMCHB, PWMCHC registers
twice per switching period. This means that different values can be used to control both the rising edge
and falling edge of each PWM signal.
In addition, it is also possible to update all other registers of the PWM (PWMTM, PWMDT,
PWMPD, PMWSEG, PWMGATE, and PWMSYNCWT) at a rate of twice that of the switching
frequency. If these registers are not updated, the same value is applied continuously.
The bit 3 of SYSSTAT register (0 or 1) indicates half of duty cycles. When this bit is cleared,
the timer decrements each DSP clock period (tck) until it reaches zero. When we set this bit, the timer
is incrementing and the SYSSTAT signal is generated.
The duty cycle’ values can be also programmed by using of PWMDT register. DT means dead
time and it indicates shift between edges of two PWM signals. DT switches edges away from the
desired point by an equal amount.
PWMTRIP allows shutting down the microcontroller immediately. It is possible when we
change 1 to 0. At this moment also the PWMSYNC pulses are switched off. The bit 1 of SYSSTAT
register contains information about configuration of PWMTRIP.
Using of double update mode ensures some advantages:
It produces lower harmonic distortion than symmetrical pattern in single update mode. In other
words, our signals on the outputs are more similar in theoretical meaning.
The symmetrical PWM schemes can be also shown to produce small frequency distortions at
multiples of the fundamental output frequency. With the asymmetrical switching frequency schemes
(produced using double update mode) can be shown that no such harmonic can be produced.
It is also possible to update the applied voltage to the motor twice as fast as with single update
mode.
41
42. Disadvantage of using the double update mode:
The only disadvantage in double update mode is that the complete control law must be
computed within half a switching period. However, the power of the DSP core of the ADMC401
provides sufficiently fast and efficient processing that the computational burden of double update
mode can be handled adequately.
In case of double update mode it is possible to calculate ton and duty cycles value.
Fig. XI2 Switching periods
1. The on-times can be expressed as:
TAH ( PWMCHA1 PWMCHA 2 PWMDT1 PWMDT 2 ) tCK
TAL ( PWMTM 1 PWMTM 2 PWMCHA1 WPMCHA 2 PWMDT1 PWMDT 2 ) tCK
2. Duty-cycle can be expressed as:
TAH PWMCHA1 PWMCHA 2 PWMDT1 PWMDT 2
d AH
TS PWMTM 1 PWMTM 2
TAL PWMTM 1 PWMTM 2 PWMCHA1 WPMCHA 2 PWMDT1 PWMDT 2
d AL
TS PWMTM 1 PWMTM 2
Regardless of operation mode selection each of the six PWM outputs signals can be enabled or
disabled by separate output enable bits of the PWMSEG register. It is also possible by using
PWMPOL pin. It can be used to select the polarity of the PWM signals so either active high or active
low PWM patterns can be produced by the ADMC401.
The operation during start-up will be somewhat different depending on whether or not the
PWMTM register is the first PWM register that is written. If the PWMTM register is written first (we
will use this option), the PWM timer begin incrementing from zero to the PWMTM values. This
actually corresponds to second half cycle of the PWM. During this time, the PWM unit is in the
disable state and all six PWM outputs are OFF. Provided the PWMCHA, PWMCHB and PWMCHC
registers have all been written to at the time the PWM-timer reaches the PWMTM value, the first
internal load signal will then be generated when the PWM timer reaches the PWMTM value. At this
point the PWM generation unit enters the normal state and the new values are latched into the
PWMCHA, PWMCHB and PWMCHC registers. However the PWMSYNC pulse is generated at this
42
43. first load signal. The values written to the PWMCHA, PWMCHB and PWMCHC registers (in
conjunction with the other PWM registers such as PWMDT, PWMPD, PWMSEG, PWMGATE
registers) define the outputs during next half cycle (in double update mode). The appearance of the
first PWMSYNC pulse (and associated interrupt) will occur at the end of the first half cycle of PWM
when the PWMTM reaches zero. The second PWMSYNC pulse will occur at the second cycle of
PWM when the PWMTM reaches zero. This situation will be repeating cyclically.
B) GENERAL RELATIONS AMONG DIFFERENT FILES, WHICH
DOUBLE UPDATE PROGRAM CONSIST OF
main.dsp => this file is the actual implementation of the application. Therefore it contains at
least the starting point of the program. It must be located in the current working directory. This file
refers to set of header files (*.h). It contains initialisation functions and code which is intended to
demonstrate the use of particular set of library routines.
main.h => this file contains definition of specific system constant and system parameters,
configuration constants. All these constants are used by library routines. This file refers to header files
with general ADMC401 constants and some of macro definitions.
ADMC401.h => this file includes important ADMC401 constants with addresses assigned to
this constant.
macro.h => it contains definitions of some macros for commonly needed tasks.
PWM401.h => it is the part of implementation of PWM401 routine program. There are macros
definitions, variable definition which can be used by each module that refers to this file.
PWM401.dsp => the purpose of this code file is the implementation of subroutines and
definitions log global and local variables.
Tree of the above structure:
Main.dsp
PWM401.h
main.h
PWM401.h
macro.h ADMD401.h
subroutines:PWM_INIT
Fig. XI3 Structure of the double update program
43
44. Also provided are some other files which are either necessary to assembler/linker [architecture
files (ADMCxxx.ach, ADMCxxx.sys) register definition (ADMCxxx.h)] or useful for code
development [general purpose macros (macro.h), definition of routines included in the ROM of the
device (romutil.h) ,where applicable].
Compilation process
The batch file that compiles and links the application is called make.bat. It must be located in
the current working directory. In order to work correctly, the path of the Root_Directory is expected as
the input parameter.
Every code files is then assembled and linked. If no errors are found, the ADMCxxx
executable file main.exe is created and short informs of correct compilation. Firstly, the user`s code is
assembled with to a call to ams21.The second task is to compile all the library routines and packing
them into a 21xx library file. If the available program memory allows for it, this section may be
unchanged. If due to memory constraints unused library routines need to be excluded, the user may
remove them by simply removing the corresponding library file in the statement invoking. At last the
assembled object files are linked by the statement invoking LD21. Every user file must be listed in the
following line, where FILENAMEx is the name of the object file (without extension, i.e. MAIN) to be
linked .The library is linked automatically with the– user switch.
C) PWMCH values calculation to update duty cycles
Each of generated PWM signals has its own duty cycle. It can be updated using following
macro. The resultant values are computed as an actual value of PWMTM register multiplied by
desired duty cycle for each channel (expressed as hexadecimal variables set from external software i.e.
Lab View through SPORT- serial port). These hexadecimal variables we declare as circular data
buffers which will be explained in the next paragraph. In the end the resultant values are converted
into PWMCHA, PWMCHC and PWMCHC registers.
The general formula of this macro is as following:
PWMT initial value is defined in admc401.h file:
.CONST PWMTM = 0x2008; {PWM timer register}
D) Data Buffer declaration
We will declare data buffer as 3– element length circular buffer, each word is written down on
10 bits (in binary notation). Circular buffer can be located in certain boundaries in memory. It has to
start at a base address which is multiplied of 2n, where n is number of bits required to represent the
buffer length in binary notation. The “n” has to satisfy following formula:
2 21 L 2 n
, where L is the length of the buffer
So in our case L=3, in binary 3=>11 so we have got n=2 bits. We round upward the L value to
the closest power of 2, that’s why base address will be assigned by linker as a*22=4a for example it
44
45. will be 8. The 2 least significant bits will be set as 0 (because length of buffer in binary is presented on
2 bits)
Base address=XXXXXX00
And whole buffer address can be presented as:
XXXXXX00 – first element (base)
XXXXXX01 – second element
XXXXXX10 – third element
Next address inside buffer – calculation principle
The way how the next address is derived can be stated as follows:
Next address=(I+M-B)Modulo(L)+B
, where:
I -> current address
M -> modify value (signed)
B -> base address
L -> buffer length
M+I -> modified address
Modulo division returns a change from division
In our case at the beginning was: I0=8, B=8, M0=1, L0=3, then:
(I0+M0-B)Modulo(L0)+B=(8+1-8)mod(3)+8=1+8=9; now I0=9 =>
(9+1-8)mod(3)+8=2+8=10;
(10+1-8)mod(3)+8=0+8=8;
(8+1-8)mod(3)+8=9;
…………..
This generates following address sequence for the elements in our data buffer:
(8,9,10,8,9,10,8,9,10,8…….and so on)
Final declaration of our buffer can be stated as following:
.VAR/DM/RAM/CIRC dt[3];
.GLOBAL dt;
L0=%dt; {length of circular buffer is assigned to L0 register}
I0=^dt; {start address of buffer is loaded into I0 register}
M0=1; {reading buffer by increment location of 1 each time}
, where L0, I0, M0 are DAG index registers; L – buffer length register used to read and wraparound
the buffer; I – index register indicates memory location; M – increment register.
These registers are used to access buffer in code.
To make buffer possible to invoke from main.dsp program we have to add special “GLOBAL”
directive below the main declaration and also define it as “EXTERNAL” in main.dsp.
Now we are able to declare our “dt” buffer as a global variable in PWM401.h file. Part of
resultant listing from this file is:
45
46. Fig. XI4 Fragment of the microcontroller’s
E) SPORT usage
We use SPORT serial port as our data input from external Lab View software. ADMC401 has
two synchronous serial port called SPORT0 and SPORT1. We choose one of them to transfer data
from the outside: SPORT1.
Each SPORT has a five-pin interface:
SCLK – serial clock
RFS – receive frame synchronization
TFS – transmit frame synchronization
DR – serial data receive
DT – serial data transmit
SPORT can receive and transmit data simultaneously (DR, DT), the bits are synchronous to the
serial clock SCLK usually generated internally by processor. Frame synchronization signals RFS and
TFS are used to indicate the beginning of a serial data word or stream of serial words.
Additional important feature of SPORT:
support serial data word of length from 3 to 16 bits
using DAG registers- SPORT can automatically receive and transmit an entire circular buffer
with rate one word per cycle, this transfer is automatic and does not need additional programming
To configure SPORT we have to set proper bits and field values in its configuration registers
which are memory mapped. Following the most important control registers are distinguished:
46
47. 0x3FF6 – control register of multichannel mode, serial clock, frame synchronization,
companding mode, serial word length
0x3FF5 –data transfer frequency determination
0x3FF4 – frame synchronization frequency of receiving
0x3FF3 – autobuffering control register
Furthermore each SPORT has receive registers RX0, RX1 and transmit registers TX0, TX1 which are
not memory mapped, but are identified by assembler mnemonics.
To initialize SPORT configuration we choose direct method which simply assign immediate
data to proper register. For example:
AX0=0x6B27; {the contents of AX0 are written to the register of address 0x3FF2}
DM(0x3FF2)=AX0
a) SPORT1 enable, Boot Wait States and Program Memory States enable
To enable we set bits number 12, 4 3, 2, 1, 0 of register 0x3FFF.
b) SPORT1 serial clock enable
To enable internal SCLK clock signal for SPORT1 we set 14-th bit of register 0x3FF6. Frame sync
signal needs to have frequency of 60 kHz. That is because changes in CHA, CHB and CHC registers
are made according to PWMSYNC signal twice per PWM period with freq of 20 kHz. Hence SPORT
has to read out all three data words from Lab View until PWMSYNC interrupt occur. To adjust frame
sync signal freq we modify the value of RFSDIV modulus which can be calculated as:
RFSDIV=(SCLK freq/ RFS freq) – 1
Then, we have: SCLK freq=2.048 MHz, RFS freq=60 kHz=0.06 MHz => RFSDIV=34-1=33,
We put value “33” in decimal into register 0x3FF4;
c) Choice of serial word length for SPORT1
To set the number of bits of serial word as 10- bit we modify the value of SLEN field in 0x3FF6
control register. SERIAL WORD LENGTH=SLEN+ 1 and SLEN=9 (1001 in binary) => SWL=10 bit.
SLEN value is written binary on 4 least significant bits in 0x3FF6 register.
d) Enable frame synchronization for receiving mode
We set 13-th bit of register 0x3FF6 to enable RFS data synchronization.
e) Setting frame synchronization signal for receiving mode
We set 8-th bit as 0 in register 0x3FF6 to enable IRFS - externally generated frame sync signal. Now
the external data software (Lab View) controls the data transmission and reception. The SPORT1 will
wait for receiving frame sync before receiving data.
f) Enable the normal framing mode
We set 12- bit as 0 in 0x3FF6 register to enable normal framing mode for receiving data. If frame sync
signal is detected at the falling edge of SCLK clock signal, on the next falling edge of SCLK signal
data is latched on and entire word is captured. After that the next detection of frame signal is made.
h) Choice of frame sync signal polarity
We set 6-th bit as 0 in register 0x3FF6 so that frame sync signal is active high.
i) Data µ- law data companding
This is the process of logarithmically encoding and decoding data to minimize the number of bits that
must be sent. We set bits number 5 as 1 and bit number 4 as 0 in 0x3FF6 register.
47
48. j) Multichannel mode disables 15-th bit of 0x3FF6 register as 0.
k) Disable the transmit frame sync required and width by setting bits number 11, 10 as 0 in
register 0x3FF6.
l) Disable internal transmit frame sync by setting 7-th bit of 0x3FF6 register as 0.
{SPORT1 initialization code}
AX0=33;
DM(0x3FF4)=AX0; {frame sync divide modulus =33, frame sync signal frequency of 60kHz}
AX0=2;
DM(0x3FF5)=AX0; { SCLK clock frequency set as 2.048MHz}
AX0=0x6129; {in binary notation 0110000100101001}
DM(0x3FF6)=AX0; {internal SCLK clock, 10 – bit of word length, frame synchronization at start of
every data word, internal IRFS signal, normal framing mode, frame sync signal active high, mu – law
10-bit data compounding}
IFC=0x1E; {clears any extraneous SPORT interrupts}
INCTL=0; {interrupts nesting disabled}
AX0=0x101F; {in binary notation 0001000000011111}
DM(0x3FF)=AX0 {SPORT1 enabled, Bwait and Pwait enabled}
IMASK=0x1E; {SPORT1 interrupts are enabled)
This SPORT1 initialization we locate in main.dsp file.
F) FINAL PROGRAM
After circular buffer declaration and SPORT initialization we are able to assign data received
through SPORT to declared buffer and use it in our macro, which calculates values for PWMCHA,
PWMCHB and PWMCHC registers. It can be done simply using RX0 register of SPORT1. Despite of
the highest priority of IRQ2 interrupts which are used by PWSYNC_ISR routine, we are able to
acquire and transfer to buffer all three data words through SPORT1 until IRQ2 interrupt occurs
because of adjusted frame sync signal frequency (it was described in previous paragraph) and resultant
SPORT interrupts.
Startup:
PWM_Init(PWMSYNC_ISR, PWMTRIP_ISR);
Set_Bit_DM(MODECTRL, 6); {Sets into Double Update Mode}
IFC = 0x80; {Clears any pending IRQ2 inter.}
ay0 = 0x200; {unmask irq2 interrupts.}
ar = IMASK;
ar = ar or ay0;
IMASK = ar; {IRQ2 ints fully enabled here}
48
49. Main: {Waits for interrupt to occur}
jump Main;
rts;
AY0=RX0; {content of RX0 register is transferred to AY0}
DM(I0,M0)=AY0; {loads AY0 value to current location in “dt” global buffer, it is described by
current values of I0 and M0 registers}
rti; {goes back to main program and waist for next SPORT interrupt}
{PWM Interrupts Service Routine}
PWMSYNC_ISR:
Test_Bit_DM(SYSSTAT, 3);
if_Set_Jump(Second_Halve);
PWM_update_DutyCycles(DM(I0,M0),DM(I0+1,M0),DM(I0+2,M0));
rti;
Second_Halve:
PWM_update_DutyCycles(DM(I0,M0),DM(I0+1,M0),DM(I0+2,M0));
rti;
G) MICROPROCESSOR’S CONFIGURATION AND TESTS
Fig. XI5 Microprocessor’s tests
Tests went well. We were able to check program, connections, possibilities and finally send
our code to microprocessor.
49
50. XII. TRANSDUCER
To control the proper working of our machinery we need to check the output values as they
come. The best solution is to use some kind of transducer which will be take values and then send to
the external device, in our case to LabVIEW via NI- USB 6008 converter.
We could use a few different models of transducer, but finally we used two DEIF transducers
from Danish company.
A transducer is an electronic device that converts energy from one form to another.
Used transducers:
The TAS- 331DG is a micro- controller based AC- transducer with 1 analog output for
measurement of power or reactive power on an AC- network. This transducer can be delivered pre-
configured to the desired measuring value and range or it can be delivered un- configured for customer
configuration through the PC- interface. The PC- configuration makes free adjustment of the full input
range and output range possible without any mechanical settings or adjustments inside the transducer.
TAS- 331DG can be configured as a normal linear transducer or with up to three slopes giving the
possibility for a higher resolution in one or two ranges of the measurement.
TAS- 311DG is a micro- controller based AC- transducer with 1 analog output for
measurement of RMS- voltages, RMS- current, phase angle or frequency on an AC- network.
Because we wanted to use National Instrument device NI- USB 6008 converter we had to choose
some kind of transducers which have on the output analog voltage range.
Fig. XII1 Transducers: TAS- 311DG, TAS- 331DG
50
51. Fig. XII2 Equipment in the laboratory. MIQ96 (upper) and TAS- 331DG (lower)
Connections diagrams:
Fig. XII3 Connection diagram of TAS- 331DG
51
52. Fig. XII4 Connections diagrams of TAS- 311DG
Thanks to these two transducers we are able to measure active/reactive power from the TAS- 331DG
and RMS voltage/frequency from the TAS- 311DG. Unfortunately we could not measure all these four
parameters in the same time. It is a huge difficulty. Better solution will be using MTR-1:
Fig. XII5 MTR- 1 multi- line transducer
The MTR-1 multi transducer is a microprocessor- based measuring unit providing
measurement of all electrical values on a single phase or 3- phase network, showing the measurements
on the built- in display and transmitting these also as the 3 analog outputs. This transducer can replace
several transducers in all electrical measuring applications, and can be applied both as a normal
transducer, where the analog output is connected to a local control system, and as a remote value
52
53. reading unit, where all measured values are transmitted to the remote control via the serial interface
(RS-232).
Each of the 3 analog outputs can be programmed to represent any of the possible
measurements, and the output signal can be programmed to the required scaling and type.
Fig. XII6 Principle diagram of connecting MTR- 1
Fig. XII7 Connection of 2W4, 3- phase network, 4- wire unbalanced
Fig. XII8 Terminal overview
Efficiency is an important consideration in any transducer. Transducer efficiency is defined as
the ratio of the power output in the desired form to the total power input. Mathematically, if P
represents the total power input and Q represents the power output in the desired form, then the
efficiency E, as a ratio between 0 and 1, is given by:
53
54. E = Q/P
If E% represents the efficiency as a percentage, then:
E% = 100Q/P
No transducer is 100-percent efficient; some power is always lost in the conversion process.
Usually this loss is manifested in the form of heat. Some antennas approach 100-percent efficiency.
MTR- 1 is based on a modern digital signal processing platform, where all current and voltage
signals are digitally sampled and all measured values are calculated from the sampled signals. This
ensured a very accurate measuring system, which also measures harmonics in voltage, current and
power. MTR- 1 will measure up to 500 Hz (10th harmonic of a 50 Hz system). From 500 Hz to 2600
Hz (52nd harmonic of a 50 Hz system) MTR- 1 will measure the harmonics in the signal with slightly
reduced accuracy.
The digital measuring principle will also give a faster response compare to conventional
analog systems. All measuring signals will be updated for every period 20 ms@50 Hz.
All voltages and currents are calculated as true RMS values by the formula:
N N
2 2
u
n 1
n i
n 1
n
U RMS I RMS
N N
, where u n and in are the sampled values and N is the number of samples during one period of the
input signal
In the same way the active power P is defined as:
N
u n in
P
n 1 N
, where N is the number of samples during the latest period of the voltage input signal
Unfortunately, we could not use this kind of transducer because on the analog output we can
get only values expressed in current. It could be perfect solution (MTR-1 sends even 3 analog
parameters), but we would need something instead of NI USB- 6008 to convert data. NI can only read
voltage on the input. We have to know that this kind of equipment is only a basic solution.
Possibilities of this box are limited.
In many modern applications we get values expressed in current than in voltage. We usually
can choose the range of working from 0 to 20 or from 4 to 20. The last choice is more desirable
because when we have 0 on the screen we could not be sure if it means that it is measured zero or
maybe there is some problem with equipment which was not connected properly.
Connections diagrams:
Another better solution could be mentioned MIQ96 and serial communication, but we were not able to
use that because of the problem with cable which could not work with RS-485 protocol.
54
55. DEIF’s SOFTWARE
By using DEIF’s software we were able to program analog outputs to get proper data. Output
range was programmed from 0 to10V.
Fig. XII9 Software to get data from transducer
55
56. XIII. LabVIEW- CONTROL APPLICATION
Like www.ni.com says: “For 20 years, engineers and scientists have been using National
Instruments LabVIEW, a powerful graphical development environment, for signal acquisition,
measurement analysis, and data presentation. LabVIEW also provides the flexibility of a programming
language without the complexity of traditional development tools”. That is way we also decided to use
this wealthy tool to get to know how in the real life that such of work with LabVIEW looks like. How
exactly this tool is powerful? Trying to learn how to think in imaginatively way to present our ideas on
the screen in the form of code of LabVIEW. To bring closer to subject matter which automation in
industry is.
On the beginning we started to think, what the purposes are, what exactly our program should
do, what we want to measure, how our front panel should looks like. But the most important thing was
to start with that maybe on the beginning difficult program. We think that we managed to take steps to
our preconditions.
Lab view is combination of two integrated “files”: front panel which consist of controls and
indicators, which are the interactive input and output terminals of the VI, respectively. Controls are
knobs, push buttons, dials, and other input mechanisms. Indicators are graphs, LEDs, and other output
displays. Controls simulate instrument input mechanisms and supply data to the block diagram of the
VI. Indicators simulate instrument output mechanisms and display data the block diagram acquires or
generates. The second “file” is block diagram. After when we build the front panel, we add code using
graphical representations of functions to control the front panel objects. The block diagram contains
this graphical source code, also known as G code or block diagram code. Front panel objects appear as
terminals on the block diagram.
Fig. XIII1 Front panel and block diagram
56
57. FRONT PANEL
Fig. XIII2 Front panel
The first task was to design front panel which will be transparent and easy to work with it. We
placed Vertical Toggle Switch to stop measurement in accurate moment. Below we have three meters
which will be measure for us Voltage, Real power and Reactive power. We add also one gauge to
check frequency. Adding Numeric Indicator we can observe exact value which have significant role in
our project, because unless we obtain 50Hz, we would not work in synchronism.
57
59. To explain what the code means would not be so easy. Let is start from the block DAQ Assistant. This
block represents equipment from National Instruments NI USB-6008.
Fig. XIII4 NI USB-6008
This instrument provides basic data acquisition functionality for applications such as simple data
logging, portable measurements, and academic lab experiments. It is affordable for student use, but
powerful enough for more sophisticated measurement applications. It included ready-to-run data logger
software to begin taking basic measurements, or program it using LabVIEW or C and the included NI-
DAQmx Base measurement services software for a custom measurement system.
The most significant features:
12 or 14-bit input resolution, at up to 48kS/s
Built- in, removable connectors for easier and more cost- effective connectivity
2 true DAC analog outputs for accurate output signals
12 digital I/O lines (TTL/LVTTL/CMOS)
32- bit event counter
We used four analog inputs from mentioned equipment (ai0, ai1, ai2, ai3). Where, in all of them
we measure voltage. It could be puzzling how we could measure e.g. power in Volts. The answer is easy;
our pre-equipment (transducer from Danish company- DEIF) measures values in real units and converts
into Volts. The range is changed as well. Analog inputs of NI USB- 6008 have own durability (20V). We
could not increase this level, because we can burn out converter. Fortunately LabVIEW has built-in
transfer function, so even if we take Volts we can observe all measurement in real values and units.
59
60. Fig. XIII5 Converting data from Volts into Watts in appropriate scale
Next blocks which were used after DAQ assistant blocks were Collector and Statistics. Task of
Collector is to collect input signals and returns the most recent data, up to the specified maximum number
of samples per channel. When we call this Express VI repeatedly and the Express VI reaches the
maximum number of samples per channel, the Express VI discards the oldest data and adds the newest
data to the collected samples. For example if we established to collect thousand samples in means that the
next block will calculate arithmetic mean from this thousand values and give the final result. This method
can protect against spikes or unstable values.
Fig. XIII6 Collector and Statistics blocks
Thanks to block Write LabVIEW Measurement File Express VI we can store the data acquired
from DAQ device, but this data after mathematical processing. It can help us to check how the values
were changing during the measurement.
Fig. XIII7 Write to measurement file block
60
61. When is the problem with acquiring data from DAQ device or the Vertical Toggle Switch was
switched, the structure below will stop everything, protecting against having incomplete data if one or
two devices do not work properly or simply if we want to interrupt our measurement.
Fig. XIII8 Unbundle by name, compound arithmetic- or, loop condition- stop.
Another structure which was used in our block diagram is compare structure. It is really helpful if
we want to decide what the program should do when the measured value is higher or lower than the
desirable value.
Fig. XIII9 Compare structure with Case Structure. Analog solution
Our second idea was to use DAQ assistant which will be sending value to the analog output
depending on the ending conditions. If the output voltage would be lower than 400V DAQ assistant
would take value from the ground 0V output and send this value on the analog output 1, while if the value
was higher, device would send 5V from the stable output to analog output 2 and additionally would send
some beep noise to warn against to high value. Unfortunately this kind of solution is not right because to
control machine we need smooth range from 0 to 5V, not only this to extreme values. Using NI USB-
6008 we are not able to be up to this.
Fig. XIII10Linking inputs with outputs to solve the problem
61
62. If we are not able to send analog values we decided to send digital values, but this time not to use NI-
USB 6008 converter, because it has only 12- bits digital output.
Our new idea was to use NI- USB only to observe behavior of the machine and use
microcontroller’s D/A converter to send hexadecimal values which will be changing the duty cycle in
PWM signal.
We came back to our first idea with using RS-232 protocol and serial interface to exchange data
between computer and microcontroller. In datasheets is written:
Solution is showed in the pictures below:
Fig. XIII11 Compare structure with Case Structure. Way to increase the duty cycle. Digital solution
Fig. XIII12 Compare structure with Case Structure. Way to decrease the duty cycle. Digital
62
63. Idea is easy. We use serial port to exchange information. Depending if the value is lower or
higher than 400V Case Structure will execute appropriate step:
a) VISA Configure Serial Port initializes the serial port specified by VISA resource name to the
specified settings.
b) VISA Read reads the specified number of bytes from the interface specified by VISA resource
name and returns the data in read buffer.
c) Hexadecimal String to Number Interprets the characters 0 through 9, A through F, and a through f
in string starting at offset as a hex integer and returns it in number.
d) Depending if we increase or decrease duty cycle appropriate mathematical calculation is
executed. 32 is hexadecimal value is our step, everything depends how fast we want to increase or
decrease the speed of the machine to obtain synchronism.
e) U32 converts a number to a 32-bit unsigned integer in the range 0 to 232–1
f) In Range and Coerce block determines whether a 32-bit unsigned integer falls within a range
specified by the upper limit and lower limit inputs (0000, 7FFF). In every applications
programmer have to predict and guarantee correctness of work.
g) Number to Hexadecimal String converts number to a string hexadecimal digits
h) VISA Write writes the data from write buffer to the interface specified by VISA resource name.
i) VISA Close block closes a device session specified bye VISA resource name. That block let to
use this port by the other applications when it is not used.
Now, in this way we are able to work in smooth range 0- 5V (0000 determines 0V, 7FFF determines 5V)
with using digital values and microcontroller’s C/A converter.
Our idea was shown by comparing output voltage, but we can use powers or frequency as well. We have
a few possibilities.
To the final block diagram (program) we can add some waveform graphs to observe relationships
between values in specific situation.
63
64. XIV. SUMMARY
First of all we want to thank all professors for enable for us to use all laboratories’ tools, devices,
kits, integrated circuits and components.
Our final report of the project contains in majority practical solution of commissioned task.
Unfortunately, when we solved all particular parts of the integrity, we could not test the system entirely.
Although we suppose that everything should work properly, because each block was tested in detail.
In our opinion we used all available stuff exhaustively.
We learned a lot during this semester and especially during the project course. It improved our
practical skills. We must admit that it was the first time that we could to set ourselves against the
problem, which is used in real life. It helped for us to be more creative to be the real engineers.
64