Asked — Edited

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

Hello,

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 :


:loop
$CurrVoltage = GetADC(ADC0) 
if ($CurrVoltage <= 180)
servo (d0, "stop")
sleep(300)
endif
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

AND FOR ALL A HAPPY NEW YEAR!

AND BIGGER ROBOTS NEXT YEAR!


ARC Pro

Upgrade to ARC Pro

ARC Pro will give you immediate updates and new features needed to unleash your robot's potential!

PRO
Synthiam
#1  

that's not how servos work. There is a tutorial that explains how servos work in the learn section - it will be an important read. Here's the direct link: https://synthiam.com/Tutorials/Lesson/48?courseId=6

There have been discussions in the forum regarding this question in the past. Here is the most popular answer:


REPEAT ($pos, 0, 70, 5)

  servo(d0, $pos)

  IF (GetADC(adc0) &lt;= 180)
    halt()
  ENDIF

   sleep(50)

ENDREPEAT

#2  

Will this work Boris?


:loop
$CurrVoltage = GetADC(ADC0) 
if ($CurrVoltage &lt;= 180)
servo (d0, $CurrVoltage)
halt()
sleep(300)
endif
goto (loop)

#3  

Hello Richard,

thanx for your idea! It works a little bit.

The biggest problem the reaction time. If i press the Sensor it takes seconds until the script stop.

@DJ what this numbers ($pos, 0, 70, 5) here means

Min Pos/ Max Pos/Speed or what?

Happy new year! Boris

#4  

From the script cheat sheet:

Repeat( variableName, startValue, endValue, increment )

so this script will start a servo at 0, go to 70, in increments of 5 every 50 ms and stop if the ADC reads less than or equal to 180.

Alan

#5  

Hello Alan!

Ok now i understand this, but one question.

Now i have this script:



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

  if (GetADC(adc0) &lt;= 75) or (GetADC(adc1) &lt;= 175)
  
    halt()
    
  endif
sleep(50)


endrepeat



This means:

Start @ 180 End @ 0 in 15 Steps/increments every 50ms

now the question. The Step takes not 50ms - the steps take almoust 1 second each step/increment. Or it means that the ADC check every 50ms?

Is this correct?

Boris

#6  

It should be doing both every 50ms, but if your servo is moving slowly, you may have a servospeed() in another script that has slowed it down.

Alan

#7  

Hello Alan,

no i have extra a script for servoSpeed (d0, 0) what i run first.

On a normal servo position ( servo d0, 5) the servo runs his fastest speed.

Now i was also thinking every 50ms ( and 50 ms seconds its really fast - not a second or more)

Boris

#8  

I know what you are trying to do now....:) This is for your inMoov's hand so he can grasp an object, sense his grip so as not to burn his servos out... Good idea man... Too bad there isn't an easy way to read the current the servos are using... That way you can stop the servo before it would normally over stress and burnout....