ADC on 12f675?


Closed Thread
Results 1 to 11 of 11

Thread: ADC on 12f675?

Hybrid View

  1. #1
    Join Date
    Feb 2005
    Posts
    130


    Did you find this post helpful? Yes | No

    Default

    Bruce:

    Thanks var word
    loop:
    thanks=$FFFF '


    it works, now I need to adjust the code because the led dont work as expected, but I put a serout after the adcin and the terminal reads the different values OK!!!

    goto loop

  2. #2
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default

    Code:
    DEFINE ADC_BITS 10 
    DEFINE ADC_CLOCK 3 
    DEFINE ADC_SAMPLEUS 50 
    number VAR word
    
    CMCON = 7          ' Comparators off
    ANSEL = %00000001  ' GPIO.0 A/D in, rest digital
    ADCON0.7 = 1       ' Right justify for 10-bit
    GPIO = %00000000 ' Initialize outputs
    TRISIO = %00000001 ' GPIO.0 = input, rest outputs
    
        PAUSE 100
    
    Loop:
        ADCIN 0, number ' (0-1023)
        IF (number > 0) AND (number < 400) Then
          GPIO = %00000010
          'GPIO.1=1
          'GPIO.2=0
          'GPIO.4=0
        EndIF
        IF (number > 401) AND (number < 800) Then
          GPIO = %00000100
          'GPIO.1=0
          'GPIO.2=1
          'GPIO.4=0
        EndIF
        IF (number > 801) AND (number < 1024) Then
          GPIO = %00010000
          'GPIO.1=0
          'GPIO.2=0
          'GPIO.4=1
        EndIF
        number = 0
        GoTo loop
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

  3. #3
    Join Date
    Feb 2005
    Posts
    130


    Did you find this post helpful? Yes | No

    Thumbs up

    MASTER !

    I trully appreciate your prompt answers, thank you very much !!!

  4. #4


    Did you find this post helpful? Yes | No

    Default ADC with tone out and hysteresis

    Hi

    After looking to the examples above I have the following I want to do
    As this is my first ADC code I need some tips and maybe some help

    I want to do the following

    ADC on GPIO.0 8 bit

    I have a DC voltage between 0.5V and 2V approx
    Which is varying all the time

    I need to encode the DC variation by a tone between 67hz and 250hz
    with 2-4 hertz incremental/value

    The DC values needs to be stored in EEprom at setup
    (example button is pushed at powerup to enter setup)
    30 DC values should correspond to 30 tones (30 tone's might be set fix in the code)
    So example:

    0.55V = 67hz
    0.64V = 71hz
    0.71V = 74hz
    etc...

    Once setup and running: if a DC value is between or equal next value it has to
    output the tone ( set in the code)
    with a kind of hysteresis for the tone duration and before next sample)
    and a Serout to check the values
    Can anyone help me ?

    Walter

Similar Threads

  1. Stable Adc Reading Routine
    By gebillpap in forum General
    Replies: 27
    Last Post: - 13th May 2015, 02:18
  2. Can't get ADC to loop
    By TravisM in forum mel PIC BASIC
    Replies: 2
    Last Post: - 11th October 2009, 15:33
  3. ADC value with 2 decimals on an LCD
    By Squibcakes in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 2nd December 2005, 15:54
  4. 12F675 ADC 'Issues'
    By harrisondp in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 31st March 2005, 01:55
  5. Serial LCD on 12F675
    By anj in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 31st March 2004, 23:11

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts