 So, in previous lecture we have seen installation of CCS, then we have written some simple program about the LED blinking and how to build that program, how to debug it into the micro controller. So, in today's lecture we will see some important parts of programming which are important for us I will make a termings applications particularly like interrupt service routine, then PWM and quadrature encoder interfacing that QEI. So, this we will look at these modules and we will debug that program into the micro controller and I am having a DC motor with me. So, you can see, so this is a DC motor with encoder, this is the encoder. You might have seen this motor image in lectures also. So, this is motor with encoder and this is connected to this A298 motor driver, which is an inverted double-edged bridge, like full-edged bridge circuit and this is connected to the TVA micro controller. So, we will write this program and build it into this micro controller and we will run the motor and we can read the actual values of inputs like position and direction and speed of the motor. So, yes, we will start now from, we will start from, so we will first of all this, we will start this program to the studio and I have already written quotes for this ISR 59, PWA and QEI, all these things because it is, it will take too much time to write the program again. So, and we are going to share these programs with you also. So, you can, you can see that program also. So, just we will like overlook about this programming. So, this is a previous workspace which we have created, I think. So, we will launch this one only. So, here it is starting, just you are having this workshop PDF video. So, in that PDF, the lab number six, I think, lab number four is about interrupts and timers, you can see. So, you can look at this, this is also giving the interrupt service routine program. So, what is interrupt and how it is, how it works. So, already you learned that in the lectures about the interrupt and what is ISR and what is the significance of that. So, you have already learned that. So, just for now, we will look at how to program it in CCS. So, yes, so this is the lab four, you can go through this lab also. So, you can get some idea about this interrupts. So, this is where this program is for linking and leading with some delay. So, you can try this program and run that program also. But for now, we will look at our program. So, yes, so you have seen, yes, so this is to, this is our project explorer and here. Okay, so, we will write the program for, or we will look at the program for LED linking using ISR or interrupt service routine. So, we will create new project. So, new project, do the studio CCS project. Next, here our target is give a CCS, GH6PM and the debug interface is still in the same circuit. So, I will just name as ISR for on board ELES. So, interpolate with main.c and finish. Yes, so, I have copied that program and I am going to paste it here. So, for now just I will take this program is basically, it is including some like PWM also and QVI also. So, we will first of all, we will delete that because we are, particularly we are going to look at ISR only for now. And then we will go to the QVI and this PWM also. So, PWM also we will delete. We are not doing this PWM at all. Okay, so, this is also not needed. Okay, yes. Now, we are going to use interrupt service. This should be included. And this should also be included. Yes. So, this is our program like these are header files. Then some of the functions like we are not going to use this PWM or timer and sorry, timer is going to use. So, QVI and this PWM function in this program we are not going to use. So, it is not needed. Or you can keep. It will behave as a redundant program. So, yes, these are functions for like this timer and it is for timer initialization and ALDG LED is for ALDG linking program. Like you can see here on this function you can get directly what is written in that function. Also for here also. Yeah. So, we will going to look at read. So, PWM frequency is also not needed. And yes. So, this is main function. So, here we have already seen that here we have like uses this system division of 5 and this PLL of 16 megahertz. So, our frequency is 40 megahertz now. Then this is for like enabling the PWM model GPIOT. But however you are not going to use that. So, it doesn't matter. Also, this GPIO C is for QVI model. Same. And this GPIO EF like 40F is for onboard LED's. So, we are for now only going to use this GPIO EF because we are only targeting our onboard LED's and ISR through this. So, we are GPIO pin type GPIO output. So, we have made this pins 1, 2, 3 as output pins. And now we have we are calling these functions now in main function only. So, PWM frequency not required. So, timer unit. So, what after this like enabling this peripherals like 40F. What will it do? It will like run this function timer unit and what is timer unit function. So, timer unit is initializing the timer. So, for any interrupt or interrupt service routine. We need to define one timer for that particular interrupt service routine. So, here in T1 we are having number of timers like timer 0, timer 1 and like timer A, 0, timer A1, timer B, 0, timer B1. Like that type of timers we are having. So, we can have number of interrupt service routines for that purpose. And we can use different timers for different applications. So, for now this timer initialization function is for ISR routine that we are going to use. So, it is enabling the peripherals enabled. So, this is a peripherals enabled. So, which is going to enable this timer 0, because we are going to use timer 0. That's right. Then this is a configuration of the timers. So, it is like there are many functions like timer CFG Peraldy or some different configuration will be there. So, we are using this Peraldy as a Peraldy. So, all these functions like system control peripheral enable or timer configuration or timer load set, int enable. All these of this type of function you will get here in this pdf like T1 functions pdf which we have already shared with you. So, in that you will get this all these functions. So, for example just for now I will tell you about this timers like so yes this 29 chapter is for timer and this API functions. You can see there are number of functions are there like timer ADC event gate timer ADC event set like that. So, for now we have used this timer configure. So, in timer configure we have done this whatever timer you are we are going to use. We have to provide its base address which is timer 0 address. You can see here also that is timer configured and the first input to this function it should be or first argument is the base address of the particular timer that we are using. And then how to configure it. So, it will like after clicking on this function also you will get more about you will get to know more about this function. So, for example this is now timer configure function and here it is giving the what is the parameters actually. So, this is the base is the base address of the timer module and it is the configuration of the timer. So, description is also there like for example what type of in which different ways we can configure the timer. So, that a timer can be configured to be as like a full-width timer a timer CFG or half-width timer A timer B like that. So, the number of different ways to configure the timer. So, of this among this we are using this timer CFG periodic. So, I am going to tell you this because whenever you are going to write the program you should go to this particular PDF. And you will get to know what is this the we can see the function of each this API function like what is what this API function is doing. So, anything like for example for now we will see that what the system control peripheral enabled means. So, system control peripheral enabled means what. So, here I think it should be the system control yes and API functions. So, yes you can get here system control clock set which is the basic or first line we can say where we are going to set our clock frequency. So, here after picking on that you can get. So, this is the which is required configuration of the device clocking. So, you can see here there is the division 1 division 2 division 3 like that up to 64 also the use of PLL either we will use PLL or we can use as oscillator. So, that and external crystal frequencies can be chosen in this way. So, you can see there are like number of ways and number of different arguments that can be given in this particular function or any different particular functions. All these arguments are what should be written in that function is provided in this PDF under this section. So, we can click on any function you want and you can go you can search for this description and you can see what is should be written inside in here. Like for example, you can see here like number of external crystal frequencies are there and of which we are using this 16 megahertz. So, that type of study you can do yourself to get to know what is like what is the significance of different API functions. And so that you can write your own programs in different ways with different many types or be many different ways you can write your program. So, again one particular function I will tell about it and ok. So, we after that we will look at the next part of the program. So, system control peripherally enabled that is that is the particular function which is we are using every time. So, this one system control variable enabled. So, you can see here. So, this is argument is this argument which is given to the function is peripheral to be enabled. So, which peripheral unit we want to enable we have to give its name or we can basically say its address maybe like it is port AF or port D or it is QVI model or it is PWM model or it is a timer model. Whatever peripheral we want to enable it can be given inside here in this function. So, you can see this is GPIOB, GPIOD, GPIOC we have we have switched on this GPIOF for our LEDs or this is PWM we are going to use this PWM PWM1 in our next program or QVI1, QVI0. So, this type of different arguments are there and you should follow this particular function because it will otherwise the program will not get built because if there is a spelling mistake or any mismatch in these functions and your written functions then your program will not get built. So, yes for now so you can see this system we have seen this API function and system control peripheral enabled also and this GPIO output mix this. So, I can say this GPIO pin input pin type GPIO output is what this function will make the pins as a output pins, general problem input output or digital output pins we can say. So, here argument is first of all the base address of the port and then the which pins are to be made output pins in that particular port. So, port is F and pins are 1, 2, 3 like PF1, PF2 and PF3. So, this is the argument we can say. So, we are not needing this particular any peripheral we can commit it out for this particular program and yes. So, where we are? Okay, so this is timer configure. Okay, so there is like the period of the timer like we can say after like it particularly it will show it will be for the frequency of ISR. So, how frequently ISR should be called or interrupt service routine should be in function that particular frequency we can set here by using this timer load set. This EVI 32 period is one of the argument which is nothing but the timer like for example or time period we can say. So, for example, it is 16 control clock gate means whatever frequency we have set as a clock frequency that one divided by 10 means that particular frequency will be 1 second and divided by 10 means 0.1 second like that. So, here particularly if we are loading this time will be 0.1 period. So, our ISR will be in service we are or we can say this ISR will be called after each 0.1 second like that. So, yes then we have enable this interrupt enable then timer interrupt enable then interrupt master enable and then finally timer enable. So, all these models should be enabled and this is the program you will also get to know from here also from this lab. So, you can see here this is the internet world time interval int master enable like that. So, yes and this here it is just making pin I think 2 means it is making pin so ready ready on and off that's it. So, it is providing if it is on then make it off otherwise make it on like that. So, so I will show that so you will concentrate you should concentrate on this function this is interrupt handler function or we can say interrupt service routine. So, whenever this timer is calling the ISR our program will execute this particular function. So, this is function what this function does first in first line it will clear first of all this timer int clear. So, because it is clearing this interrupt otherwise our timer will not call again and again. So, it should be clear then again this timer enable will be enabled then the function will be called and again it is clear then it will enable like that this cycle will be there. And then what is what this from this is actual count means actual count is giving call to this here ready function and our ready function is what it will make pin on and off sorry ready ready on and off. So, basically in first call it will make me ready on then second call it will make it ready off. So, as we are going to call ISR or we are executing this ISR then it will turn on and off the ready ready. And this actual count we have provided here because we will see when this program is built we can count this like how much time this function is called and how this frequency particular frequency is affecting the ISR. So, you can see that because this ready function is going to return this count. So, count is equal to count plus 1 and initial value of count is 0 then each time this function is called it will increase the count by 1 and that particular count is this actual count. So, here we have already declared these functions and now you will wonder about we have not defined this particular function that is timer 0800 this function is nowhere defined here in this program or even nowhere called here like in main function as well as in timer function we have not called this particular function then how the program will get exhibited. So, yes this is what the interrupt service will do. So, basically when our interrupt is enabled after this frequency it will automatically call this function but how this function is we will get called we will look at it. So, first of all we are we will build this program we check errors. So, yes ok you can see it is not it is not because we have not provided the paths for this library files. So, here you should remember in previous lecture only we said in this properties in ARM compiler in productions we have to give path for this particular Tivaware installation file or folder this one ok. Then in ARM linker file search path we have to provide this driver lift file. So, I say it is in TI then this Tivaware software folder then driver lift in CCS dip again driver lift dot dip. So, yes open. So, yes now our program should be built successfully. So, there is some error it is showing some error that you are the COI 32 period is not defined yes because we have while deleting we have by mistake deleted this also. So, we will define it again in unit. So, 32 bit integer yes we mean initialize it for 0 and look at now ok. So, our program is not is built successfully without any error. So, we will now go for debugging it on a microcontroller. So, I have attached already the microcontroller. So, you can see here even if we have now run the program or resume the program then still the ready it is not blinking. Why so like even our program is not having any error or there also this error is not being blinking and the reason is. So, yes because this function is not getting called. So, now to make this function called we need to change something that you should look at carefully. So, that particular thing you will also get in this lab file also. So, in this program of ISR you have to go through into this base file that is dm4c123 the startup file. And in that startup file we have to make one change or we can say two changes like we have to define this function in that startup file. So, under here you can see here this is external function. So, external y and this function. So, y is different yeah. So, we have to define this function here in this startup file and also you have seen we have used this timer A of timer 0 base. So, here under this timer 0 sub timer A. So, you can see here there are lots of interrupt handler functions. So, for like I can say for first of all it is these aren't some default interrupt handler functions for each like jpo port A, B, C, D, UAR, T, SSI, PWM. This type of like peripherals are having these interrupt functions interrupt handler functions depart interrupt handler functions. And of which we have selected this time to 0 sub timer A and so we have to change this function name to ours which we have defined. Then only our program will run successfully. So, here we have changed this name to timer 0 interrupt end handler whatever name we have given here that name should be copied. And yes, control yes to save this. And now you can see now you will be debug it. Yes, now it is debug successfully. And now okay, I will show you this is and now yeah. So, this already it is now blinking with 0.1 second we can say delay. And for whatever it means we have provided. And now this actual count we can count it by using add to watch expression then okay. And here continuous regression. So, you can see this is the 0.1 second frequency. So, it is running with the atmospheric machine or it is increasing by the atmospheric machine. So, after each one count like at one count it the LED is off after and at another count it will turn on like that. So, this is just for showing you how this ISR is working and yes it is working and its count is changing and yes. So, this actual count is from this is a value changing because we are this in this ISR or this particular interrupt handler function we are calling this LED. And now we can change it to the 1 second time like this and we can debug it again. You can see watch this again here in the expressions you can see this changing value changing after 1 second. So, now we have changed the frequency of we can say interrupt handler frequency to this to the 1 second. So, it is value changing as a 1 second. So, yes we have also provided this program to you you can go through this program and you can like play through it. You can do step as useful for you and you can define this different you can use different frequencies and different types of. So, you can play around this API functions also and you can go through the functions actually what this API functions are doing. And then you will learn this programming. Thank you. So, yes now we have seen the basic ISR what is interrupt service routine. Now we will look at PWM for now like just PWM and then we will look at QVI module like this quadrature encoder interfacing module. So, we will go to this PWM. So, new CCS project, TOC, GH6PM, this and here we can write PWM for onboard LEDs. So, for now I am just providing this PWM for onboard LEDs. And you can see as the PWM duty cycle is changing the brightness of the LED will go on increasing and decreasing according to the PWM duty cycle. So, yes finished. Okay, we will just complete that program which I have written already. So, onboard a PWM and yes, yes, yes. Yeah, I have completed that program. Now just we will go through it. So, these are like the difference you can see. So, here PWM.h5 this is added now because we are going to use PWM type. So, yes, this COVI adjustment is for adjusting the duty cycle. And I is for like for changing the duty cycle. Okay, so, yes, this is how to be initialization. This is like the PWM because the PWM is what port which is having onboard LEDs connected to the onboard LEDs. And then we have this PWM module. And then block saved by this. You can go through this. Actually, you can go, you can all go through this different API conditions. So, what is PWM block saved? How it can be saved? Like what should we put here? So, this is you can see what is saved. Because like for example, it is 64, so it is expected to be 64. Like that. So, I will say you should go to this PDF functions. And here the style goes to this PWM API functions. And PWM block saved is PWM block saved or so you can see here PWM block saved. It can be 64 or 32, 64, like 64, like that. So, you can go to there and you can save the PWM block. Otherwise also in system control also using this function you can save this PWM block like that. So, I will not go to all these functions because you can go to these functions actually. And you can learn that functions. No issue. So, this is the PWM type PWM like that. Like this is making this for PF1, PF2, PF3 piece as a PWM piece. So, this one is actually PF1, PF2, PF3 like that. It is PWM 3. So, in this one, I will change it before we will go out of the group guys. Yes. So, this is for the group PF1 piece as PWM only 1 and our PWM output 5 like that. PWM 1 output 6, PWM 1 output 7. So, PF1, PF2 and PF3 all these things how so you cannot do like PF2 as a PWM 5. No. You cannot do that. So, each has its particular functions or we can say different functions but that are already defined. We cannot switch functions from each on different like you can see in this data sheet. You can see here I think pin die pin or signal tapers. So, here what we are looking for PF1. So, yes PF1. Yeah. So, PF1. So, you can see in PF this PF1 pin can be configured as analog comparator or PWM 1, PWM 5 which is motion parameter mode to the point PWM 5. So, or we can configure it as a QAI module 0 phase V like we can use this pin as a QAI pin also like that. So, different functions can be assigned to particular pin but at the time it can do only one function as well as like you cannot write program without looking to this data sheet because you can see this PF1 is written as PWM 5. So, this is making this PWM. So, this is doing configure this PF1 pin as a PWM pin but you cannot write PWM 6 here because that PWM 6 is assigned to this PF2. So, like that you should go to this data sheet while writing the program. Then only you can see which pins can be written as these pins like that. So, yeah. So, the PWM is called a figure. This is the amount down you have already seen like this is up and down and only down like that. So, this is for integration. Then if you already said it is maximum period like 100 now I am giving it means period of the PWM. Like for example, if it is presented as 100 and we are going to provide its pulse width as 50, it means 50% in 20 cycle or if we are going to provide the PWM width as 80, then it is the PWM will be 80% or 80% in 20 cycle. So, it will depend on this period. But later which I will just tell you we cannot set this period directly as this. Like we can say but whenever we are going to use this for particular thermodynamics applications like DC motors, then this period is depending on the PWM frequency which we are going to use. So, here we are just going to apply this PWM to LEDs. So, it will not matter that much. But when we are doing for a thermodynamics applications, then we should know at which frequency this PWM signal should be provided to the motor. And according to that particular frequency this period will be changed. So, you can go through this long spread workshop. And here I think after 10 or 11 lab is for PWM. So, yes, this is for PWM. You can go through this particular lab and you will also get to know more about this. So, before coming into this programming, you should go like this particular lab in this workshop. So, you will get better ideas. So, this is the period set, then PWM output state. So, output state is 5, 6 and 7 of this PWM 1 is true. So, if we are making it as output, PWM output. And now we have a number of these generators, PWM generators. So, all these things you can get from the data sheet. Like for example, just I will show you. So, when you see this data sheet, this particular is attached to PWM generator 2. And this one is operated by PWM generator 3 like that. So, we have enabled this PWM generator 2 as a generator 3. And PWM 7, which is also operated by generator 3 only. So, these two and they are enabled now. And now we have a wild loop. What we have done is, we have first applied for from I1 to 21. And we have changed this EY register as I into 5. So, first idea is we will be 5 and then its final value is 100 like that. So, our duty cycle will change from 5 percent to 100 percent duty cycle. So, here pulse PWM pulse width set, we are giving its width as a EY8 integer. So, for each loop, this particular PWM width or we can say duty cycle in other words will change. And then we have provided this delay. So, we can stay this delay as a part of one second. I will give this to you to find out how this will be one second or what is this, sorry. So, how to make this as a one second. So, 10 minutes. So, 10 minutes we can say or anything we can find out that. And this A is giving us that A is equal to PWM width gate. So, it is set and this is gate. So, it will give us the particular value of this video. So, for now I will just see I have only to PWM 5 because we will just look at ready-ready. And not for other LEDs. So, yes this A is going to be fine. So, now we will improve properties. Then introductions here, browse in TI this folder. And ARN linker, file search path here. Not sure to be here. We will look at it. Build. Yes. So, this is now without a error. Now we will build this program. Sorry, we will debug this program on to the debug aspect. And now I will show you. So, currently it is on the debug aspect. So, when I upload this wiring set, these wiring are like A input wiring which we will look at after this one. So, yes. Now I will move to resume this. So, this particular, so I will say. So, this is actually equals to now. This blue LED is always one because of this PWM model. And that's why we are getting, we are not only getting ready-ready. So, just we will make some change. Instead of this, we will make as a code 6. But one thing I will show. Our program is not wrong. Just we will show you. So, keep it as a 5 only. And so we will run it. You can see here the A. And most is A. And yes. This value is like 5, 10, 20, 20, or like that. It is changing by 5. So, this PWM is changing or 20 cyclic changing for 500. So, the program is okay. But this blue LED is also one. And that's why we are not going to get exact idea. So, just I will change this to 6. And we will look whether it is now giving. So, yes it is giving. But I don't think from camera you can recognize it. Now, I think you will get this. The intensity is changing. How this intensity is changing? But maybe one. I don't think from camera you will be able to see this change in the brightness. But it is like little one and difficult to recognize from camera. So, just we will see. So, this particular brightness is changing. From 0 you will recognize it actually. Otherwise it is looking as same only. Minimum is from for you. I can recognize it. But I don't think you can recognize this change. You can look at when it is becoming 0. So, yes, this brightness is now increasing. Like that. So, in this way you will be learning this working. So, even you can, I will provide this. We are going to provide this particular program also with you. You can try this program. You can see the speed of the brightness is changing. And you can play with different areas. I made it new and green. And these areas are completely different. You can see the changes in the brightness. Otherwise you guys, if you are having an extra layer in your phone, like small area you can say. You can provide that speed of the signal that we want there also. So, that to change also. You can say so that to recognize this change. And actually the speed of the signal should be given to be like, like we are going to use for gas megatron applications like DC motor. Where we can control the speed of the DC motor. So, here it is for just for the, we can say the first glimpse of the first idea of the PWM, we have given it to the LED. So, as this brightness of the LED is changing, in that way we can change the speed of the motor. So, I will show that also. So, yes, this is the PWM. Now we will look at QEI model, which is quadrature encoder interface. So, basically that is not given in this workshop. So, you can look carefully. We will build your program for that. So, particularly that QEI model is, what it is going to do, it is capturing the signals from quadrature encoder or like rotary or linear encoders, which are having changes as APR and index channel. And we can obtain the position, velocity and the direction of the rotation or linear movement from this interface. Like QEI, we can say here is a simple QEI. We are not, I will rotate the motor by my hand opening and we will go and recognize the changing position of speed. So, yes, finish. Finish also. This is QEI ready encoder data. This is interesting. We will provide this provided also. So, just I will let you know what is it. Like these are live profiles. And here this QEI library file is now added because we are going to use this QEI model. And yes, this position and velocity and the direction of the variables for the recording. And PPR, you should know what you may know or you can study this encoder. So, the PPR is what like per revolution, the how many counts are there, what is PPR and PPR and how this partition encoder works and how it will make this count useful in our, we can say, calculation of the velocity and all these things. So, yes, this is hardware initialization enable periphery of GPIO-D because we are using port D as a QEI model. So, I will show you this port D. We are going to use QPR-QEI model because the pins like PD-7 and PD-6 and PD-7 are the pins which can be configured as a QEI pins. So, we have enabled this GPIO port D. So, you can see this PD-7. So, yes, this is PD-7. So, PD-7 pin can be configured as PHB-0, that is QEI model 0 phase B. And where is PD-6? PD-6, PD-6. So, this is PD-6 and this PD-6 can also configured as PHK-0 which is QEI model 0 phase A. So, here we have enabled this particular port D. Similarly, you can use port C also. I think port C, the PC-5 and PC-6 pins can be configured as QEI pins. So, you should go to this data sheet to recognize all these things. So, what pins should be, which pins should be used and all these things. And now, port D we have enabled and on port D the QEI model is QEI-0. So, there are two models, QEI-1 or QEI-0. As we have using port D or PD-6 and PD-7. So, we should enable this QEI-0. And now, this is one step that whenever you can see on this workshop file also, I am going to use this switch program. So, how to use this on-board switch provided on Tiva. You need to unlock that particular key. This is not needed for all the keys, but there are particular keys like this PD-7 or again I think PC-5. For this piece, we need to unlock this piece because they are configured as another and at first they are locked with particular function only. So, we need to unlock this. So, for PD-7 only, we need to do that. Not for all the pins. That means you can get it from here. You can get the data sheet also, which pins are to be unlocked or not. These things you can get. And also while programming, when particular key is not working, then you will get to know oh, there is something wrong. And you will go to the data sheet and you can search like that. So, this PD-6 and PD-7 pins are we now made as a pin type QVI. As we have already used this type of which type of pin type, GPIO output or PWM, and now we are using it as a QVI. So, this is and it is now configured as PD-6 should be used as PH0, PD-7 should be used as PHB as provided in the data sheet. And now before going to configuration, we have to configure this QVI. We have to disable this QVI model and interval QVI. And then configure it as a, you can go to this, like I will go. And so QVI, API functions, QVI configures. So, here we can say we have to provide first of all base. So, we are using QVI model 0. QVI is the base. And now we can configure it as a many different base. Like you can see, either you can capture only A or you can capture A and B. So, here we have provided it as a capture both A and B. What is A and B? These are the signals from encoder, like channel A and channel B. Then whether it should be reset on index pin or it should not be reset like that. Like for example, after reaching this 1336 value, it will again come to this 0. Like that. So, we can provide it whether it should be reset or we have to not, we don't need to reset it. Like that. So, I will tell about this value also. Just shortly. Then it can be, the QVI can be configured as quadrature or as a clock and direction. You might have seen there that in lectures also. And here we have configured it as a quadrature encoder. And it is swap is needed or not. So, swap, which means like if our by mistake provided this channel A pin to the PH, PD6 on board, like the physical it is pin from the motor, or encoder is channel A and by mistake we have attached it to the PD7 and channel B is attached to the PD6. In that case, you might need to swap the configuration. But of course, we can directly change it physically only. But if it is not possible, then you can go for swapping it. And according to this value, it is like we can say you can provide any value if you don't want to recognize this rotation. We can say so when one rotation is completed, if you do not need that, then you can go for any higher values. But for now it is value like it is value of when 360 degree is completed like 360 degree or one rotation of the motor is completed at that time it will reach the position of 1336. And it will again depend on this PPI value. So, PPI into 4, it will give us this value. And it will reset, like after reaching this value, it will again start from 0. So, we can get to know it is now reached over rotation, then it will again start from 0. Then when it starts from 0, like that. So, it will get reseted. And now enable this QEI and also enable filter if you need. And also we have to configure this velocity also. So, these are functions for your velocity configuration. Like we need to divide it or not. So, you might have studied it in lecture also during that by seeing this signal diagram for the QEI. And also at the same time you can go through this API functions. So, I will like I will suggest to go through all the API functions whenever you are seeing these programs uploaded to you or given to you, you should go to this QEI functions. And you will get to know the functions then like the arguments and why these functions are used here and all this. So, QEI velocity enable we have enable this QEI 0 piece. And now in my loop we are getting this position QEI position get QEI 0 piece. So, just keep in mind you are reusing this QEI 0 because we have used this QEI 0. So, there is QEI 1 also which is provided or another piece like PC5, PC6, like that. Now we are getting this velocity but we need to cover this velocity into the RPM and then the direction. So, yes this is the program and just I will show you. These are like connections not connections, but So, this is motor and this two pins are for motor power and this four pins are one is for encoder power then one is for encoder ground and two pins are channel A and channel B and which are connected to this our micro T1 motor. So, at this motor you have seen already in the lectures and now I think we have not So, we need to promote this path. So, it should be a free you can say. Ok, yes. So, it is we will successfully we will debug it. So, just for now I will like add this position to watch expression then this RPM to watch expression now we will resume it. Ok, so program is now present and now I will rotate the motor by hand. So, you can see this position is changing. Ok, now my I will move by hand and now as soon as I am going to rotate it my value will increase but as I am going to stop the rotation then RPM will come down to 0. However, the position will be at the last position where I have stopped. So, yes. So, RPM is started and then it is coming to 0. Now, you can see the position is changing and now it should be coming to 0 after 1336 because we have provided that 1336, yes. So, you can see this is coming after 1336 it is coming to 0. Now, this motor is I cannot rotate very smoothly by hand and so that it is going to be increasing even if I am rotating it slowly but I cannot rotate it too slowly to go by 1, by 1 like start by 1 by 1 and now I will rotate it in another direction. So, this position is really now increasing in another direction. Like that you can now if I am rotating just for you I will just connect this motor supply to the 5-way supply or not. So, you can see you can see this velocity and how this 10 positions are changing. Just wait for a minute I will now I am rotating the motor by 5 volt you can see this constant velocity is there like somehow change will be there but almost constant sorry rpm and the position is continuously increasing I am coming down to 0 after 1336 and now I will change the direction now count is increasing now after change the direction instead of increasing it will go on decreasing and this is exclusive like that. Wait this count is not decreasing and we are providing the same rotation but in different direction that is the change. So, just wait I will connect it so that we can see now you can see this position and this velocity is changing and we will just plot this position and you can see we have the position is changing and continuous repression ok. So, yes it is going to 1336 and coming down to 0 so it is not too smooth because I have directly connected it to one smaller source and it might be fluctuating but yes in this way so because it is now we have provided it in one loop so it will take time as required by the let us say or provided by this voltage and according to the voltage how much time it will take to reach the this our world rotation and I will be able to train with that because it will directly flowing to the after one position it will directly flowing to zero position. But the thing is here the thing is now you can see that you can give any type of different ways like you can say you can give rectangular signal to the motor or sinusoidal signal to the motor or trapezoidal signal triangular signal like that you can by using what? the PWM duty cycle. So, you can write yourself the program where the PWM cycle is changing such with that it is rectangular. So, if PWM is rectangular then it will provide the the speed the speed diagram will be rectangular like that the position diagram will change irregularly. But you can control the position also using this PWM because you can write the program because now you are having this position count you are having the RPM and you can you can change the RPM by using PWM by using H bridge or L298 motor driver you can see the data sheet of the H bridge how this H bridge works how to provide the PWM signal to the H bridge and how to connect the motor to that and change the speed using PWM. So, programming the programming is the programming is almost this similar one just you need to I can say combine all this which I have shown to you like I have first of all we have go through this ISR then PWM then QVM. So, basically you need to combine all these things to run your motor in the way you want basically. So, I will give one just idea you need to read the encoder data and using that encoder data in programming you need to define your duty cycle to provide I can say the PWM duty cycle to provide the speed range or speed signal or whatever signal you want due to the motor you can give it using this QVM and PWM both and ISR you can use of course for this frequency of the signal to be provided like at I can just say a great number or but to that you have to use this ISR and with different ISR frequency. So, that part I will leave to you that how to combine this different programs or different course of different aspects of this DC motor for particular DC motor with encoder and how to run that motor as you want and just another aspect is by using this not only you can provide the signal to the motor but you can control the motor like you can develop the PID controller or PD controller like that so think about that and check how you can do that by using this QVI and PWM and ISR okay, thank you