Stable ADC readings


Closed Thread
Results 1 to 40 of 91

Hybrid View

  1. #1
    Join Date
    Aug 2011
    Posts
    40


    Did you find this post helpful? Yes | No

    Default Re: Stable ADC readings

    Yes i tried last month , i have the value.
    I have already put schematic.
    my radio is pioneer 6900IP , only a jack remote input.

    My intension is to keep the wires buttons .
    With more wires , i have to change all connections.

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


    Did you find this post helpful? Yes | No

    Default Re: Stable ADC readings

    I know the input... how about the output?

    BTW, as per the service manual, this radio seems to use a stereo Jack... maybe you need a resistor on the tip, another on the ring? Whatever, the method on the previous link will work for the OUTPUT section.

    Name:  Part1.jpg
Views: 1969
Size:  85.7 KB

    Name:  Part2.jpg
Views: 1917
Size:  118.1 KB
    Steve

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

  3. #3
    Join Date
    Aug 2011
    Posts
    40


    Did you find this post helpful? Yes | No

    Default Re: Stable ADC readings

    I try assembler but i have some errorsName:  assembleur bmf.jpg
Views: 1875
Size:  145.5 KB

  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

    Assembler, C, Fortran or Pascal will not solve the problem here. The problem is not the ADC reading, it is what you do with.
    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

    the soft ? picbasic pro ?????
    i have the same error with mplab
    thanks to be explicit .
    it is an example from a guy - it works for him !
    it is not easy to spend all days to arrive ( only ADC) to nothing !

    Herve

  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

    Hervé, je veux bien t'aider du mieux que je peut, mais tu va devoir faire une partie des devoirs de ton coté.

    Ok, let's observe the schematic you posted


    OK, please answer the following question:

    Q1: The Resistor attached to the button are built-in the remote/Steering and you can't modify anything in right?

    A1:_______________________________________

    Q2: You have a 10K pull-up On RA0, and another on RA1... true?


    A2:________________________________________

    Q3: If so, assuming you don't push on any button, Between GND and RA0 AND between GND and RA1 with your multimeter you should read something like 1.4Volt RIGHT?

    A3:________________________________________

    From there, we need to etablish at least 4 conditions
    1) ADC reading when no push button are pressed
    2) ADC Reading when you push on Button 1 alone
    3) ADC Reading when you push on Button 2 alone
    4) ADC Reading when you push on Button 3 alone

    We can use maths to do so OR output each ADC reading to a LCD OR send the data do your PC via serial communication OR store them in the PIC EEPROM. Choice is yours. Let's see if the maths could work here.

    Without any push button pressed, I said around 1.4. Using the voltage divider theory
    (3902/(3902+10000))*5 = 1.403

    so the ADC should return something like
    (1.4/5)*1023 = 287

    Do the same with the other resistor value and you should be able to evaluate
    1) when no push button are pressed
    V = 1.4
    ADC Reading = 287

    2) When you push on Button 1 alone
    V = 0.37
    ADC Reading = 76

    3) When you push on Button 2 alone
    V = 0.58
    ADC Reading = 119

    4) When you push on Button 3 alone
    V = 0.82
    ADC Reading = 168

    Now, try this.
    Code:
    '
    '       Hardware setup
    '       ==============
            '
            '       I/O
            '       ---
            TRISA = %00000011       ' RA0 et RA1 en entrée
            TRISB = 255             ' Disconnect all resistor from the circuit
            PORTB = 0               '
            '
            '       ADC
            '       ---
            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
                                        
    '
    '       Software Variable
    '       =================
            ADRes       VAR WORD    ' ADC Reading
            BTN         var byte    ' Data to be sent to PORTB
            i           VAR BYTE    '
            ADCChannel  VAR BIT     '
            ADCButton   VAR BYTE [3]'
    '
    '       Software constant
    '       =================
            ADCSafety   CON 10              ' min/max range for ADC Reading
                                            '
            ADCNone     CON 287 - ADCSafety ' 
            ADCButton[0]  = 76              ' button 1 or 4 
            ADCButton[1]  = 119             ' button 2 or 5 
            ADCButton[2]  = 168             ' button 3 or 6 
                          
    Start:  
            TRISB = 255                     ' Disconnect all resistor from the circuit  
            ADCIN ADCChannel,ADRes          ' Read ADC
                                            '
            if (ADRes < ADCNone) Then       ' Any button down?!?
                                            ' - Yes!
                    FOR i = 2 TO 0 STEP -1  '   Loop through all 3 calculated posibilities
                                            '   Test against calculated ADCresult
                                            '   and allow a range of +/- ADCSafety
                            IF (ADRes > (ADCButton[i]-ADCSafety)) AND  (ADRes < (ADCButton[i]+ADCSafety)) THEN
                                            '   Valid ADC result, clear the coresponding I/O
                                    TRISB = ((DCD i) << (ADCChannel*3)) ^255
                                    PAUSE 200
                                    i=0     '   and getOut of here
                                    ENDIF   '
                                            '
                            NEXT            '
                                            '
                    else                    ' - NO!
                                            '   Switch to the other ADC channel
                    ADCChannel = ADCChannel ^ 1 
                    ENDIF
            GOTO Start                      '
    Button 1, enable PORTB.0, Button 2 PORTB.1 etc etc.

    For testing purpose use LEDs to VDD. It works here.
    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,139


    Did you find this post helpful? Yes | No

    Default Re: Stable ADC readings

    I Bet there are no pull ups on port A inputs.

    Ioannis

  8. #8
    Join Date
    Nov 2011
    Posts
    2


    Did you find this post helpful? Yes | No

    Default Re: Stable ADC readings

    Hello Mazoul72
    I think that you will be the one who can help me in this particulary issue. With all the respect for the experts of this great forum, but most of the users use so tecnical language that i don't understand. My formation is in philosophy...
    Behind my radio i have the k line, althrought my car is not can bus. As far as i understand the communications protocol is 3LB.
    Some months ago i've bought all the wiring for the multifunction steering wheel of the golf4, the relay 452 and the buttons (left and right). But i'm trying to make more buttons enable, because on the Golf4 MFSW there are only 4 buttons for control the radio and 3 buttons for cruise control. At least i would like to have six buttons to radio (volume up and volume down, next and previous track, next and previous source).
    I'm very frustrated because it all remain the same and i have a gorgeous multifunction steering wheel without functions...
    Perhaps you are kindness and maybe you could make one interface for me. If you want so, i can send you the money for the materias. I don't mind to take a change and i feel that i can trust you.

    Regards
    Karlos

  9. #9
    Join Date
    Aug 2011
    Posts
    40


    Did you find this post helpful? Yes | No

    Default Re: Stable ADC readings

    I think it is more reliable to use Kline to access to all functions (i am going to try to use these adresses Kline functions)
    i have a code but i have to work on it (Kline access based) .i will give a part of it in a new post to hope that someone can help us about it .
    Because my FIS display base code is the same than Golfop...(take on a yahoo group FREELY and freely redistriable but now it is too expensive to buy it---lot of work on it) .
    For try it , we have to use a little program to send caracters between DB25// and K-line .(see logs) LOGS.zip

  10. #10
    Join Date
    Aug 2011
    Posts
    40


    Did you find this post helpful? Yes | No

    Default Re: Stable ADC readings

    EDIT :

    See logs for what reacts FIS with sent caracters ... Attachment 6112

    LineK schematics , but we need a program to send values to see how reacts car radio LineK wire ...
    Name:  K-line E1_E2 PIC 16F877A.JPG
Views: 831
Size:  26.0 KB
    code :

    data(data line),clk(clock)
    suma=0
    dat=126
    Shiftout data, clk, 5,[dat]
    suma=suma ^ dat

    Rem High data

    dat=237
    Shiftout dato, clk, 5,[dat]
    suma=suma ^ dat

    Rem Low data

    dat=15
    Shiftout dato, clk, 5,[dat]
    suma=suma ^ dat

    Rem High data
    It is for DATA Line send (ENA/CLOCK/DATA)

    For cont=0 To 15
    tmp=msg[cont]
    Rem dat=255 - tmp
    dat= ~ tmp
    suma=suma ^ dat
    Shiftout data, clk, 5,[dat]
    Rem Low data
    Next cont

    'Somme de controle (sum)

    dat=suma + 1
    Shiftout data, clk, 5,[dat]
    Rem Low data
    High ena
    posy=255
    GoSub display


    FisDw:
    Low ena
    suma=0
    dat=169
    Shiftout data, clk, 5,[dat]
    sum=sum ^ dat

    know 255-longitude del msg

    dat=241
    Shiftout data, clk, 5,[dat]
    sum=sum ^ dat

    It is for example ,but it is a little part of sent values .

    Thanks in advance to ameliorate or given answers .

Members who have read this thread : 2

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