1
00:00:00,480 --> 00:00:07,320
Welcome back and listen, we are going to see how to use the free ARTUS middleware widow estimated to

2
00:00:07,320 --> 00:00:16,260
keep a mix going to create a new project from Yeah for you project again, the microcontroller doesn't

3
00:00:16,260 --> 00:00:16,660
matter.

4
00:00:16,680 --> 00:00:19,500
It should work the same way on steam 32 boards.

5
00:00:19,920 --> 00:00:21,510
I'm going to select my board here.

6
00:00:21,510 --> 00:00:23,640
ASTM 32 for one one.

7
00:00:28,950 --> 00:00:31,860
And for this experiment, I'm going to select the nuclear board.

8
00:00:38,550 --> 00:00:45,300
I've seen no over here, and then I'll play all spin out play piano over here like this.

9
00:00:45,810 --> 00:00:46,440
Say yes.

10
00:00:49,580 --> 00:00:55,340
We're going to start off by enabling the LSD and the push-Button for our experiment.

11
00:00:55,750 --> 00:01:02,180
Go to be a five sided to GPL, your output and P.S. 13 GPA you input like this.

12
00:01:06,850 --> 00:01:14,080
So to enable free ARTUS, we come to a middle way over here and then we select free artists and then

13
00:01:14,860 --> 00:01:16,700
we can select the interface here.

14
00:01:16,750 --> 00:01:20,110
What are we using, Simms's, if you want to feed you.

15
00:01:20,890 --> 00:01:24,190
So I'll just select assumes Simpsons for you one over here.

16
00:01:25,560 --> 00:01:28,610
And then it's a neighborhood, right?

17
00:01:29,040 --> 00:01:33,180
Oh, so what I'm going to do is I'm going to a neighborhood that you are so that we can use that in

18
00:01:33,180 --> 00:01:34,450
our experiment as well.

19
00:01:34,470 --> 00:01:42,120
I'll come to connectivity, you know, enable my you to hear I started to asynchronous mode like this.

20
00:01:45,180 --> 00:01:45,540
OK.

21
00:01:45,570 --> 00:01:52,800
Next week we come to a system called system, and then we're going to change the time base over here,

22
00:01:52,800 --> 00:01:54,380
says the time biz assistant.

23
00:01:54,390 --> 00:01:56,700
We're going to change it to a different time.

24
00:01:57,540 --> 00:02:01,560
You can select you can nominate two or three l just like three over here.

25
00:02:06,750 --> 00:02:10,860
And debug, of course, you can leave it or you can just like this here, a wi fi.

26
00:02:14,940 --> 00:02:21,990
So we can go ahead and configure our view of free artist and then we can see how to add things like

27
00:02:21,990 --> 00:02:24,370
tasks and the other artists component.

28
00:02:25,500 --> 00:02:31,830
So I just opened this again and then I'll bring this up like this.

29
00:02:33,730 --> 00:02:41,140
So these are the configuration of the of the kennel, we can we can still change this in the in the

30
00:02:41,140 --> 00:02:44,050
generated code like we see for other drivers.

31
00:02:44,050 --> 00:02:48,910
When you generate the code from here and you go to your development environment, you still have the

32
00:02:48,910 --> 00:02:51,050
option to be able to change it manually.

33
00:02:51,520 --> 00:02:55,360
We can do the, um, this is tasks we can all tasks.

34
00:02:55,810 --> 00:03:02,980
It says over here there's a difficult task task before task and you give the priority of the task always

35
00:03:02,980 --> 00:03:04,090
priority normal.

36
00:03:04,570 --> 00:03:12,190
And then over here that there is the the entry function starts Difford task, et cetera.

37
00:03:12,190 --> 00:03:14,980
We're going to add a task over here.

38
00:03:15,670 --> 00:03:17,380
I'm just going to call this thread one.

39
00:03:17,380 --> 00:03:20,560
Remember, thread and tasks are used interchangeably.

40
00:03:22,180 --> 00:03:28,180
If you want a definition that a threat is a task in execution, when a task starts to execute and we

41
00:03:28,180 --> 00:03:35,440
call it a threat so we can use the two words interchangeable so we can live the parameters here the

42
00:03:35,440 --> 00:03:39,460
same way, um, entry function we can just call it.

43
00:03:42,800 --> 00:03:45,590
I call this thread one funk for function.

44
00:03:46,590 --> 00:03:47,250
OK, the.

45
00:03:47,930 --> 00:03:55,230
We can leave it then I got another one, call this thread, too, but you can give them any names you

46
00:03:55,230 --> 00:04:01,500
want to make a bit more descriptive and then entry function through it to function.

47
00:04:03,990 --> 00:04:12,710
And then I say, OK, like this next we going to the mutex and mutex means mutual exclusive.

48
00:04:12,720 --> 00:04:21,030
And what this allows is, is that it allows us to use a shared resource effectively, not even efficiently,

49
00:04:21,030 --> 00:04:21,970
but effectively.

50
00:04:22,350 --> 00:04:29,820
And the reason that is important is if we have two threads trying to write out a you art at the same

51
00:04:29,820 --> 00:04:30,170
time.

52
00:04:30,780 --> 00:04:35,490
Yeah, there you are to the hardware driver, which is that you are two, which is the shared resource

53
00:04:35,490 --> 00:04:39,020
might crush is the same thing with an LCD screen.

54
00:04:39,030 --> 00:04:44,880
If you have two threads and they're all trying to access this single resource at the same time, you

55
00:04:44,880 --> 00:04:45,960
could cause a crash.

56
00:04:46,740 --> 00:04:54,360
What we have to do in this case is to provide a mutex such as such, that one thread would access it

57
00:04:54,360 --> 00:04:57,210
and then when it's done, the other one would access it as well.

58
00:04:58,140 --> 00:04:59,640
So we going to use that here.

59
00:04:59,640 --> 00:05:01,740
Click mutex click out of here.

60
00:05:02,250 --> 00:05:03,990
Our shared resource in this example.

61
00:05:03,990 --> 00:05:07,260
This is is the is the you are.

62
00:05:07,300 --> 00:05:12,300
So we can give it, um, our mutex and name you at mutex.

63
00:05:12,300 --> 00:05:17,580
If we had LCD, we can give it the similar name so I'll click okay.

64
00:05:17,580 --> 00:05:18,280
Here like this.

65
00:05:19,470 --> 00:05:24,620
Okay, so once this is done we can go ahead and generate a good outcome to project management over here.

66
00:05:24,630 --> 00:05:25,980
I'll try to change them.

67
00:05:25,980 --> 00:05:27,180
32 covid.

68
00:05:27,930 --> 00:05:28,740
I'll call this.

69
00:05:31,560 --> 00:05:32,460
Free Artus.

70
00:05:42,950 --> 00:05:44,530
I want to give it a descriptive name.

71
00:05:48,900 --> 00:05:51,780
Tasks and mutex by the.

72
00:05:54,810 --> 00:06:00,450
And we can live to the size and the stock size, the same should be enough when I click here to generate.

73
00:06:03,610 --> 00:06:04,930
So this is our project.

74
00:06:07,570 --> 00:06:08,840
I'm going to clean up a bit.

75
00:06:08,860 --> 00:06:11,070
I'm going to reduce the number of comment here.

76
00:06:12,550 --> 00:06:17,410
So this whole project with the M the number of comments reduced, OK, that's what we have.

77
00:06:17,920 --> 00:06:21,790
We have the the threat ID, the threats we created.

78
00:06:22,210 --> 00:06:24,040
Each one was given an ID.

79
00:06:24,160 --> 00:06:26,830
So this is the right one.

80
00:06:27,190 --> 00:06:33,610
Hondo and it's off type threat id threat to handle this also type threat ID as well as our mutex that

81
00:06:33,610 --> 00:06:37,840
you are to mutex Holmdel then this is the default threat that we saw in Cuba.

82
00:06:37,840 --> 00:06:38,230
Imex.

83
00:06:38,920 --> 00:06:41,800
So a threat is basically a main function.

84
00:06:41,920 --> 00:06:46,840
And what I mean by main function is a function with an infinite loop, a function that doesn't return

85
00:06:46,840 --> 00:06:48,850
a function with a one loop.

86
00:06:49,510 --> 00:06:55,620
So if we go to the threat functions, we'll see that the functions with infinite loops.

87
00:06:55,960 --> 00:06:56,980
So this is our threat.

88
00:06:56,980 --> 00:07:00,760
One func that we created in Cuba makes you can see this is an infinite loop.

89
00:07:01,120 --> 00:07:05,590
This is another way of writing vol one and then it has a delay of one here.

90
00:07:05,590 --> 00:07:07,210
This is the code generated by Cuba.

91
00:07:07,220 --> 00:07:09,550
Makes this is this the same thing for threat two?

92
00:07:10,150 --> 00:07:16,690
And this is the one for the start, the fourth threat, the default threat or tasks that we saw.

93
00:07:17,170 --> 00:07:24,340
OK, and over here, often if you generate code with Cuba, mix without using the free Arktos or without

94
00:07:24,340 --> 00:07:27,220
changing in time base since this is the time base.

95
00:07:27,580 --> 00:07:31,630
But because we change our time based on time, a three time, a three snowless time base.

96
00:07:31,780 --> 00:07:39,580
And the reason that is, is that the always canno of re artosis use insisting the real time operating

97
00:07:39,580 --> 00:07:42,290
system needs a time or two to work as well.

98
00:07:42,880 --> 00:07:49,990
So we've we are using system for that and we need another time out for our normal hardware initialization,

99
00:07:50,050 --> 00:07:58,720
et cetera, some hardware parts or some hardware modules such as The Spy and I to see during initialization.

100
00:07:58,720 --> 00:08:00,580
You need to apply delay every now and then.

101
00:08:00,580 --> 00:08:03,850
We need something to generate such delays for us.

102
00:08:04,420 --> 00:08:06,940
And over here we use in timer three to do that.

103
00:08:07,270 --> 00:08:11,540
And this whole electic is the heartbeat of this other time.

104
00:08:11,980 --> 00:08:17,620
So this is how our delay, if we call it all delay, is going to be used in this.

105
00:08:17,770 --> 00:08:21,130
This is will be generating the delay using this whole Intec.

106
00:08:21,370 --> 00:08:26,920
But before that it was done using the system timer knows is done using time of three.

107
00:08:26,920 --> 00:08:33,100
And this is because this is the time that's been used by our free operators operating system.

108
00:08:34,030 --> 00:08:34,450
Right.

109
00:08:34,460 --> 00:08:36,310
So we have our task functions.

110
00:08:36,790 --> 00:08:39,040
Three of them we saw in Cuba mix.

111
00:08:39,040 --> 00:08:42,420
There was a default Tasco threat created and we added two more.

112
00:08:43,270 --> 00:08:52,930
So one way to see if a while when you're working with ARTUS, one thing you have to do is profile the

113
00:08:52,930 --> 00:08:55,840
task in some in some ideas.

114
00:08:55,840 --> 00:08:58,000
There is a way to know if a task is running or not.

115
00:08:58,090 --> 00:09:06,910
If if you don't have any of such ideas or if the it doesn't provide that we can find a way of profiling

116
00:09:06,910 --> 00:09:09,530
and we can profile simply using a counter variable.

117
00:09:10,420 --> 00:09:16,540
So what I'm going to do is create a typedef typedef OSSE task profile.

118
00:09:18,980 --> 00:09:27,110
And this is simply you to underscore what type of Darcis typedef allows me to use this new name in place

119
00:09:27,110 --> 00:09:31,880
of you intended to underscore this whenever I want to type you intended to underscore to you I can simply

120
00:09:31,880 --> 00:09:32,420
type this.

121
00:09:32,760 --> 00:09:41,360
So then I'm going to declare three you in 30 to underscore Ts or callers thread one.

122
00:09:43,200 --> 00:09:53,110
I'll see through it one profiler, and then I'll have to read to profiler.

123
00:09:53,340 --> 00:09:58,490
And these are just controvert was just I'm giving them fancy names and then we'll have Difford through

124
00:09:58,500 --> 00:09:58,730
it.

125
00:10:05,840 --> 00:10:10,490
Before threat profiler and what were you going to do is we going to drop these counter variables in

126
00:10:10,490 --> 00:10:15,860
each of the threats or tasks so that when we execute, we want to see all of them increment.

127
00:10:15,860 --> 00:10:21,890
If all of them are incremental and they're almost the same value, this would tell us that our realtime

128
00:10:21,890 --> 00:10:26,000
operating system is run and also it is running in a Round-Robin fashion.

129
00:10:26,930 --> 00:10:29,470
Um, this is not the red one.

130
00:10:29,540 --> 00:10:30,500
This is the red one.

131
00:10:32,990 --> 00:10:34,460
This is the red one of.

132
00:10:34,550 --> 00:10:37,430
Is this over here and threat to.

133
00:10:39,960 --> 00:10:41,020
Is this over here?

134
00:10:41,620 --> 00:10:48,070
I changed it to two, I'm going to comment on the delay function and I'm going to comment on the delay

135
00:10:48,070 --> 00:10:49,430
functioning third one as well.

136
00:10:50,050 --> 00:10:51,520
I'm going to fetch the Difford.

137
00:10:53,790 --> 00:10:54,720
From up here.

138
00:11:01,810 --> 00:11:04,500
And I'm going to place it in our default threat.

139
00:11:04,960 --> 00:11:05,460
OK?

140
00:11:09,070 --> 00:11:14,980
And one thing I should also point out is that over here, they're free ARTUS APIs are wrapped around

141
00:11:15,400 --> 00:11:17,760
what is known as the Sims is OS APIs.

142
00:11:18,460 --> 00:11:25,960
So if you are if you've ever coded free ARTUS or if you've just called it Free Artus us, it is written

143
00:11:25,960 --> 00:11:27,240
in the documentation.

144
00:11:27,280 --> 00:11:30,670
The function for creating a new threat is not always a threat.

145
00:11:30,670 --> 00:11:35,850
Def this function is a function coming from the Simms's.

146
00:11:36,400 --> 00:11:44,650
This file here simms's unaskable always not h free Arktos has other functions, just the CMC has written

147
00:11:44,650 --> 00:11:50,230
the wrapper around that such that we can use this generic, this generic function always threat def

148
00:11:50,830 --> 00:11:58,720
and then always threat to create such that when you are using the free R Toscano or the Kyle R t Zdeno,

149
00:11:58,720 --> 00:12:06,600
you can use the same functions to create your ARTUS your ARTUS system, but different Kano's.

150
00:12:07,480 --> 00:12:14,350
So this threat created is the same for free artus can or our tax code.

151
00:12:14,480 --> 00:12:21,190
Our taxes are not a real time operating system or real time operating system canno.

152
00:12:21,730 --> 00:12:28,240
So the wrapper function that assumes is always gives us, allows us to be able to use the same API calls

153
00:12:28,660 --> 00:12:31,090
but different Cannell's.

154
00:12:31,610 --> 00:12:36,910
Essentially, if you do not understand this, leave it in the questions and, uh, questions and answers

155
00:12:36,910 --> 00:12:38,650
area and I'll get back to you.

156
00:12:39,190 --> 00:12:46,450
OK, so now that we've added our profiler's, let's build our project and see a click over here to build.

157
00:12:49,990 --> 00:12:55,120
Right, the reason we have this area is the position of this, you know, when using TYPEDEF.

158
00:12:57,070 --> 00:13:01,600
So this is the type we want to rename it to this new this new word.

159
00:13:01,810 --> 00:13:05,020
So that is why and because of that, we have another error here.

160
00:13:05,800 --> 00:13:16,600
So typedef, we want to rename or be able to use TASC Profiler whenever we want to see you in 30 to

161
00:13:16,600 --> 00:13:17,280
Enniscorthy.

162
00:13:17,560 --> 00:13:19,180
OK, I'll click here to build.

163
00:13:31,030 --> 00:13:32,530
OK, we have one warning.

164
00:13:32,560 --> 00:13:38,080
Let's see, OK, from this default threat profile we want to increment, I'll put a plus plus here.

165
00:13:39,250 --> 00:13:41,800
OK, so quick to build again.

166
00:13:46,470 --> 00:13:49,770
OK, this has built successfully a click here to go to debug.

167
00:13:51,850 --> 00:13:53,140
And then also like this.

168
00:13:57,030 --> 00:14:00,610
I say, OK, over here, right?

169
00:14:00,690 --> 00:14:06,690
So what I'm going to do is I'm going to Ottawa, profile this to our global to our live expressions

170
00:14:06,690 --> 00:14:06,870
window.

171
00:14:06,910 --> 00:14:07,880
I'm going to take this out.

172
00:14:07,890 --> 00:14:09,330
This is from the previous project.

173
00:14:09,900 --> 00:14:18,060
I'm going to come over here controversy to copy and then I'll paste and then I'll get tasked to prove

174
00:14:18,060 --> 00:14:19,800
my life's work on cruzi to copy.

175
00:14:23,450 --> 00:14:24,190
Sorry about that.

176
00:14:27,540 --> 00:14:30,620
And then I'll get this last one.

177
00:14:35,180 --> 00:14:37,790
OK, so what is going to happen next?

178
00:14:38,450 --> 00:14:43,640
I'm simply going to click here to run, click here to run.

179
00:14:45,410 --> 00:14:50,660
What we have we have currently is just our default threat profile are running.

180
00:14:52,010 --> 00:14:52,490
Right.

181
00:14:53,000 --> 00:15:01,280
And this is according to our this would be according to the settings of our real time operating system

182
00:15:01,880 --> 00:15:03,050
currently as it is.

183
00:15:04,310 --> 00:15:07,580
And the reason we have this is.

184
00:15:09,090 --> 00:15:14,700
Shown over here, I want to show this to Windows so I can post this right.

185
00:15:15,720 --> 00:15:20,100
So we have just this running and the reason we know it's running is because the counter variable is

186
00:15:20,100 --> 00:15:22,830
incrementing threat one threat to the Stuxnet.

187
00:15:23,670 --> 00:15:27,630
OK, let's go to the part where we created a task.

188
00:15:28,440 --> 00:15:33,200
OK, so over here we created our two tasks.

189
00:15:33,900 --> 00:15:35,330
This is the difficult task.

190
00:15:35,340 --> 00:15:41,060
We left it as it is, as it was in Cuba, makes the priority of this one is always priority normal.

191
00:15:42,030 --> 00:15:44,670
And this is our third one.

192
00:15:44,790 --> 00:15:47,240
The priority of this one is always priority.

193
00:15:47,250 --> 00:15:47,880
I do.

194
00:15:48,690 --> 00:15:51,840
This is our threat to the priorities, always priority.

195
00:15:51,840 --> 00:15:54,150
I do so always priority.

196
00:15:54,150 --> 00:15:57,450
Normal has a higher priority than always priority.

197
00:15:57,450 --> 00:15:57,960
I do.

198
00:15:58,020 --> 00:16:06,180
That is why only this threat, which is known as before the task and this same threat profile is the

199
00:16:06,180 --> 00:16:07,500
fourth threat profiler.

200
00:16:07,740 --> 00:16:09,420
That is why this you're the one running.

201
00:16:10,560 --> 00:16:12,030
These are idle threats.

202
00:16:12,030 --> 00:16:15,060
The lower frequency, they've got lower priorities.

203
00:16:15,060 --> 00:16:20,720
Therefore the the law doesn't give them any time to run at all.

204
00:16:21,360 --> 00:16:28,530
So how about we change the priority and we set all of them to always be priority normal, copied this.

205
00:16:29,280 --> 00:16:32,850
And I'm going to said this and then I'm going to put this over here.

206
00:16:32,850 --> 00:16:35,880
Let's see what we get a click over here to build.

207
00:16:44,400 --> 00:16:47,460
It built successfully a click here to go to debug.

208
00:17:01,080 --> 00:17:01,770
It's open in.

209
00:17:07,490 --> 00:17:09,590
What's he going to minimize this?

210
00:17:20,480 --> 00:17:27,110
Come to live expressions here, and, um, it says we've got to do this again or do the

211
00:17:29,770 --> 00:17:35,720
removal and then this is it, threat one profiler.

212
00:17:38,230 --> 00:17:45,760
I copied this out it over here, I'll copy through it to profiler.

213
00:17:48,350 --> 00:17:54,420
Little over here as well as this copy of it over here.

214
00:17:55,000 --> 00:18:00,500
OK, I'm going to click here to run and now, as you can see, they're all running and they have almost

215
00:18:00,500 --> 00:18:01,230
the same volume.

216
00:18:02,030 --> 00:18:04,850
So this is what is known as Round-Robin scheduling.

217
00:18:05,390 --> 00:18:11,120
And what Round-Robin means is we allocate equal amount of time for each thread to run.

218
00:18:11,520 --> 00:18:17,960
So we'll see if we've allocated ten milliseconds for each thread thread.

219
00:18:17,960 --> 00:18:24,800
One is going to run for ten milliseconds and then it's going to be put on hold.

220
00:18:25,010 --> 00:18:28,640
Oh, well, we call this is the threat is going to switch the right switch.

221
00:18:28,640 --> 00:18:35,030
I would switch from third one and go to thread to try to also run for two or for the same amount of

222
00:18:35,030 --> 00:18:38,740
time, which is ten times, and then the other one will run.

223
00:18:38,750 --> 00:18:43,130
And this is known as round robin, such that they run for equal amount of time.

224
00:18:43,400 --> 00:18:48,170
And because that is the case, that is how come the counter variable is almost equal because they are

225
00:18:48,170 --> 00:18:49,820
running for equal amount of time.

226
00:18:50,210 --> 00:18:55,720
And we saw what we got when the when the priority levels were different.

227
00:18:55,730 --> 00:19:00,140
If you have them in different priority levels, then they all don't have the same priority.

228
00:19:00,140 --> 00:19:03,380
So they didn't need no run at exactly the same rate.

229
00:19:04,020 --> 00:19:08,870
OK, so this is our initial experiment for our free, our choice.

230
00:19:08,960 --> 00:19:11,210
Um, so there's the part one.

231
00:19:11,210 --> 00:19:15,080
We shall continue this in the next part, so I'll see you in the next lesson.

232
00:19:15,080 --> 00:19:19,460
We just continue where we've, uh, we've got to thus far because the video is getting a bit long.
