PIC 16F877A and RB out


Closed Thread
Results 1 to 8 of 8
  1. #1
    Join Date
    Aug 2011
    Posts
    40

    Default PIC 16F877A and RB out

    Hello,

    i want to command radio remote with jack rely to RBx
    How make resistors system with different value to different voltage in remote ?
    R2R voltage digital to analogic ?
    or other method ?

    Regards

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


    Did you find this post helpful? Yes | No

    Default Re: PIC 16F877A and RB out

    Hi and Welcome on the forum,
    There's a couple of different approach you can use. Depending of the accuracy you may choose one of the following

    1) A R2R network. So basically a couple of resistor attached to a single or multiple port then you mix them like a traditional OPAMP summing amplifier Like This
    2) PWM signal, then you filter with a low-pass filter. Usually a simple capacitor and op-amp buffer
    3) Dedicated DAC chip. And still there, you have different flavor, 8,10,12 bits

    Choice is yours.
    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: PIC 16F877A and RB out

    Thanks.

    What is the best method ?

    i have another problem with program for conversion.
    Hello,
    i made this to programm ADC

    bmf_comm1 VAR PORTB.0
    bmf_comm2 VAR PORTB.1
    'Variables
    bmfsD VAR WORD
    bmfs1D VAR WORD
    iled var byte
    blink1 var byte 'pour clignotement 1ère led
    blink2 var byte 'pour clignotement 2ème led
    'configuration du port pour lire l'entrée analogique
    TRISA = %00000011 ' RA0 et RA1 en entrée
    TRISB = %11111100 ' RB0 et RB1 en sortie
    ADCON1 = $10000010 'RA0 à RA3

    test_depart:
    Low bmf_comm1
    Low bmf_comm2
    High bmf_comm1
    high bmf_comm2
    pause 2000
    goto mainloop
    'lecture de la valeur
    getad:
    PAUSEUS 50 ' Wait for A/D channel acquisition time
    ADCON0.2 = 1 ' Start conversion
    WHILE ADCON0.2 ' Wait for it to complete
    WEND
    Return

    ' Subroutine to get pot x value
    getx:
    ADCON0 = $41 ' Set A/D to Fosc/8, Channel 0, On
    Gosub getad
    bmfsD = ADRESL + (ADRESH*256)
    Return

    ' Subroutine to get pot y value
    gety:
    ADCON0 = $49 ' Set A/D to Fosc/8, Channel 1, On
    Gosub getad
    bmfs1D = (ADRESH*256) + ADRESL
    Return
    val_leds:
    low bmfs_comm1
    low bmfs_comm2
    gosub getx
    gosub gety

    if (bmfsD > 1000) Then Goto val_leds
    if (bmfsD > 750) Then Goto boucle_led
    if (bmfsD > 500) Then Goto boucle1_led
    if (bmfsD > 250) Then Goto boucle2_led

    High bmf_comm1
    High bmf_comm2
    pause 1500
    goto val_leds
    boucle_led:
    iled = 0
    while iled < 5
    if iled = 1 or 3 or 5 then high blink1:low blink2
    if iled = 0 or 2 or 4 then low blink1:high blink2
    iled = iled + 1
    pause 1000
    wend
    goto val_leds
    boucle1_led:
    High bmf_comm1
    low bmf_comm2
    pause 3000
    goto val_leds
    boucle2_led:
    low bmf_comm1
    high bmf_comm2
    Goto val_leds
    End

    The leds works but always lightning , action on button (RB0 only for the moment) don't change anything.
    No blinking ,no high , no low when i push different button
    I don't know what .
    thanks.

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


    Did you find this post helpful? Yes | No

    Default Re: PIC 16F877A and RB out

    There's no such thing as best method, all of them will work, the PWM one is the easiest but probably not the easiest one to predict the final value. R2R is also simple, but to get really good accuracy you need at least 1% resistor. The DAC is easy but usually not the cheaper method.

    "How much accuracy you need" is the keyword I guess.

    Forum Rule: Please, do not double post your code all over the place, I'v already reply to that in your second thread.
    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: PIC 16F877A and RB out

    I have +5 V on my jack input with car radio remote .
    So i can't use a r2r (no voltage is possible , only resistor )

    What is the method for it ?

    Regards.

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


    Did you find this post helpful? Yes | No

    Default Re: PIC 16F877A and RB out

    Is there a Resistor chart or voltage chart available? Case not have you tried with a potentiometer? I mean if you tie a x Resistor to Vdd (or GND) it works?

    If so, there's a thread in here made last week or so.
    Steve

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

  7. #7
    Join Date
    Aug 2011
    Posts
    40


    Did you find this post helpful? Yes | No

    Default Re: PIC 16F877A and RB out

    Normaly, it is a resistor , i tried with resistors .
    There is already voltage in Jack female (behind radio)
    It is a voltage with r2r ,not ?
    a voltage +2v (for example) to +5v , is it right ?

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


    Did you find this post helpful? Yes | No

    Default Re: PIC 16F877A and RB out

    We can produce voltage with R2R or not. It really depend the way we code it. The previous link didn't but tied resistor to GND.

    You need to know which resistor value you need for each function on the radio side. And next step, do you need to tie them between the jack and GND or between the jack and VDD (5Volts). High like ln between the jack and GND. The previous link show and explain how it works.

    Next you just need to play on the remote/steering side. Follow my code, it read AN0 and AN1, then evaluate ONLY AN0 value and jump to some routines.
    Steve

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

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