We are trying to control a servo using a potentiometer and basic stamp but cannot find any Basic Stamp programming that would allow to do so. Any suggestions?
Look in the Stamp help file under RCTIME. A sample circuit is shown there to allow the Stamp to read the position of the pot.
You'll have a value ranging from near zero to about 4000, with the components shown in the example, if I remember correctly. Don't forget to use a Word-sized variable.
Then look in the Help file under PULSOUT.When the pulsout value is 500, the servo will be at full rotation in one direction, when its 750, it will be centered and when its 1000, it will be full rotation in the other direction.
All your program has to do is read the pot, scale it to be between 500 and 1000 and send that value out with the PULSOUT command. The command has to resend its value every 20 mSec or so by having the program loop around again.
I have done more or less the same as a training exercise. The potentiometer wiring and code are borrowed from Chapter 4 of the Robotics v 1.5 Student Workbook (hard copy came with my BoEBot) and the servo I used was an unmodified Futaba compatible, attached to the spare servo port as pin 14. Unless I messed up taking out some extraneous sound generating code this attachment works. You may need to alter some multipliers to agree with the values for your pot and servo. Trial and error. What I wanted was to get the full travel of the servo arm with a full rotation of the potentiometer. Good luck.
Moonman If you realy want to learn about Pots and servos I reqemend getting the "Whats a microcontroler" It teachs you about Pots and servos. I read your post talking about controllering a servo with a Pot, Now I reqEmend useing a 10K pot, I also read that you are use a contuiss rotation servo, THIS WILL WORK BUT, it will just turn the direction, you can controlle the speed also with the pot. I was·just was experimenting with Pots and servos, I made a laser cannon, that you could controlle with two Pots. It turned the laser pointer around. I have souce codes for you, and I will send you a discrption about the circut tomorrow, its very simple,· its prety straight forward.
Comments
Then you can move the servo based on the RCTIME.
If you need more help with this, let us know.
Look in the Stamp help file under RCTIME. A sample circuit is shown there to allow the Stamp to read the position of the pot.
You'll have a value ranging from near zero to about 4000, with the components shown in the example, if I remember correctly. Don't forget to use a Word-sized variable.
Then look in the Help file under PULSOUT.When the pulsout value is 500, the servo will be at full rotation in one direction, when its 750, it will be centered and when its 1000, it will be full rotation in the other direction.
All your program has to do is read the pot, scale it to be between 500 and 1000 and send that value out with the PULSOUT command. The command has to resend its value every 20 mSec or so by having the program loop around again.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tom Sisk
http://www.siskconsult.com
·
parallax.com/Portals/0/Downloads/docs/books/edu/wamv2_2.pdf
Page 153, activity #4 .... but I'd encourage you to read the entire book starting at the beginning if you are new to micro-controllers.
What size is your pot?
Is your servo standard or continuous rotation?
Did you get you components from a parallax kit or did you buy them elsewhere? (that'll help answer questions 1 and 2).
Did the previous suggestions help you enough or do you still need more info?