Shop OBEX P1 Docs P2 Docs Learn Events
Code & Math Help — Parallax Forums

Code & Math Help

MichelBMichelB Posts: 154
edited 2009-11-02 14:11 in BASIC Stamp
Hi all (Parallax staff included), I've transposed on a Board of Education the StampWorks Experiment #26: Hobby Servo Control.
Page 149 it's written: "The value for constant Scale is determined empirically. After constructing the circuit, insert appropriate DEBUG statements to display the raw potentiometer readings from both sides..., etc.".
This exists in the program (#DEFINE _Testing = 1) and gives what it follows:
Pot. pos.···· CW···· CCW···· Center
CW (raw)··· 302······ 1········· 132
CCW (raw)·· 1······ 302········ 132
CW············250····· 0·········· 109
CCW··········· 0····· 250········ 109
Pos·········· -250··· 250·········· 0
Pulse······· 1250···1750······· 1500
Note that Pulse must be divided by 2 in order to create the correct pulse output for the servo, therefore correct pulses are CW 625, CCW 875 and Center 750 giving a range of about +30° to -30° from the center.
It's also written: "Take the lower of two values and divide that into 500 (desired output)."
What "lower" of what "two values"?
Why the desired output is 500?
What I need in my project is a range of +90° to -90° from the center obtained the following pulses:
+90° -> 310, 0° -> 750 and -90° -> 1190.
Page 149 yet we can see in the example:
Raw RCTIME value: 645 Question? In my case (see above) 302? or 2 x 302 = 604?
It seems that the number 645 contradicts the lower of two values 7 lines above.
In short:
i) What value must I consider for raw RCTIME 302 or 604?
ii) What value must I take for the desired output? (instead of 500)
iii) What's about (in this case) MAX 500 ' scale RCTIME to 0-500 in the attached code?
P.S.: There is a little typing error in the example: 250 / 645 = 0.775 must be 500 / 645 = 0.775
Thank you in advance.
Sign In or Register to comment.