Community Question

@DJ and team.

I give a small request that I hope you would consider adding to EZ-Script.

Would it be possible to add a new script command for servostop()? I'm not talking about the one the one that already exists for modified servos, but for standard ones (more like a stopservo() or possitionstop() command). The idea is to add this for things like controllers and joysticks.

E.g, you have a servo which has a centre possition of 90, and a set max possition of say 160, and a set speed of 2. When a button is pressed on a controller the servo starts to move from 90 towards 160, but if you release the button the servo stops in its current possition and stays there. Press the button again and it continued to travel towards 160, or back to 90 by pressing another button.

I'm aware that there are ways to write a script for this, but I've had a lot of trouble with it so far, and having a simple script command in the script menu would make things so much easier. Would it be something that you would consider adding? And if there is a command to do just this, then I apologise in advance and would appreciate someone informing me of what script command to use.

Thanks,
Steve.
thetechguru
Commented November 2014
I was just discussing monitoring how tight the claw was closing using an ADC port. He said the best way would be to open the servo and get resistance from the pot, but that monitoring the ground wire for power spikes would probably also work.

Added to my project list.

Alan
Rich
Commented November 2014
@Steve, you're welcome. Hopefully the scripts and explanation make sense and help you understand what's going on :)

@Alan, these work well on the ADC ports, I use a few in my projects. Melvin monitors one for the current to the drive motors so that if he gets stuck it is detected, he also has one for the EZ-B to monitor power being drawn by the EZ-B and connected devices.

They also do an I2C version which looks like it'll work well but I've not used it yet.
VGosine
Commented November 2014
@Steve to get the buttons to move the servo when held down and then as it is released the servo stops you can create two scripts:

Code:


:loop
if(GetServo(D0)<150)
ServoUp(D0,1)
endif
sleep(100)
GoTo(loop)


and

Code:


:loop
if(GetServo(D0)>75)
ServoDown(D0,1)
endif
sleep(100)
GoTo(loop)


and then in the joystick control when the button is pressed down run

Code:


ControlCommand("Script Manager", ScriptStart, "Move Servo Up")
#and
ControlCommand("Script Manager", ScriptStart, "Move Servo Down")


and then for when the button is released you run

Code:


ControlCommand("Script Manager", ScriptStop, "Move Servo Up")
#and
ControlCommand("Script Manager", ScriptStop, "Move Servo Down")


So i've tested this method and it seems to work but you may have to adjust the increment you want to increase by as well as the sleep command in the movement scripts

Steve G
Commented November 2014
@Vgosine.

Thanks
for your response. I appreciate it. I'm golden now. :)
VGosine
Commented November 2014
Awesome :) I'm glad to help out
Question
AvatarSteve G
Asked on Wednesday, November 12, 2014