 Hello, Myself Ravindra Chahan, Assistant Professor, Department of Electronics Engineering, Walsh and the State of Technology, so in this session, we will discuss how to interface the digital to analog converter with the 8051. So at the end of this session, the student will able to apply the concept of DAC interfacing in controller based system design. The outline of the session will be like this. First we will go through the different DAC 0809 signals, then the interfacing of DAC with the microcontroller 8051 and then we will write the program by making the use of digital to analog converter. So here we are discussing the DAC 0809 signal. So this 0808 DAC is of the 8 bit means the DAC is having the 8 digital data input pins that is the D0 to D7 and the output of this DAC is in the form of current and this output pin is named as I out. So this I out is nothing but the current output of the DAC. But for most of the times, we are requiring this analog signal in the form of voltage. So at the output of the DAC that is by making the use of this current output, we have to use the current to voltage converter to get the final output in terms of the voltage. Then this V reference plus and V reference minus, this is these two are the reference voltages. Now these two if V reference plus is connected to the plus 5 volt and V reference minus is 0, so your reference voltage will be between 0 to plus 5 volt. Then the VCC to apply the power to the DAC and to close the circuit the ground is there. So this is the very simple interfacing with the 8051. From the 8051 side, only one 8 bit port is required. No any other control signals are required. So here we are using the port 1 of the 8051. And this we are connecting to the data pins D0 to D7 of the DAC 0800. Then the output is here that is the I out which is the current output. But we need the most of the times output in terms of voltage. So this is converted into voltage here the I to V converter. Now you can use any current to voltage converter. The simplest way is you just use one resistor here. So you use one resistor at the output I out and other end you connect to the ground and take the voltage across this resistor. That is also the simple I to V converter. But to get the precise conversion you can use here OPAP to convert this current into the voltage. VCC it should be connected to the plus 5 volt and ground should be connected to the ground. Then we will write the program by making the use of this interface DAC. So write the assembly program to generate a square wave using digital to analog converter. So how will you proceed this how will you write the algorithm. So first step is now what do you mean by a square wave okay. What do you mean by a square wave square wave means here the two levels of voltages need to be sent 0 and plus 5 volt means 0 and logic 1 okay. So first you send 0 wait for some time then send 1 and wait for some time again do the same things. So here the DAC output should be 0 for some time 0 volt then after required time it should be go to the plus 5 volt okay. So where we are getting the voltage you just recall the previous slide the we are talking about the V out output of the I to V converter. So make this V out 0 for some time then make this V out equal to plus 5 volt wait for some time. Then how will you do this first send 0 0 to the port 1 okay and this port 1 is connected to the digital input of the DAC. So for 0 0 the current output will be 0 and your V out will be 0 okay. Then you call a delay wait for some time to get the required of time. Then send FF to port 1 okay. So when you are sending FF to port 1 current will be maximum output current and we are getting V out is equal to plus 5 volt. Then again call a delay to get the required on time and then repeat the steps 1 to 4 continuously because the square wave is a continuous process. So you just repeat the 4 steps continuously. So as far as the program is concerned we can write the program like this move a comma hash 0 0 h okay. So first load the accumulator with 0 transfer to the port 1 okay. So V out will be 0 then call delay to get the required of time move a comma FF means and send to the port 1 okay means V out will be at logic high. Then call the delay to get the required time and do this continuously. Now you think how to write the delay subroutine then write the assembly program to generate a triangular wave using the DAC okay. Now how will you generate the triangular wave send 0 0 to FF to the port 1. Send first 0 0 then 0 1 then 0 2 and go up to the FF. So you will get the rising age of the triangular wave okay. And then send FF to 0 0 0 means you come downward from FF to 0 0 so you will get the falling age of the triangular wave. And repeat the steps 1 and 2 continuously to get the continuous triangular wave okay. So the example or the program is written here first load the accumulator 0 0 and transfer to port 1 to send the 0 0 to FF then increment the accumulator so 0 1 okay. Then compare this A with the maximum value FF if it is not FF then again send to the port 1 okay means the 0 0 to FF we are transmitting to the port 1. So when accumulator reaches to FF this condition will be false and it will move to the next line. So whatever the maximum value FF you send to the port 1 and now you go towards the 0. So decrement A compare A with 0 0 if A is not with 0 again do the same send to the port 1. When A becomes 0 then this condition is false then it will come to the next that is S jump again and repeat the same things infinite times continuously to get the triangular wave okay you now try to write the program to generate a sawtooth wave references used 8051 and embedded C programming by Majidi and microcontroller by Ajay Deshmukh.