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

Take control of your robot's destiny by subscribing to Synthiam ARC Pro, and watch it evolve into a versatile and responsive machine.

#25  

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(&quot;Close Hand&quot;,ScriptStartWait, &quot;Hand Close&quot; )

"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:


:CheckADCPort
  ServoUp(D0,1) #Close the minimum increment
  if (GetADC(adc0) &lt;= 75) or (GetADC(adc1) &lt;= 175)
    Goto(TheExit)  #Stop and hold at this point
  endif
  Sleep(20)
  Goto(CheckADCPort)

:TheExit

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.

#26  

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!

Boris

PS: I will got some new servo for the Hand and more pressure Sensor. If i finish one Hand i will post a video.

#27  

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.

#28  

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)

#29  

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?

#30  

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.

Boris