need some help with servo programming
b0ib0i07
Posts: 33
currently using BS2 and hitec HS-815BB servo.
do
pulsout 14, 900
loop
the servo moved. however its so slow....
any way to move it faster?
do
pulsout 14, 900
loop
the servo moved. however its so slow....
any way to move it faster?
Comments
pulsout 14, 900
pause 20
next
for b0=1 to 200
pulsout 14, 500
pause 20
next
goto a
thank you for the code you gave me.
can you explain to me the code please?
The problem with your original program fragment is that servos need a control pulse 50 times a second, not faster (it can't respond to it properly) and not slower (it will shut off if it doesn't get a control pulse). The PAUSE 20 provides the timed delay to make this happen.
Required Pulse: 3-5 Volt Peak to Peak Square Wave
Operating Voltage: 4.8-6.0 Volts
Operating Temperature Range: -20 to +60 Degree C
Operating Speed (4.8V): 0.48sec/140° at no load
Operating Speed (6.0V): 0.38sec/140° at no load
Stall Torque (4.8V): 274.96 oz/in. (19.8kg.cm)
Stall Torque (6.0V): 343.01 oz/in. (24.7kg.cm)
Operating Angle: 70 Deg. one side pulse traveling 400usec
360 Modifiable: Yes
Direction: Clockwise/Pulse Traveling 1500 to 1900usec
Current Drain (4.8V): 8mA/idle and 700mA no load operating
Current Drain (6.0V): 8.7mA/idle and 830mA no load operating
Dead Band Width: 8usec
Motor Type: 3 Pole Ferrite
Potentiometer Drive: Indirect Drive
Bearing Type: Dual Ball Bearing
Gear Type: All Heavy Duty Nylon Gears
Connector Wire Length: 11.81" (300mm)
Dimensions: 2.59" x 1.18"x 1.26" (66 x 30 x 57.6mm)
Weight: 5.6 oz. (152g)
Above are the info i have on this servo.
I do have a question.
Is the board of education able to supply the current needed by using the board Vdd and Vss to power up the servo?
Meaning i connect the servo red wire to Vin and black wire to Vss?
But, i am using a 9V battery instead...
By the way, just to ask. How much current can a 6V battery pack supply?
Depends on the type of cells you are using. For example, the alkaline AAs from a major manufacturer are rated to deliver about 2800 mAH. That is 2800, milliAmps for one hour. For a few minutes, they can deliver a lot more, but then they wear out much faster.
Unloaded, your servos draw 830 mA, so if you are running one servo continuously, and nothing else, you'd get about 3 hours of run time (3 x 830 = 2490mAH) and loosely accounting for the current drawn by your board as well. Under load, they would draw more.
Assuming you are running two continuous rotation servos to drive a robot, they would be under load, so they would draw more current, maybe up to an Amp (1000mA), so estimate an hour of run time on a pack made from four AA alkaline cells before things start to slow down.
Switch to recharge-ables and you get a little less runtime. NiMH cells deliver between 2000 and 2600 mAH, depending on how much you are willing to pay for them, and how many charge/discharge cycles you expect them to last. They last longer if you study the charge characteristics, track how much of their capacity they have used, don't push them to the limit, and refrain from over-charging, or over-heating them.
Tracking the performance of rechargeable batteries and better managing them is actually one of the data logging tasks that got me interested in micro controllers in the first place. I wanted to measure and log the current being drawn by all of the devices in a model airplane over the course of a morning at the flying field and then compare the current "consumed" to the factory specifications of the battery, then use this information to optimize battery charging. I wanted to see if there was an appreciable change in the service life of the batteries compared to the standard model airplane practice of "charge them over night before flying and then discard them after they've been used 200 times, or every 2 years, whichever comes first".
But then I got interested in robotics and haven't flown the planes for a couple of years...
thank you very much for the info :smilewinkgrin:
a:for b0=1 to 200
pulsout 14, 900
pause 20
next
This above code does allow me to move the servo to my desired position. However, after a while, the servo begins to "jerk" off from my desired position.
From my knowledge of servo, a continuous pulse is needed to hold the position of the servo. Can i assume that this condition is happening to my servo as it had exited the for-loop?
If that is so, is that any way to hold the servo in a certain position?
I am not sure you really have to hold to 20 mS in the above pause - maybe 18-19 mS would be better as the TOTAL pulse cycle is suppose to be 20 mS. Sorry but I disagree with Mike Green.
My idea is to move the servo to the position i want then hold the position while my program continue to execute the other command.
Is this possible?
@b0ib0i7, You're right, you have to loop to hold position just like you have to loop to move. You don't have to pause in the loop, you could always do something else during that time. Maybe poll an input? Did you look at the link provided by Mike Green?
If the polling logic is too much, I suggest picking up a, Parallax Servo Controller to handle servo control.
I got what u meant. Thanks for the help. I will try it out. =]
Hi Mike Green
I would like to clarify something with you as you are more exeperienced with servo. From the above, u told me that the servo wil shut itself off if no pulse is sent. I enter the code as shown below:
FOR a = 0 to 100
PULSOUT 14, 600
PASUE 20
NEXT
The servo moved to the specified position. However, after the servo exited the for-loop, the servo begin to jerk clockwise slowly.
May i know what is causing it to jerk?