ADC measuring


Closed Thread
Results 1 to 4 of 4

Thread: ADC measuring

  1. #1
    Join Date
    Feb 2005
    Location
    Portugal
    Posts
    79

    Default ADC measuring

    I'm a little new working with ADC so i need your help.
    I'm trying to make an overvoltage, undervoltage and overload circuit. What concerns to voltage I have to regulate a trimmer in 2.5V that corresponds to 230V. If voltage goes above than 250V or under than 195V I have to turn on an led. What I did was
    1024--------5V
    x------------2.5V
    x=409
    230V---------409
    250V----------y
    y=446
    230V---------409
    195V---------z
    z=348

    In corrent I have to measure values between 0 and 15.9A. I have an output in voltage (0-5V) that´s proportional to the corrent it´s passing. What I did was
    15.9 ---------- 5V
    and 5V it´s 1024, so
    15.9------1024
    x---------ADC_value
    x= (15.9*ADC_value)/1024

    To voltage and corrent my code is:

    DEFINE OSC 4 'o programa irá correr a 4MHz
    Define ADC_BITS 10 ' Set number of bits in result
    Define ADC_CLOCK 3 ' Set clock source (3=rc)
    Define ADC_SAMPLEUS 50 ' Set sampling time in uS

    ADC_corrente var word
    ADC_tensao var word
    corrente var byte
    unid_corrente var byte
    dec_corrente var byte
    unidade var byte
    decimal var byte
    ADCON1 = $8D 'temos RA0 e RA1 como entradas analógicas e RA2, RA3 como referências e RA5 como entrada digital.
    'o ADRESH tem 6 bits mais significativos a zero pág. 80 datasheet
    TRISA = $0F 'SSSSEEEE - Porta A
    TRISB = $FF 'EEEEEEEE - Porta B
    TRISC = $0F 'SSSSEEEE - Porta C

    porta.5 = 1
    ADC:
    ADCIN 0, ADC_corrente
    ADCIN 1, ADC_tensao
    if ADC_tensao < 348 then
    portc.4 = 1
    porta.5 = 0
    endif
    if ADC_tensao > 446 then
    portc.5 = 1
    porta.5 = 0
    endif

    if ADC_tensao > 348 && ADC_tensao < 446 then
    portc.4 = 0
    portc.5 = 0
    endif

    corrente = (159*ADC_corrente)/1024

    unid_corrente = corrente / 10
    dec_corrente = corrente // 10

  2. #2
    Join Date
    Feb 2004
    Location
    Germany
    Posts
    762


    Did you find this post helpful? Yes | No

    Default

    leonel,

    what is your actual question?
    regards

    Ralph

    _______________________________________________
    There are only 10 types of people:
    Those who understand binary, and those who don't ...
    _______________________________________________



  3. #3
    Join Date
    Feb 2005
    Location
    Portugal
    Posts
    79


    Did you find this post helpful? Yes | No

    Default Question

    My question is if what I did it´s right?
    Can I do that way?
    Regards
    Leonel Monteiro

  4. #4
    Join Date
    Feb 2005
    Location
    Portugal
    Posts
    79


    Did you find this post helpful? Yes | No

    Exclamation ADC Value

    What I want to do is the following:
    my output is 0V when Vin=0 and increases toward Vref as Vin approaches +256mV or -256mV.
    The biggest value that I could obtain is 5/0.256=19.5 that´s right?
    19.5 corresponds to 1024 in ADC?

Similar Threads

  1. Stable Adc Reading Routine
    By gebillpap in forum General
    Replies: 27
    Last Post: - 13th May 2015, 02:18
  2. 10 bit ADC display on LCD using 16f873
    By pr2don in forum mel PIC BASIC
    Replies: 3
    Last Post: - 6th March 2010, 18:29
  3. Can't get ADC to loop
    By TravisM in forum mel PIC BASIC
    Replies: 2
    Last Post: - 11th October 2009, 15:33
  4. 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
  5. 12F675 ADC 'Issues'
    By harrisondp in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 31st March 2005, 01:55

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