Looking for a little help.
Hello, new to this whole BASIC thang...
I am sure that somewhere in the great information superhighway this exhixts:
I am looking for a code that accomplishes this:
I am looking to control a servo (I have a Basic Stamp Home Work Board and servo assembled as specified) I would like to assign the keys on my keyboard to have a value (percentage) of servo movement (i.e., pressing the "G" key would move the servo let's say 7% and "H" would move it 8% etc., etc.) I am sure that a someone had created a BASIC code that acheives this I just am ignorant as to where to look.
Any help in finding (or writing) this would be most helpful!
Thanks in advance!
Scott
·I just like this little guy!
I am sure that somewhere in the great information superhighway this exhixts:
I am looking for a code that accomplishes this:
I am looking to control a servo (I have a Basic Stamp Home Work Board and servo assembled as specified) I would like to assign the keys on my keyboard to have a value (percentage) of servo movement (i.e., pressing the "G" key would move the servo let's say 7% and "H" would move it 8% etc., etc.) I am sure that a someone had created a BASIC code that acheives this I just am ignorant as to where to look.
Any help in finding (or writing) this would be most helpful!
Thanks in advance!
Scott

Comments
·· Are you trying to do this from a keyboard, or from the PC itself?· If from the PC you would need some software on the PC side as well to handle key presses and send them to the BASIC Stamp, unless you used the DEBUG window.· In any event it's basically a matter of inputting the keystrokes via SERIN and having a small lookup for the key value that correlates to a PULSOUT value.· You could also achieve your servo delay using the timeout on the SERIN.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
csavage@parallax.com
Thanks again, I really appreciate it!
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
csavage@parallax.com
I appreciate the help, thanks agian!
a servo needs a pulse every 20 ms. That pulse needs to be between 1 and 2 ms in width. 1 ms pulse is full counter clockwise and 2 ms pulse is full clockwise. Look at the timing for PULSOUT for the stamp that you have. IT is IMPORTANT that you realize the timing varies from one stamp to the next. Use DEBUGIN to read your letters from the keyboard, when the letter = X ( insert your letter here) Pulsout to the servo the appropriate pulse width in microseconds to the servo. Use the help function in the PBasic editor to study FOR... NEXT, PULSOUT, DEBUG and DEBUGIN . This should help you get started. You can do this.
Servos do in fact need to be refreshed if they have not yet arrived at the desired position, and to maintain position (actively) if the position has already been reached.
There are newer servos that have different timing/resolution needs, be aware of that.
Ryan
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Ryan Clarke
Parallax Tech Support
rclarke@parallax.com
'Homework Board and Parallax Standard Servo. This program moves a servo via a computer 'keyboard using the DEBUGIN command. Developed by RoboRookie 9-7-05 '{$STAMP BS2} '{$PBASIC 2.5} counter VAR Word KeyIN VAR Byte 'Define KeyIN as a variable FOR counter = 0 TO 30 'Center servo to position 750 PULSOUT 15, 750 PAUSE 20 NEXT DO DEBUGIN KeyIN 'Prompt for user key input. SELECT KeyIN 'Match the contents of KeyIN to match one of the CASE conditions. CASE = "x" 'If KeyIN = "x" then execute FOR NEXT loop FOR counter = 1 TO 30 'Change vale 30 to a higher number to allow servo enough time PULSOUT 15, 1200 'to pulse to proper position. The higher the number, the slower PAUSE 20 'the response to user key input. 30 seems to work best with NEXT 'the Parallax Standard servo with the Homework Board. CASE = "y" 'If KeyIN = "y" then execute FOR NEXT loop FOR counter = 1 TO 30 PULSOUT 15, 280 '15 = I/O Pin #15, 300 = servo position. PAUSE 20 NEXT CASE = "s" 'Center servo FOR counter = 1 TO 30 PULSOUT 15, 750 PAUSE 20 NEXT CASE = "q" '"Quit" - Exit DO LOOP and END program END ENDSELECT LOOP
Post Edited (RoboROOKIE) : 9/7/2005 11:29:52 PM GMT
Thank you so much for your help! I'll go check it out right now!