Canada
Asked — Edited

Adc Help - Uggg Frustrated

Hey All,

Trying to tweak my dome control scripts.

My Hot Pot potentiometer outputs a number from 0-212 on ADC7

Here is a few variations of the script I'm trying to use.

My main goal is to have the dome spin and stop on or close to the number I desire.

There is some momentum delay to stop but I can work that out.

Here are the scripts snipped from my main scripts Notes Added for clarification.

:CenterR
$DomePosition=GetADC(adc7)
ADC_Wait(adc7, EQUALS, 106) *Dome Center is 106*
Servo(D3, 50)   *Sets servo Control for Syren10 Full Stop*
Sleep(500)
Release(D3)
$DomeDirection=3 *Control Variable*
$DomeServo=50 *Control Variable*
Goto(Stop)

I've also tried with a little more luck.

:CenterR
$DomePosition=GetADC(adc7)
ADC_Wait_Between(adc7, 104, 107) *Dome Center is 106*
Servo(D3, 50)   *Sets servo Control for Syren10 Full Stop*
Sleep(500)
Release(D3)
$DomeDirection=3 *Control Variable*
$DomeServo=50 *Control Variable*
Goto(Stop)

The ADC_Wait never seems to catch the reading from ADC7 the first go around. I'm lucky if it catches it on spin 2 but sometimes it goes 3-4 times around before it catches it.

What am I doing wrong?

Am I going about this all wrong?

Suggestions? Cookies? Beer?

Kris


ARC Pro

Upgrade to ARC Pro

Discover the limitless potential of robot programming with Synthiam ARC Pro – where innovation and creativity meet seamlessly.

PRO
Synthiam
#1  

The Speed of the dome might me too quick. Is it connected to an hbridge? If so, try slowing it down and see what the test results are. Slowly start speeding it up and until it begin missing again.

Canada
#2  

Prior to running this script it ramps down to the slowest speed possible. Still misses the mark quite often.

I have a script that I can run to monitor position and at full speed it can keep up and show the dome position accurately.

Just seems like the ADC_Wait / ADC_Wait_Between are "sleeping" and missing their mark.

#3  

Sorry for your frustration. To the best of my knowledge finite control using a pot and a dc motor is not possible with EZ-Robot. Here's my theory: The only limitation of EZ-Robot that I have encountered is that it is based on client server architecture. As most programmers know that is frequently the slowest method of negotiation between two software programs. You need at minimum millisecond response time between the EZ-B and ARC for precise motor control. Your EZ-B communication is handled most likely using the Bluetooth stack and your windows environment. This setup is likely to induce small delays as there are a variety of factors competing for time in the control stack.

When I asked a very similar question to this one, a couple of weeks ago, in regards to controlling a MR. Clock Radio modded robot head the only response I received was that a servo controllers somehow needed to be hacked/wired to the DC motors and pots. There was no additional instruction or documentation on how to accomplish this. The idea was at best described vaguely in a causal non-technical approach.

So for the sake of brevity, the best advice I can give when using dc motors, pots and the EZ-B: Abandon all hope ye who enter here. Use a servo ;)

Should you continue down the low road, see this code for additional insights:

https://synthiam.com/Community/Questions/3777

Canada
#4  

LOP,

DJ was discussing the possibility of using the pot with a servo controller board and an H-Bridge to make a giant servo like setup.

I'm going to go back and review that thread. My only issue was using an H-Bridge, I wasn't quite sure if my Syren10 would work with what he described.

I'll tinker and see what I can come up with.

#6  

Hey Lumpy,

I wish I had more time to spend with you on this but lots of family stuff going on right now. I'll try to help as mush as possible and I'll have move time this weekend if you need.

I was having this exact same problem. I could not get my DC rotation motors to stop at a stated point using ADC feedback of a pot. Any method I tried in a script of trying to stop at an exact point failed. It would shoot right past where I wanted to stop most of the time. So here's what I did with both the waist and radar section on my B9. I used math and a spread of the pots output numbers so if it would pass the given variable by a few points it would still stop. I know this is not an exact and finite stopping point control but I'm OK with the outer stopping places being close. The only real place I wanted them to stop almost exact way on center (looking forward) and that was even OK to be a little off. Anyway, I wrote a movement script (with help from others on this forum) that would receive a variable number that represented a stopping point on my turning radius. The variable number would be read from the pot connected to an ADC port. Then I could write another script that would send that variable or and number of variables and I would get my rotation animation. Now for the centering of the motors I would have a centering script that could be run that would move the motors to center no matter where the rotation stopped along the radius. I usually send the centering script twice with a sleep command between them just incase it doesn't end up centered the first time. Sounds complicated but it's really simple and works great. So here is an example of the movement script:


#This script will move the waist to any
# point on the radious. The script that calls this needs to use 
# $adcSpecified = "any value between 66 and 188. (this may change)"
# Example: $adcSpecified = 188

:Start

  $adcCurrent = GetADC(1.ADC1)

    if ($adcCurrent < $adcSpecified)
    goto(RotateRight)
EndIf

    if ($adcCurrent > $adcSpecified)
    goto(RotateLeft)
EndIf

    If (($adcCurrent >($adcSpecified - 20) and $adcCurrent <($adcSpecified + 20)))
    goto(RotateSlow)
EndIf

    If (($adcCurrent >($adcSpecified - 5) and $adcCurrent <($adcSpecified + 5)))
    goto(RotateStop)
EndIf


goto(Start)

:RotateRight
  Set(1.D4, on)
  Set(1.D5, off)
Return()

:RotateLeft
  Set(1.D4, off)
  Set(1.D5, on)
Return()

:RotateSlow
PWM(1.D6,20)
Sleep(0250)
PWM(1.D6,10)

:RotateStop
  Set(1.D5, off)
  Set(1.D4, off)
Halt()

This is an example of a script sending the stopping point varable. I also have PWM settings that provide ramping effects:


PWM(1.D6,10)
$adcSpecified = 90
controlcommand("Move Waist", scriptstart)
Sleep(0250)
PWM(1.D6,30)
Sleep(0250)
PWM(1.D6,50)
Sleep(2250)

PWM(1.D6,10)
$adcSpecified = 160
controlcommand("Move Waist", scriptstart)
Sleep(0250)
PWM(1.D6,30)
Sleep(0250)
PWM(1.D6,50)
Sleep(2250)

PWM(1.D6,10)
$adcSpecified = 185
controlcommand("Move Waist", scriptstart)
Sleep(0250)
PWM(1.D6,20)
Sleep(0250)
PWM(1.D6,30)
Sleep(0250)
PWM(1.D6,50)
Sleep(2250)

PWM(1.D6,10)
$adcSpecified = 90
controlcommand("Move Waist", scriptstart)
Sleep(0250)
PWM(1.D6,20)
Sleep(0250)
PWM(1.D6,30)
Sleep(0250)
PWM(1.D6,40)
Sleep(3000)

PWM(1.D6,10)
$adcSpecified = 128
controlcommand("Move Waist", scriptstart)
Sleep(0250)
PWM(1.D6,30)
Sleep(0250)
PWM(1.D6,40)
Sleep(3000)

controlcommand("Waist Center", scriptstart)

Here is an example of a centering script (as you can see in the above script I have it being called at the end of the script):


# This script will move the motor into the
# Center position.

:Start

$adcWctSpecified = 128

$adcWctCurrent = GetADC(1.adc1)

IF ($adcWctCurrent < $adcWctSpecified)
  goto(RotateRight)
ENDIF 
  
IF ($adcWctCurrent > $adcWctSpecified)
  goto(RotateLeft)
ENDIF 
  
IF (($adcWctCurrent >($adcWctSpecified - 5) and $adcWctCurrent <($adcWctSpecified + 5)))
  goto(RotateStop)
ENDIF 
  
goto(Start)

:RotateRight
PWM(1.D6,10)
Set(1.D4, on)
Set(1.D5, off)
Return()

:RotateLeft
PWM(1.D6,10)
Set(1.D4, off)
Set(1.D5, on)
Return()

:RotateStop
Set(1.D5, off)
Set(1.D4, off)
Halt()

Hope this helps. Let me know if I can help more.

Dave Schulpius

PRO
Synthiam
#7  

New feature: https://synthiam.com/Community/Questions/3883

You can do something like this now..


:CenterR
$DomePosition=GetADC(adc7)
ADC_Wait_Between(adc7, 100, 110, 10) 
Servo(D3, 50)   
Sleep(500)
Release(D3)
$DomeDirection=3 
$DomeServo=50 
Goto(Stop)

Do not use ADC_WAIT() because you won't always get the exact value for your application.

#8  

Thanks DJ for the tweak and pointing us to the new command. I probably would have missed it.

I need to study how this will work. Not really sure right now. However once I figure it out it looks like this may make my scripts much simpler.

Canada
#9  

It's working great so far. I'm still fiddling with the delay but it's making my script above 100 times better now!

Once again DJ rocks!

Kris

PRO
Synthiam
#10  

I think you offered cookies or beer to find a solution? I'll take both! :)

Canada
#11  

Next trip in. I'll bring you guys and gals some goodies. ;)