Welcome to Synthiam!

The easiest way to program the most powerful robots. Use technologies by leading industry experts. ARC is a free-to-use robot programming software that makes servo automation, computer vision, autonomous navigation, and artificial intelligence easy.

Get Started
Asked — Edited

Servo (Stop) / Servo "Stop" - How To Stop A Servo At A Specific Adc Value


i have one ( i hope easy) question.

i have a pressure sensor.

Work fine on the ADC!

Now i have one problem.

If the value for the ADC port is under 180 the servo must stop ( hold his position)

my idea of a script :


$CurrVoltage = GetADC(ADC0)
if ($CurrVoltage <= 180)
servo (d0, "stop")
goto (loop)

But the command servo (d0, "stop") dont exist

So with command i can take what tells the servo he must stop and HOLD his position.

Thanx a lot for helping




Upgrade to ARC Pro

Synthiam ARC Pro is a cool new tool that will help unleash your creativity with programming robots in just seconds!

Only getadc() one time, otherwise it's needless queries to the ez-b. Also, the IF statement is redundant because it will always be below 175.

My initial example was the best so far. Simply change the REPEAT to have the max and min values of the gripper.
DJ, he is looking at the value of two different ADC ports, and if either value is true he wants the script to halt. I think the script is correct. Am I missing something that you see, or did you miss that it is two different adc ports with two different thresholds?

@DJ it works fine with two ADC ports

@Alan You are right!

Hello Boris;

I get what is trying to be done, but I'm not sure I understand the programming part of the problem correctly, so I'll ask some questions.

Are there two separate scripts running? That is, one script which is making the servo move however it should, and a second script that is monitoring the pressure sensors voltage? Then, when the voltage drops below 180 (or whatever) the second, "stop" script, stops the servo and the servo then holds the position it has at the moment it is stopped?

Also, is the stopping script supposed to stop the servo even if it is currently moving due to being sent a servo() command (or whatever) to make it move? In other words, let's say the command Servo(D4, 155) is sent, and the servo is slowly moving to the 155 degree position, is the stop script supposed to stop it dead before it gets to 155?
Hello WBS00001!


Long time not hearing from you! I am happy to see you again!

To you question.

Yes it will be the best if i will have a monitoring script to check out which value the ADC ports have and when the value reach his point the script will stop the servo.

To understand here is a photo from my Inmoov Palm with the first finger who has 2 pressure sensors.

User-inserted image

DJ Script works, but first problem the move is not smooth, because the servo moves now in 15 steps every 50ms and this is not smooth! And the second problem, its better to have a monitoring script, now i must copy the DJ Script in every moving script for the fingers what i have.

I hope this explains what i want to do.

Hey Boris... try slowing the servo down instead of "stepping" it...

EDIT.... On second thought never mind my idea won't work
Hi Richard!

Happy new year!

How i slow down the servo in DJ´s Script?


repeat ($pos, 180, 0, 15 )
servo(d0, $pos)

if (GetADC(adc0) <= 75) or (GetADC(adc1) <= 175)



@Boris... Could you use the release command and a slow moving servo .... although releasing a servo means resetting servo speeds again.....


servospeed(D0,3) # slowly close hand... lower is faster, higher is slower
servo(d0, $pos)
if (GetADC(adc0) <= 75) or (GetADC(adc1) <= 175)

Hello Richard!

And from where the Servo/the variable knows to move to which position?

($pos, 180, 0, 15 )



Or work your script like a monitoring script (i am not near my Inmoov)
@Boris.... You give $pos any value you want for example...


$pos = 30 #closed finger

servospeed(D0,3) # slowly close hand... lower is faster, higher is slower
servo(d0, $pos)
if (GetADC(adc0) <= 75) or (GetADC(adc1) <= 175)

Hi Richard,

i understand now!

I will try in 2-3 hours, then i am back!


PS. And then i tell you if it works!
Hello Richard,

sorry it not works. If the value for the ADC is under the servo release not HOLD the Position! So this means if the Hand will hold something it will fall down.

The servo must hold his postions!

The best way until now is still the way from DJ!

Boris, no one can give you the complete solution catered to your application. We can only lend a hand and provide the template for you to work from. It's up to you to learn from the examples we provide. Keep at it and it'll come together for you:)
Hello DJ!

Everything OK! I never was thinking to get a completer Robot!

Thats why i am asking! Do you know "Sesame Street"? Who not ask, will stay stupid!

Again Everything ok, you understand something wrong! Relax!

Hello again Boris, and a Frohes Neues Jahr. to you as well. :)

The basic problem here is that there seems to be no way to stop a servo (and get it to hold position) once it has been given the command to move to a certain position. This is why the solutions given have all involved a loop that tests the status of the pressure sensor as the hand is closed one small step at a time.

So, it seems to me the best way to do this would be to call a "Close Hand" script to make the hand close via a CommandControl instruction. Something like this:


ServoSpeed(D0,5) #Set to whatever you want
CC("Close Hand",ScriptStartWait, "Hand Close" )

"Close Hand" would be the name of a Script Manager which contains the "Hand Close" script described below. But you could put it in any script manager you wish.

Then the "Hand Close" script would be something like the ones already shown. My own would be:


ServoUp(D0,1) #Close the minimum increment
if (GetADC(adc0) <= 75) or (GetADC(adc1) <= 175)
Goto(TheExit) #Stop and hold at this point


The Sleep(20) statement may not be needed at all. You could try it with and without it in there. Or at least play with different values of sleep.

I have tested this with a JD claw, but I don't have a pressure sensor so I don't know how well it will work with the hand.
Hello WBS00001,

i check you script and it works a little bit better then from DJ (smoother, but still not the best)

But i found out the problem. If i run you script without the ADC check, the finger moves best off! If i let check the ADC Ports the finger will move not so smooth.

So its the reaction time of reading the ADC, who is not the best. I think at this point nobody can make it better.

I am not lucky with the choppy/juddery way of closing the fingers, but on other hand i think its a soloution for a not profi Home-Robot-Builder.

If someone has a idea, to maybe source out the ADC reading or else, i am open everytime for new tests!


PS: I will got some new servo for the Hand and more pressure Sensor. If i finish one Hand i will post a video.
Sounds like the issue is with the read of the ADC port. Have you tried to adjust how often the port reads the value? I'm thinking two things may be happening;

1. The port is reading too fast and flooding the commutations link.
2. The port is reading too slow and each time it checks the servo needs to jerk forward to catch up to the reading.

I'm not sure that this method will control the speed of the ADC check in EZ scripts that you write but; In each of the 3 ADC port controls there is a interval setting. It's usually set at 500 ms. setting. It's usually set at 500 ms. After adding that control to your project and setting it to the port, try adjusting that up and down.

There may be other ways to get the ADC port to check values at different intervals. The repeat script command comes to mind. It has a interval setting.

Also, I've found if you leave these ADC controls running and checking ADC status they will slow down your system. Keep them paused till you really need to see performance.

Just some random thoughts on a couple things to try. Good luck.
I've been working on a ADC issue all day today. It's somewhat similar to yours. I'm trying to stop a motor through EZB's UART port with a opto switch that's attached to an ADC port. I've tried all the suggested scripts and still wasn't satisfied with the responce. Nothing seemed to act fast enough. Couldn't get a good balance between speed and ACD readings.

Anyway, I found that using the ADC_Wait gave me the best responce and got everything working smoothly.


ADC_Wait (adcPort, higher/lower/equals, value, [delay ms])
Wait until ADC port is higher or lower than specified value
The optional parameter Delay MS is the millisecond delay for checking. This value determines the delay between checks.
Example: ADC_Wait(ADC0, HIGHER, 50)
Example: ADC_Wait(ADC0, HIGHER, 50, 50)

Here's another one that may work for you:


ADC_Wait_Between (adcPort, low, high, [delay ms])
Wait (pauses script) until ADC port is between the specified values. Soon as the ADC port is between the low and high values, it will stop waiting.
The optional parameter Delay MS is the millisecond delay for checking. This value determines the delay between checks.
Example: ADC_Wait_Between(ADC0, 20, 50)
Example: ADC_Wait_Between(ADC0, 20, 50, 50)
Hi Boris;

I don't understand what the difference in the results using the Inmoov hand and my tests using JD's claw. In my tests the claw closes smoothly while checking ADC0 and ADC1 in the test loop. Are you moving several servos to close the Inmoov's hand or just one? Do you have other things running at the same time that may actually be causing the problem? You may want to make a new test project with just the hand closing script in it to see if it runs smoothly then.

Running speed trials, I see it takes a bit less than 14ms to execute a GetADC instruction. A little less than 27 ms to execute the test statement (GetADC(adc0) <= 75) or (GetADC(adc1) <= 175) checking the two ADC ports. That should be plenty fast enough for smooth hand closing.

Are you using the latest version of ARC? JD has recently made changes that make the script execution much faster?
Hello WBS00001,

NO, i use a complete new clean Project, no other scripts are running.

I think i will make a video, then you can see more.

But that you got a smooth closing with you JD claw, brings me again a little bit hope!

I will check tommorow afternoon and i will report you.

Thanx for your Help!

@Dave yes i am also not lucky with the speed from the ADC port! I will also check your scripts and i will report.