Another Way To Auto Release / Restart Servo

 
#1

Last week we had a discussion about buzzing servo and capability to release it without loosing the mechanical position of the assembly.

One of the issue mentioned was the Inmoov head horizontal movement, where the servo might buzz even in standby.

The next script code , I believe could solution the problem.

Code:

SetServoMax(D23, 154 )
SetServoMin(D23,17 )

$Running_Pos=0

:loop
$Present_pos=1

WaitForServoMove(D23 )

####################### RESTART SERVO ########################
ServoUp( D23, 1 )
ServoSpeed( D23, 0 )
sleep(100)
servospeed(D23,5)
Say("on") # Confirm

######################## Check for Servo still mooving #######

repeatuntil($Present_pos = $Running_Pos)
$Present_pos=GetServo( D23 )

Sleep(1000) # as to be long enough for movement to complete

$Running_Pos=GetServo( D23 )

###################### Servo released if not mooving #############

if ($Present_pos = $Running_Pos)
Release(D23 )
Say("off") # Confirm

##################### Loop back to top and check for servo move #######
goto(Loop)
endif

endrepeatuntil



Give it a try and everyone is welcome to make it better.

#2

Once again, nice coding.

I may be wrong but it looks here like the script is looking for postion feedback from the ezb. Since servos don't give feedback information won't the Getservo command give you the last postion sent no matter if the servo is still traveling to it or has already arrived? Wouldn't this throw off the timing of the script? Again, I may be reading this wrong.

#3

Dave,

Like you said ... analog servos don't provide the servo position, but the EZB firmware can track the positions sent to the servo, keep the last value and returned when you call GetServo.

The difference to real hardware position, you can query the servo hardware to know is position (moved outside the software)

#4

Under the hood there is no hardware servo function to control the speed, the ezb firmware/software implements the speed control, keeping a delay and adding steps between the current position and the destination position.

the main issue is releasing the servo while the servo is still being moved by the firmware.

A cleaner solution is the firmware take in consideration the release action versus the user script to control servo by servo if is ready to do a release.

The firmware knows about the release call, knows the servo is in motion, when the motion stops do the release.

DJ ?

#5

Thanks PTP. That's just what I was asking. The ezb does not know if the servo has reached its destination or if it's still in motion. All it knows is that it has sent it there and assumes it will be there the next time a movement command is sent. I wanted to know if this new script works with this fact.

#6

Guys, your right.
This script needs to be rework. It was to simple to be right.

The only way to use it as it is now, is to make the sleep time longer enough to cover the servo traveling time between min and max before releasing it.

Setting a sleep time that long, will certainly be unacceptable when we move the servo for a small value.

Servo will move at full speed to his previous position if it is released too early.

#7

Nice try though. Don't give up. Winky

#8

To effectively use this script it is necessary to be able to know when the servo comes to a stop. This would be done by the use of a pot.

#9

Just a thought:

Since it is necessary simply to know when a given servo has stopped, I wonder if a current sensor on the main power line to the EZB4 might do the job for all servos. To make it work out the easiest, you would need to run a separate power lead wire to the EZB4 itself. It would be that wire that would be monitored.

This idea would be based on the supposition that a servo will be, by far, the largest current draw where the EZB4 is concerned. There should be a noticeable increase in current when any servo is running and, conversely a noticeable decrease when it stops.

Since you know which one is running during that time, a script would automatically know which one to release when the current draw decreases. The only thing would be the holding current. I'm assuming it will still be less than the running current. This would eliminate the need for variable Sleep periods based on estimates of how long it will take for the servo to go to desired position.

A few turns of this separate positive power wire going to the EZB4 wrapped around a hall effects device might work or a very small resistor placed in-line may also work as a sensing point. Likewise, a coil of wire wrapped around the positive power wire itself. There are any number of devices that can be used to detect current flow. An A-D converter input can be used to monitor the level.

So a looping script could go like this:
-Set a variable to the number of the servo that is to be moved.
-Start the servo moving.
-Begin a loop monitoring the AD port.
-When the AD port value goes back down, break out of the loop
-Use the variable to release the appropriate servo.

A Command Control call can be used to handle all the details. You would still have to set the variable before using the CommandControl, however.

#10

@WB, that's a very cleaver idea. It's one I'd love to experiment with. I can see how this would work well with one servo starting and stopping. However things may get very messy and completed with many servos of different sizes and load demands moving about. Any ideas on how to script for that kind of dance? Smile