Stable ADC readings


Closed Thread
Results 1 to 40 of 91

Hybrid View

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


    Did you find this post helpful? Yes | No

    Default Re: Stable ADC readings

    Looking at your code, I guess it's your first program, There's quite a few mistakes in and it is also hard to follow what you want to do.

    No problem, been there...done that. Tell us what you want to do and we could build something to help you to get started.

    Tell us the PIC your're using and post your schematic if you have any, or describe it.
    Steve

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

  2. #2
    Join Date
    Aug 2011
    Posts
    40


    Did you find this post helpful? Yes | No

    Default Re: Stable ADC readings

    Sorry for double post but i tried many many modifications.
    my pic is 16F877A , i desire to put multifunctions buttons of steering wheel and decode for command radio car system .
    i make a test with leds for ADC value input .
    Oh,oh,oh,
    i have just see that i don't put MCLR to any connection , a resistor of 4.7kohms to +5V ?

    It is a very simple schematic for test but the entire schematic is for steering wheel command and FIS Tachometer car display modification in live .
    example : see the kwp1281 protocol codes of line K (not can bus) like VCDS soft but more simple.

    This is the first part ( BMF )

    For mainloop , it is because i modify the labels and i forgot it (val_leds) .
    For $ , it is a mistake , THANKS.
    i will try now

    Regards
    Last edited by mazoul72; - 24th August 2011 at 21:42.

  3. #3
    Join Date
    Aug 2011
    Posts
    40


    Did you find this post helpful? Yes | No

    Default Re: Stable ADC readings

    my leds light off after 2 sec , it is ok for starting (mainloop replaced by val_leds)
    But after i have only two leds lightning together , it is not good with all boutons
    and i have no blinking leds

    And now i have no actions on leds (off always) , i don 't undertand why , AD not stable or other....
    it is the same with or without MCLR .

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


    Did you find this post helpful? Yes | No

    Default Re: Stable ADC readings

    Ah ok I see, you read a voltage then act upon. Cool, I did something like that awhile back but it was for car remote starter purpose (Door lock, alarm bypass, Windows roll-up/down) Oh well, those were the days

    Yes MCLR must be tied to Vdd. 4.7K is fine.

    not sure of what you want to do and how it should flash your LEDs but try this one
    Code:
            bmf_comm1   VAR PORTB.0
            bmf_comm2   VAR PORTB.1
            
            LEDBlinkRate CON 200
            
            'Variables
            bmfsD       VAR WORD
            bmfs1D      VAR WORD
            iled        var byte
            
            'configuration du port pour lire l'entrée analogique
            TRISA = %00000011       ' RA0 et RA1 en entrée
            TRISB = %11111100       ' RB0 et RB1 en sortie
           
            DEFINE ADC_BITS 10      ' Set number of bits in result
            DEFINE ADC_CLOCK 3      ' Set clock source (rc = 3)
            DEFINE ADC_SAMPLEUS 50  ' Set sampling time in 
            ADCON1 = %10000010      ' RA0 à RA3
    
    test_depart:
            PORTB = 3               ' Turn ON PORTB<1:0>
            pause LEDBlinkRate      '  
           
    val_leds:
            PORTB = 0               ' Turn OFF PORTB<1:0>
            PAUSE LEDBlinkRate        
            ADCIN 0,BMFSd           ' Read CH0
            ADCIN 1,BMFS1d          ' Read CH1
            if (bmfsD > 1000) Then val_leds
            if (bmfsD > 750)  Then boucle_led
            if (bmfsD > 500)  Then boucle1_led
            if (bmfsD > 250)  Then boucle2_led
            
            goto test_depart
            
    boucle_led:
            PORTB = 1
            for ILED = 0 to 5
                    PORTB = PORTB ^ 3
                    PAUSE LEDBlinkRate
                    NEXT
            goto val_leds
            
    boucle1_led:
            High bmf_comm1
            pause LEDBlinkRate
            goto val_leds
            
    boucle2_led:
            high bmf_comm2
            PAUSE LEDBlinkRate
            Goto val_leds
            End
    seems to work for me here, 4MHz oscillator, some different led blinking opattern depending of the value of AN0.
    Last edited by mister_e; - 24th August 2011 at 22:54.
    Steve

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

  5. #5
    Join Date
    Aug 2011
    Posts
    40


    Did you find this post helpful? Yes | No

    Default Re: Stable ADC readings

    Hello,

    it still doesn't work ....I don't understand why .
    The leds are still off whenever i select any buttons .
    I see 3.96 V between middle point of my buttons and external pull up resistors (on RA0 and RA1) .
    When i push buttons , i have 1.44V / 0.80 V / 0.40 V .
    Whith quantum 4.88xxx mV , it gives to me 295 , 164 , 82 .
    For 3.96V , 811 aproximatively .

    LED replace resistors out (to test)

    Name:  bmf.JPG
Views: 4684
Size:  31.4 KB

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


    Did you find this post helpful? Yes | No

    Default Re: Stable ADC readings

    Simple, there's no voltage in there as it is right now. You'll need to modify the circuit to add some voltage there. The pull-up thing should work.

    Do yourself a big favor, output the value of the ADC reading to a LCD or to your computer, push on a single button, note the value and modify the IF-THEN value in the code.

    What are your pull-up value?
    Steve

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

  7. #7
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    4,132


    Did you find this post helpful? Yes | No

    Default Re: Stable ADC readings

    On F877 or F877A there are NO pull-ups on port A. Only on Port B.

    Ioannis

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


    Did you find this post helpful? Yes | No

    Default Re: Stable ADC readings

    Check this thread, seems you want to do something really alike
    http://www.picbasic.co.uk/forum/showthread.php?t=15229&
    Steve

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

  9. #9
    Join Date
    Aug 2011
    Posts
    40


    Did you find this post helpful? Yes | No

    Default Re: Stable ADC readings

    10k for pull up external.
    i have only two wires to tie at right and two wires to tie ar left of steering wheel.
    So 12 buttons in fact .
    If i tie like the thread you provided , so many wires and this is the first part of entire PIC system .
    i am not sure there are enough wires after this.
    I have 25 inputs/outpouts tie to PIC .(without components reserved operation )
    Perhaps the eight outpouts/input reserved to LCD (for test before FIS tachometer connected) .

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