Radio Controlled Digital Pot
crgwbr
Posts: 614
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
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.
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.
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.
RcPin PIN 15
time VAR Word
DO
PULSIN 0, 1, time
time = time/8
DEBUG ? time
LOOP
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.
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