Division by non-integers
I am using the operators "**" and "*/" to enable me to multiply by numbers with decimal points. Can't find anything that will let me divide by numbers with decimal points. My Boe-Bot pivots·right 90 degrees fith the following subroutine:
·· PivotRight:··· 'pivot Boe-Bot 90 degrees to the right
· FOR counter = 1 TO 13
··· PULSOUT 13, 850
··· PULSOUT 12, 850
··· PAUSE 20
· NEXT
· PAUSE 200
· RETURN
Doing the math that means I get 6.92 degrees of rotation for each pulse. I want to replace the 13 in the FOR statement with a variable who's value can be set prior to calling the subroutine so I can get other than just 90 degrees of rotation. Would someone please help me with this task? I am using a BS2 processor and PBASIC 2.5. Thanks you.
·· PivotRight:··· 'pivot Boe-Bot 90 degrees to the right
· FOR counter = 1 TO 13
··· PULSOUT 13, 850
··· PULSOUT 12, 850
··· PAUSE 20
· NEXT
· PAUSE 200
· RETURN
Doing the math that means I get 6.92 degrees of rotation for each pulse. I want to replace the 13 in the FOR statement with a variable who's value can be set prior to calling the subroutine so I can get other than just 90 degrees of rotation. Would someone please help me with this task? I am using a BS2 processor and PBASIC 2.5. Thanks you.
Comments
But you will find that hobby servos will not give you the precision you seem to be expecting. I would recommend you investigate encoders if you need to stay with servos or perhaps stepper motors.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- Stephen
Say you want to move 47 degrees. Then the variable would be 47 * 0.145, or on the Stamp,
As Stephen pointed out, the precision is not good. Maybe there is something mechanical that can make the steps smaller, say, by running the servos at 800 instead of 850.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tracy Allen
www.emesystems.com
See Help for "FOR"
FOR Counter = StartValue TO EndValue {STEP StepValue} ... NEXT
EndValue is a variable/constant/expression* (0 - 65535) that specifies the end value of the variable (Counter). When the value of Counter is outside of the range StartValue to EndValue, the FOR...NEXT loop stops executing and the program goes on to the .....
·