Welcome back and listen, we are going to see how to use the free ARTUS middleware widow estimated to
keep a mix going to create a new project from Yeah for you project again, the microcontroller doesn't
matter.
It should work the same way on steam 32 boards.
I'm going to select my board here.
ASTM 32 for one one.
And for this experiment, I'm going to select the nuclear board.
I've seen no over here, and then I'll play all spin out play piano over here like this.
Say yes.
We're going to start off by enabling the LSD and the push-Button for our experiment.
Go to be a five sided to GPL, your output and P.S. 13 GPA you input like this.
So to enable free ARTUS, we come to a middle way over here and then we select free artists and then
we can select the interface here.
What are we using, Simms's, if you want to feed you.
So I'll just select assumes Simpsons for you one over here.
And then it's a neighborhood, right?
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
our experiment as well.
I'll come to connectivity, you know, enable my you to hear I started to asynchronous mode like this.
OK.
Next week we come to a system called system, and then we're going to change the time base over here,
says the time biz assistant.
We're going to change it to a different time.
You can select you can nominate two or three l just like three over here.
And debug, of course, you can leave it or you can just like this here, a wi fi.
So we can go ahead and configure our view of free artist and then we can see how to add things like
tasks and the other artists component.
So I just opened this again and then I'll bring this up like this.
So these are the configuration of the of the kennel, we can we can still change this in the in the
generated code like we see for other drivers.
When you generate the code from here and you go to your development environment, you still have the
option to be able to change it manually.
We can do the, um, this is tasks we can all tasks.
It says over here there's a difficult task task before task and you give the priority of the task always
priority normal.
And then over here that there is the the entry function starts Difford task, et cetera.
We're going to add a task over here.
I'm just going to call this thread one.
Remember, thread and tasks are used interchangeably.
If you want a definition that a threat is a task in execution, when a task starts to execute and we
call it a threat so we can use the two words interchangeable so we can live the parameters here the
same way, um, entry function we can just call it.
I call this thread one funk for function.
OK, the.
We can leave it then I got another one, call this thread, too, but you can give them any names you
want to make a bit more descriptive and then entry function through it to function.
And then I say, OK, like this next we going to the mutex and mutex means mutual exclusive.
And what this allows is, is that it allows us to use a shared resource effectively, not even efficiently,
but effectively.
And the reason that is important is if we have two threads trying to write out a you art at the same
time.
Yeah, there you are to the hardware driver, which is that you are two, which is the shared resource
might crush is the same thing with an LCD screen.
If you have two threads and they're all trying to access this single resource at the same time, you
could cause a crash.
What we have to do in this case is to provide a mutex such as such, that one thread would access it
and then when it's done, the other one would access it as well.
So we going to use that here.
Click mutex click out of here.
Our shared resource in this example.
This is is the is the you are.
So we can give it, um, our mutex and name you at mutex.
If we had LCD, we can give it the similar name so I'll click okay.
Here like this.
Okay, so once this is done we can go ahead and generate a good outcome to project management over here.
I'll try to change them.
32 covid.
I'll call this.
Free Artus.
I want to give it a descriptive name.
Tasks and mutex by the.
And we can live to the size and the stock size, the same should be enough when I click here to generate.
So this is our project.
I'm going to clean up a bit.
I'm going to reduce the number of comment here.
So this whole project with the M the number of comments reduced, OK, that's what we have.
We have the the threat ID, the threats we created.
Each one was given an ID.
So this is the right one.
Hondo and it's off type threat id threat to handle this also type threat ID as well as our mutex that
you are to mutex Holmdel then this is the default threat that we saw in Cuba.
Imex.
So a threat is basically a main function.
And what I mean by main function is a function with an infinite loop, a function that doesn't return
a function with a one loop.
So if we go to the threat functions, we'll see that the functions with infinite loops.
So this is our threat.
One func that we created in Cuba makes you can see this is an infinite loop.
This is another way of writing vol one and then it has a delay of one here.
This is the code generated by Cuba.
Makes this is this the same thing for threat two?
And this is the one for the start, the fourth threat, the default threat or tasks that we saw.
OK, and over here, often if you generate code with Cuba, mix without using the free Arktos or without
changing in time base since this is the time base.
But because we change our time based on time, a three time, a three snowless time base.
And the reason that is, is that the always canno of re artosis use insisting the real time operating
system needs a time or two to work as well.
So we've we are using system for that and we need another time out for our normal hardware initialization,
et cetera, some hardware parts or some hardware modules such as The Spy and I to see during initialization.
You need to apply delay every now and then.
We need something to generate such delays for us.
And over here we use in timer three to do that.
And this whole electic is the heartbeat of this other time.
So this is how our delay, if we call it all delay, is going to be used in this.
This is will be generating the delay using this whole Intec.
But before that it was done using the system timer knows is done using time of three.
And this is because this is the time that's been used by our free operators operating system.
Right.
So we have our task functions.
Three of them we saw in Cuba mix.
There was a default Tasco threat created and we added two more.
So one way to see if a while when you're working with ARTUS, one thing you have to do is profile the
task in some in some ideas.
There is a way to know if a task is running or not.
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
and we can profile simply using a counter variable.
So what I'm going to do is create a typedef typedef OSSE task profile.
And this is simply you to underscore what type of Darcis typedef allows me to use this new name in place
of you intended to underscore this whenever I want to type you intended to underscore to you I can simply
type this.
So then I'm going to declare three you in 30 to underscore Ts or callers thread one.
I'll see through it one profiler, and then I'll have to read to profiler.
And these are just controvert was just I'm giving them fancy names and then we'll have Difford through
it.
Before threat profiler and what were you going to do is we going to drop these counter variables in
each of the threats or tasks so that when we execute, we want to see all of them increment.
If all of them are incremental and they're almost the same value, this would tell us that our realtime
operating system is run and also it is running in a Round-Robin fashion.
Um, this is not the red one.
This is the red one.
This is the red one of.
Is this over here and threat to.
Is this over here?
I changed it to two, I'm going to comment on the delay function and I'm going to comment on the delay
functioning third one as well.
I'm going to fetch the Difford.
From up here.
And I'm going to place it in our default threat.
OK?
And one thing I should also point out is that over here, they're free ARTUS APIs are wrapped around
what is known as the Sims is OS APIs.
So if you are if you've ever coded free ARTUS or if you've just called it Free Artus us, it is written
in the documentation.
The function for creating a new threat is not always a threat.
Def this function is a function coming from the Simms's.
This file here simms's unaskable always not h free Arktos has other functions, just the CMC has written
the wrapper around that such that we can use this generic, this generic function always threat def
and then always threat to create such that when you are using the free R Toscano or the Kyle R t Zdeno,
you can use the same functions to create your ARTUS your ARTUS system, but different Kano's.
So this threat created is the same for free artus can or our tax code.
Our taxes are not a real time operating system or real time operating system canno.
So the wrapper function that assumes is always gives us, allows us to be able to use the same API calls
but different Cannell's.
Essentially, if you do not understand this, leave it in the questions and, uh, questions and answers
area and I'll get back to you.
OK, so now that we've added our profiler's, let's build our project and see a click over here to build.
Right, the reason we have this area is the position of this, you know, when using TYPEDEF.
So this is the type we want to rename it to this new this new word.
So that is why and because of that, we have another error here.
So typedef, we want to rename or be able to use TASC Profiler whenever we want to see you in 30 to
Enniscorthy.
OK, I'll click here to build.
OK, we have one warning.
Let's see, OK, from this default threat profile we want to increment, I'll put a plus plus here.
OK, so quick to build again.
OK, this has built successfully a click here to go to debug.
And then also like this.
I say, OK, over here, right?
So what I'm going to do is I'm going to Ottawa, profile this to our global to our live expressions
window.
I'm going to take this out.
This is from the previous project.
I'm going to come over here controversy to copy and then I'll paste and then I'll get tasked to prove
my life's work on cruzi to copy.
Sorry about that.
And then I'll get this last one.
OK, so what is going to happen next?
I'm simply going to click here to run, click here to run.
What we have we have currently is just our default threat profile are running.
Right.
And this is according to our this would be according to the settings of our real time operating system
currently as it is.
And the reason we have this is.
Shown over here, I want to show this to Windows so I can post this right.
So we have just this running and the reason we know it's running is because the counter variable is
incrementing threat one threat to the Stuxnet.
OK, let's go to the part where we created a task.
OK, so over here we created our two tasks.
This is the difficult task.
We left it as it is, as it was in Cuba, makes the priority of this one is always priority normal.
And this is our third one.
The priority of this one is always priority.
I do.
This is our threat to the priorities, always priority.
I do so always priority.
Normal has a higher priority than always priority.
I do.
That is why only this threat, which is known as before the task and this same threat profile is the
fourth threat profiler.
That is why this you're the one running.
These are idle threats.
The lower frequency, they've got lower priorities.
Therefore the the law doesn't give them any time to run at all.
So how about we change the priority and we set all of them to always be priority normal, copied this.
And I'm going to said this and then I'm going to put this over here.
Let's see what we get a click over here to build.
It built successfully a click here to go to debug.
It's open in.
What's he going to minimize this?
Come to live expressions here, and, um, it says we've got to do this again or do the
removal and then this is it, threat one profiler.
I copied this out it over here, I'll copy through it to profiler.
Little over here as well as this copy of it over here.
OK, I'm going to click here to run and now, as you can see, they're all running and they have almost
the same volume.
So this is what is known as Round-Robin scheduling.
And what Round-Robin means is we allocate equal amount of time for each thread to run.
So we'll see if we've allocated ten milliseconds for each thread thread.
One is going to run for ten milliseconds and then it's going to be put on hold.
Oh, well, we call this is the threat is going to switch the right switch.
I would switch from third one and go to thread to try to also run for two or for the same amount of
time, which is ten times, and then the other one will run.
And this is known as round robin, such that they run for equal amount of time.
And because that is the case, that is how come the counter variable is almost equal because they are
running for equal amount of time.
And we saw what we got when the when the priority levels were different.
If you have them in different priority levels, then they all don't have the same priority.
So they didn't need no run at exactly the same rate.
OK, so this is our initial experiment for our free, our choice.
Um, so there's the part one.
We shall continue this in the next part, so I'll see you in the next lesson.
We just continue where we've, uh, we've got to thus far because the video is getting a bit long.