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

 
#1

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 :

Code:


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



But the command Servo (d0, "stop") donĀ“t 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!

#2

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: http://www.ez-robot.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:

Code:


REPEAT ($pos, 0, 70, 5)

servo(d0, $pos)

IF (GetADC(adc0) <= 180)
halt()
ENDIF

sleep(50)

ENDREPEAT

#3

Will this work Boris?

Code:


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

#4

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

#5

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

#6

Hello Alan!

Ok now i understand this, but one question.

Now i have this script:

Code:



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

if (GetADC(adc0) <= 75) or (GetADC(adc1) <= 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

#7

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

#8

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

#9

I know what you are trying to do now.... Smile 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....

#10

Hello Alan

i made a complete new project and copy the script into this and now it works with the 50ms. Ahhhhhhh Something was wrong!


@Richard yes not only for burning servo, also for holding eggs and not break it!


It works slowly almoust like my idea was, but now the next problem to put the presssure sensors to good positions to the finger where they can get a good pressure! and at which value the servo stops. to weak it stops to early to strong it not stops.



If i have a good result i will inform you.


But first happy new year to all!