1
00:00:00,000 --> 00:00:03,629
hello everyone my name is Antone and i
will present today how to control the

2
00:00:03,629 --> 00:00:09,599
three face brushless motor using similar
ink and a TI launch pad with a three

3
00:00:09,599 --> 00:00:16,410
phase inverter booster back here is the
hardware i have my ti launch pad here

4
00:00:16,410 --> 00:00:22,740
with the booster pack on top im using
the boost excel dash drv 8301 booster

5
00:00:22,740 --> 00:00:29,759
pack which is a three phase inverter you
can see the six mosfets here and i have

6
00:00:29,760 --> 00:00:34,710
my three phase connector here which is
connected to my motor you can also

7
00:00:34,710 --> 00:00:40,79
notice here this is my position sensor
cable and it's not connected today

8
00:00:40,79 --> 00:00:44,129
because I will demonstrate how to do
field oriented control with sensorless

9
00:00:44,129 --> 00:00:48,120
let me start with the end and then i
will show how I got there

10
00:00:48,120 --> 00:00:52,260
this is my simulink model that will
generate code from it by pressing this

11
00:00:52,260 --> 00:00:57,930
button or pressing ctrl be on my
keyboard you can follow the cogeneration

12
00:00:57,930 --> 00:01:03,329
steps on the main map window notice on
the side i have these variables that

13
00:01:03,329 --> 00:01:07,920
have been automatically created when I
opened my model i can set my cpu

14
00:01:07,920 --> 00:01:13,740
frequency and I can also set my PWM
frequency i'm using a PWM frequency of

15
00:01:13,740 --> 00:01:19,259
20 kilohertz today this is also the
frequency at which i'm going to run my

16
00:01:19,259 --> 00:01:24,450
current loop so i'm running a new
current loop and refreshing my pwm duty

17
00:01:24,450 --> 00:01:30,960
cycles every 50 microseconds or 20
kilohertz i have an automated script

18
00:01:30,960 --> 00:01:36,600
that will load the generated executable
on my targets so I just connected to my

19
00:01:36,600 --> 00:01:42,000
target loaded the code and if i go back
to my camera I can see now my shaft is

20
00:01:42,000 --> 00:01:52,590
spinning now that my motor spinning i
can open this host model that will read

21
00:01:52,590 --> 00:01:57,600
cereal messages coming from the USB
cable connected to the launch pad so

22
00:01:57,600 --> 00:02:01,770
here i have three messages coming over
the serial port i have the desired speed

23
00:02:01,770 --> 00:02:07,229
the actual speed and torque demand so if
I around this model on the host it will

24
00:02:07,229 --> 00:02:12,790
get the serial messages and I can see in
real time what's happening on my target

25
00:02:12,790 --> 00:02:19,30
using similar scopes this is my desired
speed its per unit speed of 4.5 and this

26
00:02:19,30 --> 00:02:23,290
is the actual measured speed and this is
my torque demand coming out of the speed

27
00:02:23,290 --> 00:02:28,870
control PID controller so if i try to
slow down my shaft you can see that the

28
00:02:28,870 --> 00:02:32,739
actual speed is slowing down and I need
torque to maintain the speed if I

29
00:02:32,739 --> 00:02:38,319
release the shaft then there's a spike
of speed because it's catching up with

30
00:02:38,319 --> 00:02:42,879
the with the amount of torque that that
was needed to maintain the speed before

31
00:02:42,879 --> 00:02:48,159
I can do that test again if i try to
slow down my shaft I can see the Tour de

32
00:02:48,159 --> 00:02:53,560
man climbing up as soon as I release the
shaft the amount of torque that built up

33
00:02:53,560 --> 00:02:56,769
created a spike positive speed

34
00:02:56,769 --> 00:03:00,159
how did I get there so first of all
let's go through a few installation

35
00:03:00,159 --> 00:03:05,769
steps so i'm using matlab are 2013b
everything i'm doing here can be done

36
00:03:05,769 --> 00:03:10,810
also with 13a i wouldn't recommend going
to an earlier version of 13a because we

37
00:03:10,810 --> 00:03:16,780
made a lot of improvements for the
people f-22 to 1713 a 430 is recommended

38
00:03:16,780 --> 00:03:22,449
version in 13b our support for tis e2000
processor is coming now

39
00:03:22,449 --> 00:03:26,769
yeah a support package that you have to
download from the web so you have to

40
00:03:26,769 --> 00:03:33,729
type this target installer command that
will help you through that process type

41
00:03:33,729 --> 00:03:38,620
this command it will open a GUI install
the Support Package 40 i see two

42
00:03:38,620 --> 00:03:44,49
thousand processors and follow the steps
to link also the third party files that

43
00:03:44,49 --> 00:03:48,669
you need ccsb five or before or even be
three if that's what you prefer

44
00:03:49,329 --> 00:03:53,79
once this is done you can also run the
check

45
00:03:53,769 --> 00:04:00,400
env set up Jackie and setup will help
you validate your installation against

46
00:04:00,400 --> 00:04:09,489
the third party tools use check and be
setup CCS that's for ccs version 3.3 if

47
00:04:09,489 --> 00:04:16,930
you want to use the five type CCS v5
then f 22 27 check make sure all these

48
00:04:16,930 --> 00:04:21,10
items are pointing to the recommended
versions

49
00:04:21,10 --> 00:04:26,80
of the third body files there's another
command that you can run also which is

50
00:04:26,80 --> 00:04:32,50
target updater this will make sure that
you have the latest version of the

51
00:04:32,50 --> 00:04:38,530
support package and you can also use
tools to validate that your third-party

52
00:04:38,530 --> 00:04:44,289
files are configured correctly the paths
are correct and similarly knows where to

53
00:04:44,290 --> 00:04:50,140
find the third party tools so three
commenced to remember targets installer

54
00:04:50,140 --> 00:04:58,599
target the later check env set up the
model I'm using today has been posted on

55
00:04:58,600 --> 00:05:06,10
mass of central so you can find it by
typing massive central.com and if you

56
00:05:06,10 --> 00:05:11,349
look at the file exchange and if you
type motor control with ti launch bad

57
00:05:11,350 --> 00:05:18,490
you will find this motor control model
so download this model it comes with the

58
00:05:18,490 --> 00:05:23,680
installation script or an init script
that will initialize my variables each

59
00:05:23,680 --> 00:05:27,970
time i open the model so make sure you
put all these files in the same folder

60
00:05:27,970 --> 00:05:33,550
and make this folder your present
working directory in matlab so this will

61
00:05:33,550 --> 00:05:37,360
guarantee you have access to all the
files there are two models provided

62
00:05:37,360 --> 00:05:43,930
actually there are three models provided
14 CCSD 5 which is the ERT version 14

63
00:05:43,930 --> 00:05:52,210
ccsb three and a host model that allows
me to read serial data in real-time now

64
00:05:52,210 --> 00:05:57,310
let's look what's inside one of these
models i'm going to open sea 28 to 27

65
00:05:57,310 --> 00:06:05,110
p.m. SFO see on the score ERT why on the
score ERT because in my configset i am

66
00:06:05,110 --> 00:06:12,220
using ertiga TLC as my system target
file for the older CCS version 3.3 we

67
00:06:12,220 --> 00:06:19,780
are using IE link brt which stands on
the ID link automation that we have with

68
00:06:19,780 --> 00:06:27,280
CCS version 3.3 in 13b you can use the
generic ERT TLC you can see that you can

69
00:06:27,280 --> 00:06:31,138
select your target hardware directly on
the cogeneration pain

70
00:06:31,139 --> 00:06:37,830
so this is new and 30b and you can
select your TI processor here and also

71
00:06:37,830 --> 00:06:44,248
your tool chain and that goes through a
makefile approach and we also have an

72
00:06:44,249 --> 00:06:49,139
automatic download that you can select
here on the corner target pain so let's

73
00:06:49,139 --> 00:06:50,520
look inside this model

74
00:06:50,520 --> 00:06:55,169
let's start with scheduling so for this
model i have enabled sample time colors

75
00:06:55,169 --> 00:06:59,938
this is something you can do under
display sometime colors and if i press

76
00:06:59,939 --> 00:07:05,669
this control ji get this legend which
tells me every discreet an asynchronous

77
00:07:05,669 --> 00:07:11,490
time that I have in this model i have to
its discreet x 110 million another one

78
00:07:11,490 --> 00:07:16,319
at $TIME hundred milliseconds and i have
one asynchronous time the asynchronous

79
00:07:16,319 --> 00:07:23,610
time is this interrupt trigger here that
is represented with this purple color so

80
00:07:23,610 --> 00:07:27,839
this is my current loop this interrupt
is coming from the ADC so at the end of

81
00:07:27,839 --> 00:07:31,650
an ADC conversion i'm going to get an
interrupt and this will trigger my

82
00:07:31,650 --> 00:07:36,60
current loop so this will guarantee you
will start the algorithm as soon as I

83
00:07:36,60 --> 00:07:42,300
have fresh values coming from my
analog-to-digital converter at 10

84
00:07:42,300 --> 00:07:46,949
milliseconds i will have my speed
control group so i have one PID that

85
00:07:46,949 --> 00:07:51,750
reads the desired speed and the actual
speed and the output of that PID is

86
00:07:51,750 --> 00:07:56,909
going to be my torque demand and that
will feed the desired torque for the

87
00:07:56,909 --> 00:08:02,188
field oriented control algorithm i have
another discreet sample time which is

88
00:08:02,189 --> 00:08:07,379
hundred Millie and that i'm using to
send cereal messages to that hosts model

89
00:08:07,379 --> 00:08:11,729
i showed in the beginning of this
example so now let's look at side the

90
00:08:11,729 --> 00:08:16,710
FOC algorithm subsystem so first of all
you can notice the thick boundaries of

91
00:08:16,710 --> 00:08:21,000
this system this is typical to atomic
subsystem and the difference with a

92
00:08:21,000 --> 00:08:25,620
regular subsystem is the fact that in
the generated code the boundaries have a

93
00:08:25,620 --> 00:08:30,60
meaning you can define that meaning by
right-clicking on the subsystem and go

94
00:08:30,60 --> 00:08:35,640
to block parameters and assigned to
specific subsystem to a function or a

95
00:08:35,640 --> 00:08:39,120
separate see file given name to the
function set that you

96
00:08:39,120 --> 00:08:43,679
the function to be reusable and not
reusable in which case it may take

97
00:08:43,679 --> 00:08:48,870
adventure to stack or global variables
and one thing which is important here is

98
00:08:48,870 --> 00:08:54,810
the fact that i can also define the
memory section for this subsystem in

99
00:08:54,810 --> 00:08:59,790
this case this is my currently I want
this to execute the fastest as possible

100
00:08:59,790 --> 00:09:05,790
so i'm putting this subsystem in code
round funks this section has been

101
00:09:05,790 --> 00:09:11,910
defined in a package where we specify
that it needs to be loaded in flash but

102
00:09:11,910 --> 00:09:16,439
run from Run so this is what this
section will do it will reside in flash

103
00:09:16,440 --> 00:09:22,410
for standalone execution but it will run
from round for faster execution and at

104
00:09:22,410 --> 00:09:26,490
any time we're going to copy the code
from flashed around to make sure that it

105
00:09:26,490 --> 00:09:32,130
can execute from around the same can be
done at the model level in the config

106
00:09:32,130 --> 00:09:43,200
sent i can go to code generation memory
section and if i select this ti c2000

107
00:09:43,200 --> 00:09:47,940
demos package you can access it by
clicking this refresh package button

108
00:09:47,940 --> 00:09:53,640
then you will see this tis demos package
this has the definitions for a few

109
00:09:53,640 --> 00:09:57,449
sections that we have defined like this
code round front section that I

110
00:09:57,450 --> 00:10:02,370
described earlier you can select
execution this will apply at the model

111
00:10:02,370 --> 00:10:07,350
level and it will try to find all the
functions that are being executed at

112
00:10:07,350 --> 00:10:15,360
every time step and you can place them
in the code ramp on section so let's

113
00:10:15,360 --> 00:10:20,940
look inside the FOC algorithm subsystem
so it is triggered on an ADC and dropped

114
00:10:20,940 --> 00:10:30,120
and it starts with to ADC readings abcb1
and ADCB 3 East correspond to ia and IB

115
00:10:30,120 --> 00:10:35,940
measurements on the hardware the second
one which is b3 will trigger the

116
00:10:35,940 --> 00:10:43,950
interrupt so it's using SOC 1y the first
one is using SOC 0 so this will happen

117
00:10:43,950 --> 00:10:49,649
after SOC 0 so this is the last one to
convert at the end of the converter

118
00:10:49,649 --> 00:10:55,800
I want to post my interrupt and i'm
using a DC and one so now an important

119
00:10:55,800 --> 00:11:01,889
thing to notice is the fact that we want
to trigger the ADC based on a pwm event

120
00:11:01,889 --> 00:11:07,980
this will guarantee that we launched the
conversion outside pwm transition this

121
00:11:07,980 --> 00:11:15,449
can be done using the pwm blog on this
block we have an event trigger tab on

122
00:11:15,449 --> 00:11:21,929
the event trigger i enable ABC start of
conversion for modulating based on a .

123
00:11:21,929 --> 00:11:27,629
event which means that when the counter
reaches the . i will start by a DC

124
00:11:27,629 --> 00:11:33,449
conversion in the general tab i have
sent my counter to be up and down so

125
00:11:33,449 --> 00:11:38,459
it's a symmetric moving up moving down
counter if i launched my ADC conversion

126
00:11:38,459 --> 00:11:43,859
in the middle is very less likely to
launch the conversion when there will be

127
00:11:43,860 --> 00:11:50,69
a pwm transition so I'm going to repeat
this workflow pwm has a counter that's

128
00:11:50,69 --> 00:11:56,759
counting up and down when it reaches the
. it launches the ADC conversion ADC

129
00:11:56,759 --> 00:12:02,129
converts ini be at the end of conversion
i will trigger an interrupt

130
00:12:02,920 --> 00:12:08,290
now i need to react on this interrupt so
using that interrupt block i can select

131
00:12:08,290 --> 00:12:14,529
cpu interrupt one pcie one so you have
to read it vertically this is a matrix

132
00:12:14,529 --> 00:12:27,519
that you can access in the help so you
can view the sec 1 so this is sequence

133
00:12:27,519 --> 00:12:38,889
or 14 the ADC which comes under cpu1 p
IE 1 so here you can read pa1 cp1 this

134
00:12:38,889 --> 00:12:45,940
is why I selected cp1 p iu 107 entice
priority is said 230 you have to

135
00:12:45,940 --> 00:12:50,79
remember that any synchronous task which
is executed

136
00:12:50,79 --> 00:12:56,79
yeah a similar example time will execute
at a priority of 40 so 30 means the

137
00:12:56,79 --> 00:13:00,699
priority of this interrupt is higher
than the main simulink scheduler

138
00:13:00,699 --> 00:13:06,130
apprehension flag is set to one which
means that a higher priority i don't

139
00:13:06,130 --> 00:13:11,709
have any in this model but let's imagine
i had a higher priority it would be able

140
00:13:11,709 --> 00:13:19,810
to preempt this particular interrupt so
you can notice that this line is dotted

141
00:13:19,810 --> 00:13:24,640
and the reason for this is because it's
not data flow going through this line

142
00:13:24,640 --> 00:13:31,510
it's an event so this Hardware interrupt
is going to trigger this subsystem you

143
00:13:31,510 --> 00:13:36,250
can also notice the presence of this
gpio block the goal of this block is to

144
00:13:36,250 --> 00:13:43,540
enable the DRV 8301 chip and it's using
gpio six so i need to set this to one

145
00:13:43,540 --> 00:13:47,19
otherwise my inverter is completely shut
down

146
00:13:47,19 --> 00:13:52,269
so let's look inside the store control
algorithm have two major subsystem the

147
00:13:52,269 --> 00:13:57,220
first one is input skating this will
scale my ia and I be inputs into per

148
00:13:57,220 --> 00:14:01,810
unit value one block that's important to
know this is that minus one on the

149
00:14:01,810 --> 00:14:08,589
hardware it's using an inverted often so
to feed my main algorithm i need to do

150
00:14:08,589 --> 00:14:12,329
that- one to go back into a positive
value for positive

151
00:14:12,329 --> 00:14:18,929
current on the second subsystem i
generate myspace vectors and that is the

152
00:14:18,929 --> 00:14:24,600
typical field oriented control algorithm
using the park park here i have my PID

153
00:14:24,600 --> 00:14:30,569
controllers for ID and IQ IQ is
proportional to torque so it's coming

154
00:14:30,569 --> 00:14:35,998
from my speed controller and then i feed
my inverse park space vector generator

155
00:14:35,999 --> 00:14:41,699
and this will feed the duty cycles of
the pwm one thing good to notice here is

156
00:14:41,699 --> 00:14:48,689
that sliding mode observer so this will
define my position so this allows sensor

157
00:14:48,689 --> 00:14:55,170
less field oriented control so it's
using the alpha v beta alpha by beta and

158
00:14:55,170 --> 00:15:00,179
this gets out a theta which is a
position signal from 0 to 1 it will be

159
00:15:00,179 --> 00:15:05,369
associated if we're moving at a constant
speed and it's also outputting a speed

160
00:15:05,369 --> 00:15:10,529
signal we can look inside the sm 0
subsystem and you can see that it's a

161
00:15:10,529 --> 00:15:15,720
complicated subsystem you can take it
out and tested in a unit test feed some

162
00:15:15,720 --> 00:15:22,169
stimulus signals and and watch the
output of this subsystem going back to

163
00:15:22,169 --> 00:15:26,429
the root of the model i will show now
the speed controller is a pretty simple

164
00:15:26,429 --> 00:15:31,649
system there's just a PID controller
that takes a desired speed in this

165
00:15:31,649 --> 00:15:37,259
example is just a constant and feedback
will be the measured speed and the

166
00:15:37,259 --> 00:15:42,179
output will be the desired torque so the
PID will work on the Delta between the

167
00:15:42,179 --> 00:15:47,279
desired and the actual speed and we'll
build up some desire toric depending on

168
00:15:47,279 --> 00:15:53,9
the air measured this subsystem also
contains a serial monitor subsystem i'm

169
00:15:53,9 --> 00:15:57,779
going to be sending signals at 100
millisecond and i'm sending the speed

170
00:15:57,779 --> 00:16:01,949
desire d actual speed and the torque
command basically the two inputs and the

171
00:16:01,949 --> 00:16:07,949
output of the PID controller i'm going
to send the three variables every

172
00:16:07,949 --> 00:16:10,258
hundred millisecond

173
00:16:10,259 --> 00:16:15,569
now you're ready to generate code for
this model the other model provided is

174
00:16:15,569 --> 00:16:22,738
the exact same model for ccs version 3.3
it's using the ID link automation so if

175
00:16:22,739 --> 00:16:28,410
i open the config set i will see that it
is using ID and link on the score ERT

176
00:16:28,410 --> 00:16:36,988
TLC for the system target file if you
want to learn more

177
00:16:37,589 --> 00:16:42,449
you have access to a list of examples if
you open the simulink library browser

178
00:16:42,449 --> 00:16:47,998
under embedded code or support package
for TI c2000 processor you can click on

179
00:16:47,999 --> 00:16:53,579
this blue example blog and it will point
you to the list of examples provided for

180
00:16:53,579 --> 00:16:59,248
this support package i recommend going
through the simulation of FOC using pmsf

181
00:16:59,249 --> 00:17:05,789
model this example shows how to test
your algorithm using a plant model of

182
00:17:05,789 --> 00:17:10,109
the motor so you can work purely in
simulation before you go to the embedded

183
00:17:10,109 --> 00:17:10,979
hardware

184
00:17:10,980 --> 00:17:16,230
this requires some power system so you
can use motor simulation i also

185
00:17:16,230 --> 00:17:20,459
recommend going through the steps
provided in the motor control example

186
00:17:20,459 --> 00:17:27,600
this is a step-by-step example on how to
create the full algorithm and how to

187
00:17:27,599 --> 00:17:33,809
test components one-by-one also
recommend going through this example

188
00:17:33,809 --> 00:17:39,000
which provides pretty much the same as
what i described today on different

189
00:17:39,000 --> 00:17:45,450
types of hardware you can use the easy
ESP from TI with the DM 550 we also have

190
00:17:45,450 --> 00:17:53,669
demos using the DRV 8312 kids with
piccolo f28 or 35 + / 69 we have support

191
00:17:53,669 --> 00:17:58,679
for 28 33 528 Wade 2012

192
00:17:58,679 --> 00:18:03,450
thanks for watching I hope you will be
successful running your simulation

193
00:18:03,450 --> 00:18:06,510
models and algorithms on the TI
launchpad

194
00:18:06,510 --> 00:18:06,899
good luck


