help using adcin


Closed Thread
Results 1 to 6 of 6
  1. #1
    Join Date
    Sep 2005
    Location
    France
    Posts
    50

    Default help using adcin

    HI,
    I'm newbie with adcin... I wrote this little prog for a pic16f87x, and it works fine.
    DEFINE OSC 4
    DEFINE ADC_BITS 10
    DEFINE ADC_CLOCK 3
    DEFINE ADC_SAMPLEUS 50
    bat var word
    temp VAR WORD
    ADCON1 = 0

    TRISB = %00000000
    PORTB = 0

    TRISA = 255
    PORTA = 0
    startval:
    GOSUB measure
    serout2 portb.0,84,[DEC bat," ",DEC temp," "]
    PAUSE 1000
    GOTO startval

    measure:
    ADCIN 0,bat
    adcin 1,temp
    RETURN

    But now, I would like to use a pic18f1220 and there is something wrong... the value for "temp" is now always the same as "bat" (adcin 0 versus adcin 1).

    Someone can explain ?
    regards
    Herve

  2. #2
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    Chances are that the internal comparator are disabled at POR.

    i'd tested it here and's working as it's supose to. So i'll guess on a hardware problem. Maybe a way to high impedance on the A/D inputs, bad PSU filtering,... or worst... a short circuit between them

    Sorry it's working here.

    BTW, you can even try to increase the ADC_SAMPLEUS value.. maybe.
    Last edited by mister_e; - 29th January 2006 at 19:58.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  3. #3
    Join Date
    Jan 2005
    Location
    France
    Posts
    97


    Did you find this post helpful? Yes | No

    Default not the solution but ...

    I'm working on same job but using a 16F88
    i spend hours becaus a got garbagge on serial output
    I find a solution
    Increase define char_pacing !

    by the way I have a problem .... value are not stable
    one unit less .. one unit more ... input is done with two resistors !
    quite strange ...

    here is my poor job !
    ' program to display result of 10-bit A/D conversion on LCD
    ' Connect analog input to channel-0 (RA0)
    adval var word
    advalcd var word
    advalcomp var word
    DEFINE CHAR_PACING 1000

    ' Definition des parametres ADCIN
    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
    TRISA = %00000001 ' Set PORTA to all input
    ADCON1 = %10000000 ' Set PORTA analog and right justify result
    Pause 500 ' Wait .5 second

    loop: ADCIN 0, adval ' Read channel 0 to adval
    adval.highbyte = ADRESH 'HIGH byte of result to adval
    adval.lowbyte = ADRESL 'LOW byte of result to adval

    Lcdout $fe, 1 'nettoyage ecran
    Lcdout "ADVAL ", #adval 'Affichage de la valeur en decimal

    serout porta.3,N9600,["Position = ",#advalcd," Degres "]
    pause 500
    Goto loop 'Do it forever
    End

  4. #4
    Join Date
    Mar 2003
    Location
    Commerce Michigan USA
    Posts
    1,166


    Did you find this post helpful? Yes | No

    Default

    F1CHF, The probable reason for the A/D reading jumping around is the input has some noise on it and it is being digitized. With a 5 volt reference for the A/D the minimum resolution per bit is 4.9 Millivolts. You should either do some kind of analog filtering using an RC network or do some kind of software filtering. The A/D is only telling you what it sees. Also make sure you have a ROCK stable reference voltage at the PIC. If you have access to a scope, use it, you will be supprised at what you see...

    Dave Purola,
    N8NTA

  5. #5
    Join Date
    Jan 2005
    Location
    France
    Posts
    97


    Did you find this post helpful? Yes | No

    Thumbs up ADC reading not stable

    Sir ... you got it !
    I use to "play" with a homemade dev board with a lot of stuff things
    like LCD, switches, push button, led, In situ prog, etc ...
    this developpement board is OK for normal use.
    In this case .. I discover that the small power supply has a 0.120 volt
    ripple .. with some spikes !
    2200 µF on the power itself, the well know trio of decoupling capacitors
    near the +5 volts regulator, and also near VCC and VDD on the PIC !
    you got it !
    I have forgotten the basic rule of electronic .. have a CLEAN power supply!
    it was clean for basic opération since 5 years ! not for analogique use !
    you are the winner !

    I am working on the following project :
    Using an On Screen Display IC (STV5730) show the antenna rotor position
    used in a radio amateur TVA repeater.
    I need to find a very good potentiometer to avoid variations in the reading
    thanks a lot 73's from F1CHF

  6. #6
    Join Date
    Sep 2005
    Location
    France
    Posts
    50


    Did you find this post helpful? Yes | No

    Default F1chf

    Bonjour CHF,

    J'ai essayé avec ta méthode, sans succès.... bon c'était de la simulation et ce prg fonctionne (en simul) sur pic16f88, pic16f87x.... je vais essayer avec un vrai 18f1220.

    Mais j'y pense, f1chf.... ne nous connaissons nous pas ? ce call me rappelle qq chose... du temps ou je faisais de l'émission OM et de la TVA... mon ex call F1SLU herve (pres de melun)

    73's

Similar Threads

  1. ADCIN and PIC18F4331 Arghhhhh !
    By GrandPa in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 6th December 2010, 20:27
  2. How to make adcin stable?
    By Pic2008 in forum mel PIC BASIC Pro
    Replies: 11
    Last Post: - 20th January 2009, 07:41
  3. ADCIN problems with PIC16F73
    By passion1 in forum mel PIC BASIC Pro
    Replies: 19
    Last Post: - 26th July 2007, 11:38
  4. Adcin or Pot
    By lerameur in forum mel PIC BASIC Pro
    Replies: 18
    Last Post: - 11th January 2007, 16:46
  5. ADCIN - AD settings are wrong
    By teverett in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 4th December 2006, 16:32

Members who have read this thread : 1

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