Servo to Pot problem
AIman
Posts: 531
Hey all,
I am working on a code that requires a pot to control a servo, so I went back to whats a microcontroller and started toying with the program on page 152. Here is my exact code
However, the servo goes back and forth without anything happening. I tried adujusting the time values on both ends and didn't get anywhere - after much toying I got the servo to move a little and then it started simply staying stationary once again and going back and forth in place.
Since this is modular to a bigger program I set up the schematics exactly as shown in WAM as a thought it would remove problems, however the same results occurred. (See pages 147 and 110 for schematics)
All connections have been checked and rechecked. The pot location has been checked several times (meaning the knob location has been repeatedly changed) and the pot itself was removed and reinserted. The servo connection is tight, the power is from a wall adapter and nothing is connected but an LED and the servo.
This started after checking the pot was double checked for connection.
Any ideas?
Post Edited (AIman) : 1/31/2007 6:30:12 PM GMT
I am working on a code that requires a pot to control a servo, so I went back to whats a microcontroller and started toying with the program on page 152. Here is my exact code
' {$STAMP BS2} ' {$PBASIC 2.5} time VAR Word DO HIGH 7 PAUSE 10 RCTIME 7, 1, time time = time */ 185 time = time + 500 DEBUG ? time PULSOUT 14, time LOOP
However, the servo goes back and forth without anything happening. I tried adujusting the time values on both ends and didn't get anywhere - after much toying I got the servo to move a little and then it started simply staying stationary once again and going back and forth in place.
Since this is modular to a bigger program I set up the schematics exactly as shown in WAM as a thought it would remove problems, however the same results occurred. (See pages 147 and 110 for schematics)
All connections have been checked and rechecked. The pot location has been checked several times (meaning the knob location has been repeatedly changed) and the pot itself was removed and reinserted. The servo connection is tight, the power is from a wall adapter and nothing is connected but an LED and the servo.
This started after checking the pot was double checked for connection.
Any ideas?
Post Edited (AIman) : 1/31/2007 6:30:12 PM GMT
Comments
One other thing -- the Servo PULSOUT does need to be repeated every 20 mSecs -- I don't know if that is guaranteed by your current approach.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- Stephen
% = Value#1 * 100 / (Value#1 + Value#2)
Now that you have a·percent value that can be used as a common·denominator, you can apply the PULSOUT command
PulseWidth = ( (% from above) * 10 ) + 1000
This method will also compensate for any temperature drift.
Edit:
With the attached image, Set I/O #2 to an·OUTPUT LOW and set I/O #3 to an INPUT.· Read the value of "R" using RCTIME (State Mode = 1) from I/O #1.
Next, Set I/O #2 to an·INPUT and set I/O #3 to an OUTPUT LOW.· Read the value of "R" using RCTIME (State Mode = 1) from I/O #1.· Use the two returned
values in the formula above.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Beau Schwabe
IC Layout Engineer
Parallax, Inc.
Post Edited (Beau Schwabe (Parallax)) : 2/1/2007 7:22:01 AM GMT
The times the problem occurs is ONLY when the values from WAM are adjusted to get the servo to move in a bigger arc. Once different values are entered to problem comes up again.
Beau,
I will give it a shot, right now the servo moves about 20% of the available movment.
I wonder if you could explain the difference between your three pin reading of a pot to control a servo and the two pin version in "stampworks" experiment 26 - page 146? What is the advantage of your technique?
Thanks,
Carlos Ferguson
Good question! Both circuits perform a ratio metric reading of the potentiometer. The main difference is that the above circuit uses only one capacitor. As a result any "would be differences" due to component tolerances and or mismatches are now completely negated. Using one capacitor directs any differences to the sensing element (the potentiometer). This includes any effects that are caused by ambient temperature.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Beau Schwabe
IC Layout Engineer
Parallax, Inc.
The code used to calculate the servo signal in these two methods is different as well. This is from the Stampworks example:
rcRt = (rcRt */ Scale) MAX 500 ' scale RCTIME to 0-500
rcLf = (rcLf */ Scale) MAX 500
sPos = (rcLf - rcRt) ' position (-500 to 500)
pWidth = (Center + sPos) ' finalize pulse width
Is there an advantage to your percentage approach? It seems like you would be stepping by 10 with your formula -
percentage*10+1000 - is this not a problem because it is a fine gradation?
thanks for your help,
Carlos
There is nothing wrong with the method used in Stampworks. My use of percentage stems more from a programming style
that I tend to implement more than anything else. I generally take a modular programming approach and like to "encapsulate"
a function when I have something that works. Using a common denominator output such as percentage (0-100) makes
interfacing to another module easier and I don't have to "re-think" as much about what goes on inside the module if I decide
to use the same module for something else down the road.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Beau Schwabe
IC Layout Engineer
Parallax, Inc.
Carlos