Interfacing a DAC

Interface a DAC and generate Triangular and Square waveforms

 Interfacing diagram:


  • P0.4 to P0.11 are used to get the Digital values.




1. Program to generate square wave with DAC interface


          0xff  ________
             |                     |                  |
             |                     |                  |
             |                     |                  |
             |                     |                  |
    0x00 |                     |_________|

Program:

#include <LPC17xx.H>
void delay(void);
int main ()
{
LPC_PINCON->PINSEL0 = 0x0 ;// Configure P0.4 to P0.11 as GPIO
LPC_GPIO0->FIODIR  = 0x00000FF0 ;
 while(1)
    {
        LPC_GPIO0->FIOPIN  = 0x00000FF0 ;
        delay();
        LPC_GPIO0->FIOCLR  = 0x00000FF0 ;
        delay();
    }
}  

void delay(void)
{
          unsigned int i=0;
          for(i=0;i<=9500;i++);
}
-------------------------------------------------------------------------------------------
Test:
Download the file “Square.hex” to trainer using Flash Magic 6.01 version.

Jumper JP3 should be shorted. Jumper JP11 should be open for bipolar mode. Jumper JP11 should be short for unipolar mode and all the other jumpers should be removed. Switch off SW3, Un-short JP7. Press the reset switch (SW1) to run the program.
Result:
Observe the Analog output waveform at the Pin-1 of RM3 using Oscilloscope (CRO) with respect to GND pin-2 of RM3.

NOTE: POT3 is provided to control the Reference voltage for DAC output (Vref).User will get maximum 2.5V peak to peak for uni-polar and 5V peak to peak for Bipolar.


2. Program to generate Triangular wave with DAC interface

        0xff    

                   /\          /\
                  /  \        /  \
                 /    \      /    \
                /      \    /      \
               /        \  /        \
                 0x00 /           \/          \

#include <LPC17xx.H>

int main ()
{
          unsigned long int temp=0;
          unsigned int i=0;
 
  LPC_PINCON->PINSEL0 = 0x0 ;  // Configure P0.4 to P0.11 as GPIO
  LPC_GPIO0->FIODIR  = 0x00000FF0 ;
           
    while(1)
    {
                                           //output 0 to FE
        for(i=0;i!=0xFF;i++)
        {
          temp=i;
          temp = temp << 4;     //to shift bit to right 4
          LPC_GPIO0->FIOPIN = temp;
        }
          // output FF to 1  
        for(i=0xFF; i!=0;i--)
        {
          temp=i;
          temp = temp << 4;
          LPC_GPIO0->FIOPIN = temp;
        }
          }       //End of while(1)
}                 //End of main()
-------------------------------------------------------------------------------------------

TEST:
Download the file “Triangle.hex” to trainer using Flash Magic 6.01 version.
Jumper setting are same as sine wave.

Result:
Observe the Analog output waveform at the Pin-1 of RM3 using Oscilloscope (CRO) with respect to GND pin-2 of RM3.
NOTE: POT3 is provided to control the Reference voltage for DAC output (Vref).User will get maximum 2.5V peak to peak for uni-polar and 5V peak to peak for Bipolar.








Comments

Popular posts from this blog

7-segment LED interface

Interface a Stepper motor