PIC Programming in C

Discussion in 'Programmer's Corner' started by MCU, Feb 8, 2009.

  1. MCU

    Thread Starter New Member

    Feb 8, 2009
    3
    0
    Hey all

    I was wondering if I could get some opinions or suggestions relating my project . I am trying to interface a PIC into my circuit where it recieves 8 bit digitized input (From a separate ADC) . The PIC reqiures to perform a DAC every T minutes (Log) and save it into SD card (txt file , Time and D/A value). Does anyone know good resources to develop a code for performing D/A in C . And what family of PICs would be the ideal choice. I have PIC18F242 or 18F452 in mind .



    Thanks
     
    Last edited: Feb 8, 2009
  2. mik3

    Senior Member

    Feb 4, 2008
    4,846
    63
    I don't know any PICs which have a built in DAC. Maybe the ds30 family has otherwise you will need an external DAC. However, most PICs have a built in ADC.
     
  3. MCU

    Thread Starter New Member

    Feb 8, 2009
    3
    0
    Yes very few PICs have direct built in DACs . But while I was looking at the ds30 family as you suggested I realised you can achieve a reasonable DAC using PWM . Any idea how this can be done in C say using PIC18452 ?
     
  4. mik3

    Senior Member

    Feb 4, 2008
    4,846
    63
    If you know how to program in C then set the uC to produce PWM, buffer the PWM output with a transistor and put a low pass filter to take the average value of the PWM signal. By varying the duty cycle the average voltage on the low pass filter will vary.
     
  5. MCU

    Thread Starter New Member

    Feb 8, 2009
    3
    0
    I decided to merge the ADC into PIC. (Since I need the ADC to sleep during conversion) . So I used Assembly language to perform 10 bit ADC . Now I need to log this to the SD card . There are alot of SD card libraries , long codes and confusing [​IMG] cant find a good tutorial on SD card read/write.
     
Loading...