Shop OBEX P1 Docs P2 Docs Learn Events
Radio Controlled Digital Pot — Parallax Forums

Radio Controlled Digital Pot

crgwbrcrgwbr Posts: 614
edited 2006-05-23 18:11 in Learn with BlocklyProp
The robot I am building has dual H-bridges that control the motors.· These are controlled with the Basic Stamp Homework Board by use of a digital pot.· I have a Tower Hobbies radio controll that I would like to us on my robot somtimes.· The radio is designed to controll servos, can I make my BS2 recognize the radio command and controll the digital pots based on it.· If so- how?

Comments

  • edited 2006-05-16 18:38
    You can use the PULSIN command to measure the servo control pulses. The pulses should measure from 250 to 1250, which typically instructs the servo to rotate from 90-degrees clockwise to 90-degrees counterclockwise. This gives you a range of about 1000. If your digital pot has 100 positions, your code might work something like this:

    RcPin PIN 8
    time VAR word
    .
    .
    .
    PULSIN RcPin, time
    time = time/10
    ' add code that uses time to determine the digital pot's wiper position using the time variable.
  • crgwbrcrgwbr Posts: 614
    edited 2006-05-16 18:43
    Thank You
    I'm really new at this, so, my digital pot has 128 positions, so my code would be like this, right...

    RcPin PIN 8
    time VAR word
    .
    .
    .
    PULSIN RcPin, time
    time = time/7.81
    ' add code that uses time to determine the digital pot's wiper position using time.
  • edited 2006-05-16 18:54
    The BASIC Stamp doesn't have floating point math, so you could use:

    time = time / 8

    For 1/7.81, you can use the ** operator. It multiplies by a certain number of 65536ths. The number of 65536ths in 1/7.81 is (1 / 7.81) x 65536 = 8391. So the command you could use to multiply time by (1/7.81) is:

    time = time ** 8391

    For code that controls the digital pot, take a look at What's a Microcontroller, Chapter 9. It's available for download from www.parallax.com -> Downloads -> Stamps in Class Tutorials.
  • crgwbrcrgwbr Posts: 614
    edited 2006-05-16 19:01
    Thank You
  • crgwbrcrgwbr Posts: 614
    edited 2006-05-16 20:06
    I'm using this code to view the pulses, it's not working; I just keep getting time: 0 or somthing like that. What am I doing wrong? To connect the reciever to the BS2, I directly hooked the signal pin into I/O 0. Is that wrong? Please help!

    RcPin PIN 15
    time VAR Word

    DO

    PULSIN 0, 1, time

    time = time/8

    DEBUG ? time

    LOOP
  • edited 2006-05-16 20:38
    I can see two possible problems.

    1) You set RcPin to 15, but you are using 0 in the PULSIN command's Pin argument. Use PULSIN RcPin, 1, time, and make sure that RcPin is declared as the correct pin number. (RcPin PIN 15 if it's connected to P15, RcPin PIN 0 if it's connected to P0, etc.)

    2) Is your Board of Education's Vss connected to the receiver's ground (negative terminal)? This common ground is necessary so that the BASIC Stamp and RC receiver have the same voltage reference.
  • crgwbrcrgwbr Posts: 614
    edited 2006-05-23 18:11
    w00t

    I got it to work, thanks guys!· There were several problems I had to fix, like comman voltage and stuff.· Anyway, I'll atach the code for any one who wants it, its a veriation on the terminal controlled pot in the "What's a microcontroller" text.

    w00t
Sign In or Register to comment.