richardghirst / PiBits

819 stars 565 forks source link

Servo moves full range before allowing other movements #70

Open kc0hwi opened 8 years ago

kc0hwi commented 8 years ago

I am controlling servos with servoblaster via html+webiopi for a robot.

Python Example:

@webiopi.macro def Shoulder_Up(): cmd = 'echo 3=-10 > /dev/servoblaster' os.system(cmd)

However, the servos will not move until I first click a button that corresponds to the -10 increments as shown above (it will not initially move in the + direction) . That first movement always moves the servo in the - direction to it's minimum. After which, I can finally move the other direction and back again in those 10 width increments. It only does it the first time the servo(s) are moved when the webpage is first loaded.

lf- commented 8 years ago

The reason this is happening is likely because servod has no idea where your servos are. It can't tell, because the servos aren't designed to tell the machine where they are, the machine has to keep track of it.

kc0hwi commented 8 years ago

Hmm, so perhaps I could add some "center" buttons on the control page that send something like echo 1=150 and then start from there?

lf- commented 8 years ago

That would fix it. Basically, every time servod starts, you need to send an absolute command before you can use relative commands.