 So, in the last class we were looking at programming philosophy, so of microcontroller in general. So, microprocessor has different different kinds of way like you know interfaces available and we saw some general philosophy of programming interfaces also. In the last part where we looked at control registers and actually working registers. So, now in this class we will look at different kinds of interfaces that are available and typically some with some examples we will look at their little more detail about what is their utility, how they can be used used for you know useful applications ok. So, let us begin different kinds of interfaces possible ok. As we can see here, so first is digital input output interface ok. The digital input output is a most common interface that is there in all microprocessors or microcontrollers. So, this interface allows you to exchange the data in the digital format either input or output with the external peripherals ok. So, for example, if you have indicators or some LED light that you need to glow after some process has happened or indicating something has happened, then you can use this digital input interface. Then you can have limit switches to in the operation you want to kind of control the application such that it does not damage the system. So, when this limit switch is reached like you know that is indicator that your operation beyond this point is going to be harmful. So, when that switch is reached we will switch the system off or do something to save the system ok. Like that you can use this digital input output interfaces. Other very important application for this is stepper motor running ok. There are different interfaces available for stepper motor running nowadays. You can use digital input output as a as a most basic kind of interface with amplifier or you can also use PWM interface nowadays for these. Then you can use this for direction control in the servo motor control. So, there are ample applications and this is both most important interface to be used. So, say for example, we saw 7 segment display in our previous classes. So, to program that 7 segment display you will need this digital input output interface by using that you can display some numbers or some data to the user ok. So, this how this interface works is very simple actually we you know the registers now. The registers if the pins of the registers are made available to the user normally they are not available to the user. So, I given a register if the pins of the register are made available to the user then user can use that those pins for where the data is high or low that we depend upon if the value in the register is 0 or 1 the pin will go higher low and that is what is indicated and used by the external user in some way. And you can have like some kind of a logic to have the facility for the this wire to kind of input the data to the register as well ok. Then reading and writing to this digital input output is done by using like some kind of a control registers to by programming control registers first where like you define whether the given register or digital input output port is so to say it is called is used in the input mode or output mode. So, for that you need some kind of a control registers typically. Now let us have a look at little bit of more details about this diva launchpad that is what we will this is optional, but we will use in this course as a hardware for this diva interface this diva board that is picture is seen here the F port for example in diva is used for LEDs online some part of the LEDs you know there are so this 3, 4 LEDs that are there on the board there are 3 LEDs actually. So, R, G and B these 3 LEDs are there and they are connected to some diva port connection pin diagram is shown in this diva data sheet. Now the way this diva input output pins other pins ok this is F port, but there are some other ports available on these pins. And interestingly this is very compact and more kind of a modern ARM architecture as we saw based interface or microcontroller interface for this digital input outputs. So, let us have a look at little bit more details about what facility this interface gives in diva ok. So, before going to the ADC we will look at the diva in little more details here ok. So, you can see that the diva periphery rival library this particular file PDF file will give you all the details about the functionalities or the API library is there. So, this is a driver library these are API functions are there this function description is given in this file and in this you have the this is a diva data sheet for the diva. So, so this is microcontroller data sheet and this data sheet also gives you the details of the GPIO interface. So, this so depend upon this programming philosophy you will use either of these two for the programming. So, for example, if you use the diva microcontroller data sheet it will have these all these different different registers that are defined here. So, let us say GPIO interface if you see here general purpose input output ok. So, it will give you the different different registers that are used in GPIO interface for example, and this some kind of a block diagram of the architecture of this general purpose input output interface and so on and so forth all these registers where you can use for programming and controller that will be given here ok. So, in this you will have directly functionality given. So, if you are using directly API functions of this driver library then you do not need to worry about like you know these different different registers that are control registers or you know working registers you need to understand how these functions are written ok. And interestingly if you see this diva general input purpose input input output interface it has this port this general purpose input output pins have a mapping possible ok. So, for example, these pins can be like you know normal function or alternate function selection is there. So, where you can select it as a as a say for example, QEI interface pin ok. So, so, so, this for this digital pins you can configure this pins to work as a quadrature encoder interface or it they can work as a PWM pins ok. So, this configuration is done via two ways one is by using this kind of a control registers that are given in this data sheet of the diva the chip or the functions ok. So, for example, if you go to this GPIO functions then like you know it has some introductions and there are different different functions that are given ok and some of these functions are like you know having this pin configuration if you see here is a pin configure kind of a thing. So, you configure this pin for different different types of pins it can be as a ADC pin or it can be as a general purpose input output pin or PWM pin or QEI pin like that. So, so, this function you can directly use then for the for the configuration ok. So, so, like that you start reading through the data sheet and understanding this different from functions. So, if you go through details of this function you will find a way to use it and write it and then there are this of course, there are these you know programming examples that are given. These are functions here, list of functions and programming examples and then you can directly go to programming examples and like you know see this sample programs and figure out ok what changes you need to make to do it for your own kind of a purpose ok. So, let us get back here so, that is what about GPIO general purpose input output interface. So, in this particular case of diva that interface has a possibility of many different functions that can be you know possible for that interface ok. So, so, you can program the pins. So, this is pins are programmed that interface is GPIO, but the pin can be programmed to have different different kinds of other interfaces possible there ok which may not be there in all the microcontrollers ok. This modern microcontrollers which is ARM based microcontroller diva has that functionality ok or some microcontrollers for XCP100 for example, will have only input output pins there they they are not non configurable ok. You cannot change their functionality to use them as a PWM pins ok. So, so, depending upon what is written in a data sheet and what is of your interest you can start using them ok. Now, let us look at this ADC interface so, this as a name says analog to digital kind of conversion interface and it is used for reading analog sensors. So, you have analog sensors like temperature sensor, pressure sensor or potentiometer, accelerometers they have analog output and that analog output needs to be sensed or you want to say some like resistor value resistance resistor is there in which the when the current changes like you want to sense the voltage there know that those are kind of places you use these ADC sensors you have the strain gauges for example. So, there are many many different utility for this analog to digital conversion and how this analog to digital conversion happens is by using a comparator ok. You have this digital analog conversion interface first which which uses digital value given by microcontroller and processes it to give analog output ok. How does it do that maybe we have some something to show ok I will show you some stuff later. So, so, this digital analog conversion is done first and analog value is available. Now, this analog value on one of the pin that is available is compared by using opamp comparator with the analog value that user wants to sense and when these two my values match each other then like you know the digital value that is a supplied to this pin which is used for comparison that digital value is going to be the value for my analog to digital conversion conversion ok. So, this is how like the analog to digital conversion works by using the comparison with you know value that is generated by the microprocessor itself through digital to analog conversion. So, so, this interface is also very popular we need to use it many places in mechatronic systems for various kind of sensing application and this is IoT for example, is very much in IoT this is of a great value this interface a lot of values can be sensed analog like temperature or like acceleration that in the places can be sensed and that can be used in the IoT way to monitor some situations around any machine ok. Then this is a very important other interface called quadrature encoder interface. This interface basically is used for encoders so, we have seen in the sensors lecture what are the encoders. So, those encoders you directly want to interface with microcontroller you will use this quadrature encoder interface. This has as we saw before it has a signals of the form A and B where they both are kind of a pulses which are 90 degree phase shifted those A and B I will taken as the input to this quadrature encoder interface and then they are processed to generate a number or they are counted to get a number which will correspond to the position of the encoder. So, this is nowadays very useful interface because encoders are digital sensors for position instead of using your potentiometers encoders would be preferred because they will have like absolutely no noise because they are digital in nature ok and that has a lot of important applications in position control systems ok. So, lot of mechatronics positions positioning system positioning stages would use encoders and for those encoders these interface will be very useful with printers or machining systems no SCNC and others they will have these encoders. Then this motor like we will discuss this more details about this interface and how to program for particularly for Tiva we will discuss little bit more detail in another class and that can be used for actually programming this hands on your training your own kind of a Tiva microcontroller for using this interface along with the motor that is there in the kit. Then you can have serial and other kind of communication interfaces which are nowadays available like a USB communication or can communication ok. So, this control area network kind of a communication interface that has been specifically designed for automotive kind of a control systems ok. So, these are all different different kinds of interfaces that can be possible for serial and other communication. You can have any some kind of a Wi-Fi kind of a interface or you know wireless communication kind of interfaces also are possible. So, although in Tiva it is not there, but there are other kind of microcontrollers where you can find the direct inbuilt interfaces or with Tiva if you want to use you can use ZigBee kind of a you know wireless devices to communicate with ok. Then so, this is where like I was talking about this digital analog conversion interface which is there in the analog to digital conversion interface. So, to make ADC work you need to have a DAC inside ADC. So, this DAC interface can be also used separately you know so, typically this interface would work very simply you can have this you know circuit which is some kind of a opamp with this dividing resistors those provide this current here and then this current is amplified and your you produce this analog voltage output ok. And this current is proportional to you know the digital values that you are supplying at every each of this resistors and these resistors values are so, selected such that the calculation will show that you know your when this digital value is changed linearly the analog output voltage will change linearly ok. So, this is like a summing opamp which will sum up all these different voltage which are coming here because of the differential currents that are proportional to the you know the digit that digital value that you provide here. And higher the digit say say d 0 is a least kind of a significance digit its resistors will be resistance will be very high and the more significant will have a low resistance. So, that it will get like you know more representation in the summation ok. So, this is typically the digital to analog interface works ok. And this is not very wide, but some applications where you want to run like you have a motor which you want to run and it is having an amplifier which is analog to analog kind of a conversion amplifier there you will need digital to analog interface. Otherwise typically for running motor we use PWM kind of interface which you will see. And the main drawback or what you say not drawback it is a characteristics of the digital output is that it will have the stepping kind of a behavior of course, because your voltages or your digital values are going to be in discrete kind of a form. Depend upon the number of bits that you use for this conversion. So, you have a 3 bit conversion then like the least count will be 1 over 8 you will have that much kind of a error in conversion like that you have this possibility. So, this is called quantization kind of errors typically that they will exist in these systems. Now we come to this PWM interface which stands for pulse width modulation interface. And this is very important interface for mechatronics engineers because this interface you can use for driving many different kind of actuators or you can use it for clock generation kind of a application for external peripherals. There are many different ways this interface can be used, but the most important is driving the actuators by this interface. Why this interface is used for driving actuators we will see that. So, how this interface works is basically it uses a clock signal of microcontroller and divides that or uses that to generate some kind of a pulses. Now let us first understand what is this pulse width modulation. So, this pulse width modulation will be where you have a pulse coming on the pin and that at some frequency say maybe about kilohertz or 4 kilohertz kind of a frequency the pulse comes. And the pulse has typically clock pulse will have 50 percent duty means like know the clock pulse will have a 50 percent on time and 50 percent off time. The PWM you can have this different possibility of varying that duty in the sense you can say this is 10 percent PWM or 10 percent duty PWM where the on time can be changed depending upon what is application or what is the requirement. So, this is a PWM interface provides a facility to change the frequency and on time for the pulse ok. So, we will see more programming details will be there in the microprocessor data sheet microcontroller data sheet and we will have a look at in the further classes ok. So, this now let us look at how this motor why motor needs PWM interface ok. So, if you want to drive an actuator ok. So, you need a driver for amplification ok. So, say because you cannot say ok I will connect my motor directly to my microcontroller and it will start turning know you imagine like know you cannot connect the ceiling fan for example, do your microcontroller and expect it to run right. Because the typically this motors will require like larger power ok microcontroller are supposed to be like know very low power devices they will provide hardly any current for these applications to run. So, what we do is we amplify the current that we or current or voltage whatever you want to say that we get a output from the from the our microcontroller and then provide it to the actuator. And suppose let us say if we use some kind of amplifier amplification here say let me get the interface right. So, if we use say some kind of a transistor based amplifier for example, so typically amplifier is required. So, micro this will be the kind of a configuration that you will use. So, microcontroller the output goes to amplifier amplifier amplifies the thing increases power and gives to actuator and then actuator drives your mechanical system. And thus the sensors will sense the feedback and it is provided feedback to microcontroller and microcontroller will take some decision to process this and give power to the amplifier. This is a typical kind of a you know it is a loop in which the microcontroller your mechatronic system would be working. Now, so we are focusing on now this amplifier unit here. So, what kind of amplifiers we will use suppose say we have a transistor based amplifier. So, say ULN2003 chip for driving stepper motor is there like that we are using some kind of a transistor amplifier. So, if we use this amplifier in the servo motor ok. So, what we are talking here is right now when we are talking in this actuator driver interface we are typically the servo motor we are talking here not a stepper motor here. And the servo motor not really this aero modeling servo motor. So, they are different kinds there is a different although the terminology is same what we are talking about is DC permanent magnet DC motor we will use this term permanent magnet DC motor rather than servo motor ok. So, when we are we have to drive permanent magnet DC motor then if we use this kind of a circuitry and then here we input we give from our digital analog conversion ok. That voltage we give here then that voltage will be amplified and you get some kind of a like you know current through flow to flow through this load ok. So, so what is the problem with this kind of a interface. So, so if you think about like you know what happens we need to go back to the transistor characteristics. The transistor characteristics tells us that unless some base bias voltage is there you cannot fire the current through the collector ok. So, so so that means, like you know you need to provide some kind of a bias voltage to the to the transistor before we expect some current flow to happen in the motor which is one drawback that you have this kind of a dead band that will come. And the other thing that is a that is kind of a main reason you know you will have a problem here that you go below certain kind of a you know voltage given by the analog to digital converter digital to analog converter from your microcontroller and then beyond this only the motor will start running somehow ok. And other problem is where like see when this is very very low like you know this voltage or the signal that is that is given from the microcontroller is very low you will have lot of noise that will be seen the signal to noise ratio will be very high for the low signal ok low value of the of the voltage that you are providing and that that would drive some kind of a you know your actuators will get driven with that kind of a low signal that is amplified version of that signal will go to the motor and then motor will start making like a like a noisy behavior ok. So, this is main problem here and other thing like you know of course, we need to think about is ok the other like side we do not have like you know same kind of a characteristics and then other side we will need to see ok how do we reverse the direction of the of the motor ok. We cannot like you know drive current negative by the same kind of a circuit we need to have something else to do to reverse the direction in the motor ok. So, how are the solutions for this problem done by using pulse width modulation is what we need to think about and see. So, you pause and think ok how this problem can be solved by using pulse width modulation where pulse is of a fixed voltage value ok, but the pulse duration can be changed. So, so think about that and then pause here for a while after you have done gathered your thoughts then you can go forward ok. So, ponder over these questions. So, as I have told you the pulse width modulation has this idea where the on time period can be changed ok. So, now, what happens when we do these kind of a thing going to the to an amplifier the same kind of amplifier we use. So, so we use same transistor amplifier, but the now instead of giving analog as a input to the that amplifier we give this you know changing pulse as a input to the amplifier. And this pulse is given at a very large frequency. So, large frequency is that in such a way that your motor output does not respond to this pulses ok. What I mean here is that see this pulses can be changing at a frequency of say few kilohertz. Now, imagine if your motor is given the input at that kind of a higher frequency motor has a large inertia ok. The frequencies of the motor or the bandwidth of the motors will be typically in the like now some few hertz kind of a range. And when it is given kilohertz kind of a signal what motor sees actually is the average value that is seen here ok. So, how this average value is seen we will also be clear this is this is based on the basically the because the inertia of the motor is much higher ok. And suppose we give this input to our amplifier then what happens is the value is always operated operating point is always here ok. Because values are either 1 or 0 you can see that this value here is either 0 or 1 ok. This is 1 here and this is 0 here. So, but only the period of on time it changed this is a time period and on time out of that is it changed ok. So, since the on time it changed like and this value is fixed the now this the noise if you talk about that we said is in the small range here. So, we are not since we are operation operating at this point the noise is not going to bother us any time now ok. So, noise will be much smaller than than this value here ok. So, the voltage value that we are providing since it is either 1 or 0 the noise levels are relatively low as compared to that and that is how we get rid of the noise problem here. And then this how does which how do we change then the amount of power given to the motor by changing the on time ok. As you give on time lesser and more like you see that you know the power delivered will be more or less average value of the current that will be flowing in my motor is going to change based on the you know on time or how much time I I give this in during the cycle of the PWM ok. So, so this mechanical inertia of the motor it does not respond to this pulses is what we may make use of this fact and and the motor can see then only the average power delivered ok. So, this is how this fundamental principle is used for driving you know all your actuators you know very very you know noise free kind of a way. And how do we reverse the direction we use the edge bridge circuitry to do this ok. So, so this you might have already some of you might have already used this in the in programming your you know some hobby motors or something like that. So, these are the advantage that are listed for the PWM ok. Then how do we reverse the direction is is using this edge bridge and edge bridge there are this lot of these different chips available for edge bridge kind of functionality. And it works as an amplifier and direction reversal both functions are done in the one kind of a chip ok. And this is very good ideal kind of a thing for motor control and digital control of the motor. And there are many advanced features could be available in other kind of chips ok. So, this edge bridge has a very simple way of switching the transistors and reversing the direction of the current in the motor ok. So, this is transistor based switches are realized here. And this is one way direction and this is other way direction reversal by switching S 1 and S 4 first and S 3 and S 2 next reversing the direction ok. So, you can see this is a configuration of typical edge bridge ok. So, it has say some gates to operate and things like that. And so, you are one can figure out from this kind of a block diagram of the chip how this chip can be interfaced with your microcontroller and what to be what is to be connected to motor to kind of drive it ok. So, think about this you know we will have this important exercise to be done. So, there is a inputs here and then there is a N A kind of a signal ok E and A is kind of a signal enable kind of a signal here ok. And then there are these outputs that are coming out of these edge bridge ok. So, you can see how many motors can be given see here to there are 1 2 3 4 outputs are there. So, you can drive 2 motors one motor can be connected here and other motor can be connected here. And then suppose I want to reverse the direction what should I do that you can figure out from this kind of a diagram ok. So, so, think about this then there are these some some kind of a sensing terminals also are available here. So, which can be used by user for something ok. So, you think and figure out you know it is not very difficult when this kind of a diagram is given to figure out how this current is going to flow for one particular direction which transistor should be on. So, this transistors here you can think them as a switches and then the switches are operated when this output of this AND gate becomes 1 ok that is a hint to think about ok. So, then like you know you can figure out how things would be working here ok. So, you pause and think about this part. Then there are many different kind of drivers that can be possible for the for this edge bridge or you know depend upon kind of a motor ok. So, DC permanent magnet DC motor can be driver driven by the edge bridge or stepper motor can be driven by this some simple Newton transistor amplifier. And important issues to consider is power requirements for the motor available control signal the especially the voltage output amplitude ok. And this power requirement and motor voltage compatibility should be seen ok power not only power, but voltage and current compatibility to be seen. So, driver also should be compatible with the with the motor. Say if motor is requiring 2 amperes of current driver should be providing more than that I mean typically 3 or 4 amperes of current rating should be there for the driver like that and of course, voltage compatibility should be there. Then number of motors to be driven would be other issue that will we can see then robustness requirements ok. So, there are some advance chips that are available to or advance drivers that will be available for giving you some additional functionality ok. Then typically brushless DC motors there are some controllers available for example, Maxon motors kind of or fall ever there are there are 2 major players in the international market which are having excellent quality for these motors ok. Then there are many different companies Siemens has controllers or. So, you can look at yourself like a lot of motor drivers available. Then you go for AC servo motors when you have very high power or torque requirements. Then we use a Kwanzer analog amplifier this is analog driver this is not a PWM amplifier this is analog amplifier which is used in our double flexure manipulator kind of a system where where we want to have a very high very low noise in the system and very high precision positioning requirement is there ok. So, like that you can have many different kinds of drivers possible. So, what you need basically the fundamental knowledge is about you know what we have seen you how do you read the datasheet and utilize the information to interface these different different things ok. So, you need to see mainly the current and voltage compatibility and of course, the absolute limits of you know different things. So, that you do not damage the damage the systems ok. So, this is what we had talked about anyway and and other thing is very important is it is response bandwidth ok. So, it the driver should be fast enough to respond to in many places this will not be a problem especially when we go for MEMS based kind of applications know then this response will be a problem because electrical like you know electronic things respond much faster electrical signals are much faster responding than mechanical motions ok. So, so response bandwidths will be satisfied like they will be pretty fast for the electrical domain, but when it comes to very tiny systems like MEMS then the motion can be very fast in at a at a at a low speeds low low masses ok. And then when these motions are very very fast then those bandwidths of that motion can be matching with the bandwidth of the controller and that is where we need to bother about the response bandwidth of the controller. And these are like some of the schemes for you know implementation as we have seen this one of these schemes we have seen already. You can have a computer or microprocessor or microcontroller whatever you want to use for the for the brain or for the control of these ok. So, so this is what like you know is about interfacing different different drivers and actuators here. And this we will see now how these interfaces can be then further used for building catonics application ok. Thank you.