Requested

Blend DC Motor Control With Servo Control


Completed
This feature request has been completed. Install the latest ARC Pro to experience the newest features and bug fixes.

Get ARC Pro

I've written many EZ Scripts that will take the frames from a Auto Position control and blend in DC motor control based on feedback from an encoder on the motors shaft. This is because in have a robot arm that is moved by a worm gear windshield wiper DC motor for the elbow and then three servos, two for the a wrist in two directions and a claw for open and closed.  It works but is clunky to script and although the resulting movment can look good, I am thinking the process may be able to be easier and cleaner.

Maybe I'm overlooking a better way to do this other then my blended scripts and AP controls but it would be nice to have a plugin or something that would make the process more seamless and easer to blend the two kinds of motors. Blow are examples of one of my main scripts and the other support script it calls where I have both the wrist and claw servos (positions that are built in the Auto Position control) moving with the DC elbow motor. I have embedded a lot of DC motor commands in the Auto Position servo controls. It works but the project has taken on a life of it's own.

My DC elbow motor is sent commands through an EZB uart to a pair of  Kangaroo/Sabertooth motor controllers. Is there any better way to do this?

Here's one of the EZ Scripts that calls on frames in one of my Auto Position controls that have scripts embedded that calls on other external EZ Scripts that move the DC elbow motors (and other servo commands). There is a support script bellow this.

ControlCommand("Personality Generator", PauseOn) #Pause off in Rt Carrage Auto In/Out script
ControlCommand("Speech Recognition", PauseOn) #Pause off in Rt Carrage Auto In/Out script
Sleep(50)
# --------------------------------------------
# ------------------------------------
# The next command will Move arm carrages out of the torso
# Arms will be centered by "Both Ars out" script.
ControlCommand("Auto Both Arms", AutoPositionFrameJump, "Center_Both_Arms")#This will iniseate servos to keep them from jumpung.
Sleep(50)
ControlCommand("Amanation Support", ScriptStart, "Reset Rt Claw")
Sleep(50)
ControlCommand("Amanation Support", ScriptStart, "Reset Lft Claw")
sleep(50)
ControlCommand("Leg Section", ScriptStart, "1/4 Fast Waist Anamation")
Sleep(50)
ControlCommand("Auto Both Arms", AutoPositionAction, "Both Ars Out")
Sleep(1700)
# ----------------------------------------------

WaitFor( $Both_ARS_Extended = 1 ) #Both Carragse fully out. It's safe to proceed.
# ################################################################
# #Place command below to start the "Auto Both Arms",  AutoPosition Control below
# #Example: ControlCommand("Auto Both Arms", AutoPositionAction, "Down And Center")
ControlCommand("Auto Both Arms", AutoPositionAction, "Classic Pose")

#----------------------------------------------------------------
Waitfor($AutoPositionStatus = 0 )#Anamation is complete and AP has stopped, OK to
ControlCommand("Auto Right Arm", AutoPositionFrame, "90 up, Claw Open", 25, 20, 0)
ControlCommand("Auto Left Arm", AutoPositionFrame, "Lft_Up - Out, Claw Open", 25, 20, 0)
Sleep(2500)
# --------------------------------------
# The next command will cebter and retract arm carrages into torso
# Arms will be centered through the "Both Ars In" script.
ControlCommand("Auto Both Arms", AutoPositionAction, "Both Ars In")
Sleep(50)
Release(2.D3) #Release Rt Claw
Release(2.D6) #Release Lft Claw
Sleep(50)
ControlCommand("Leg Section", ScriptStart, "Waist Center")
Sleep(50)
# --------------------------------------
# #Place below any commands to shut down motors, end extra anamations and
# Return robot back to normal standby.

ControlCommand("Personality Generator", PauseOff)
ControlCommand("Speech Recognition", PauseOff)

Here's an example of one of the scripts embedded in one of my Auto Position "Action" controls that moves the DC elbow motor and other servos:

#This Script along with the Action it's attached to will move

#both the DC Elbow motors and the Wrist Servos.
# #####################################################
# Called by Arm Anamae script to command the Kangaroo
# to move Rt Elbow motor by variable value set in that script.
# this will also move same time  AutoPosition control is moving arm Servos
# Elbow Kangaroo Values:
#
# Right Elbow Motor:
# p3000-Full up, p2510-Center, p1885-Full Down
# s2000-Full Speed, s0-Dead Stop
#
# Left Elbow Motor:
# p1885-Full up, p2485-Center, p3000-Full Down
# s2000-Full Speed, s0-Dead Stop
# #######################################################
# ---------------------------------------

$Both_Arms_Centered = 1 #Reset varable so script will run. 1=not centered, 0=centered
$Both_Elbow_Seek_Speed = 600

Sleep(50)

uartWrite(2, 0, "1,P"+$Rt_Elbow_Center, "s1600", 0x0d) #Move Rt Elbow Motor
#Sleep(200)
uartWrite(2, 0, "2,P"+$lFt_Elbow_Center, "s1600", 0x0d) #Move Lft Elbow Motor
Sleep(3000)

$ADC_Rt_Elbow = GetADC(2.ADC0)
Sleep(50)
if ($ADC_Rt_Elbow >= 160) #160-350 is in Centered position
  Goto(Check_Left_Elbow)
ELSEif ($ADC_Rt_Elbow < 160) #Below 160 is not chetered
  Goto(Adjust_Arms)
endif

:Check_Left_Elbow
$ADC_Lft_Elbow = GetADC(2.ADC1)
Sleep(50)
if ($ADC_Lft_Elbow >= 160)#160-350 is in Centered position
  $Both_Arms_Centered = 0 #Sets varable 1=not cnetered, 0=centered
ELSEif ($ADC_Lft_Elbow < 160) #Below 160 is not centered
  Goto(Adjust_Arms)
endif

:Adjust_Arms
# ------------------------------------
$ADC_Rt_Elbow = GetADC(2.ADC0)
Sleep(100)
Print($ADC_Rt_Elbow)
if ($ADC_Rt_Elbow >= 160) #160-350 is in Centered position
  Goto(Read_Left_Elbow_Center)
ELSE ($ADC_Rt_Elbow < 160) #Below 160 is not chetered
  uartWrite(2, 0, "1,P"+($Rt_Elbow_Center - 40), "s"+$Both_Elbow_Seek_Speed, 0x0d) #Move Rt Elbow Motor down a little to try to center
endif
Sleep(2000)

# ----------
$ADC_Rt_Elbow = GetADC(2.ADC0)
Sleep(100)
Print($ADC_Rt_Elbow)
if ($ADC_Rt_Elbow >= 160) #160-350 is in Centered position
  Goto(Read_Left_Elbow_Center)
ELSE ($ADC_Rt_Elbow < 160) #Below 160 is not chetered
  uartWrite(2, 0, "1,P"+($Rt_Elbow_Center - 30), "s"+$Both_Elbow_Seek_Speed, 0x0d) #Move Rt Elbow Motor down a little to try to center
endif
Sleep(1000)

# ----------
$ADC_Rt_Elbow = GetADC(2.ADC0)
Sleep(100)
Print($ADC_Rt_Elbow)
if ($ADC_Rt_Elbow >= 160) #160-350 is in Centered position
  Goto(Read_Left_Elbow_Center)
ELSE ($ADC_Rt_Elbow < 160) #Below 160 is not chetered
  uartWrite(2, 0, "1,P"+($Rt_Elbow_Center - 20), "s"+$Both_Elbow_Seek_Speed, 0x0d) #Move Rt Elbow Motor down a little to try to center
endif
Sleep(1000)

# ----------
$ADC_Rt_Elbow = GetADC(2.ADC0)
Sleep(100)
Print($ADC_Rt_Elbow)
if ($ADC_Rt_Elbow >= 160) #160-350 is in Centered position
  Goto(Read_Left_Elbow_Center)
ELSE ($ADC_Rt_Elbow < 160) #Below 160 is not chetered
  uartWrite(2, 0, "1,P"+($Rt_Elbow_Center - 10), "s"+$Both_Elbow_Seek_Speed, 0x0d) #Move Rt Elbow Motor down a little to try to center
endif
Sleep(1000)

# ----------
$ADC_Rt_Elbow = GetADC(2.ADC0)
Sleep(100)
Print($ADC_Rt_Elbow)
if ($ADC_Rt_Elbow >= 160) #160-350 is in Centered position
  Goto(Read_Left_Elbow_Center)
ELSE ($ADC_Rt_Elbow < 160) #Below 160 is not chetered
  uartWrite(2, 0, "1,P"+($Rt_Elbow_Center + 20), "s"+$Both_Elbow_Seek_Speed, 0x0d) #Move Rt Elbow Motor down a little to try to center
endif
Sleep(1000)

# ----------
$ADC_Rt_Elbow = GetADC(2.ADC0)
Sleep(100)
Print($ADC_Rt_Elbow)
if ($ADC_Rt_Elbow >= 160) #160-350 is in Centered position
  Goto(Read_Left_Elbow_Center)
ELSE ($ADC_Rt_Elbow < 160) #Below 160 is not chetered
  uartWrite(2, 0, "1,P"+($Rt_Elbow_Center + 30), "s"+$Both_Elbow_Seek_Speed, 0x0d) #Move Rt Elbow Motor down a little to try to center
endif
Sleep(1000)

# ----------
$ADC_Rt_Elbow = GetADC(2.ADC0)
Sleep(100)
Print($ADC_Rt_Elbow)
if ($ADC_Rt_Elbow >= 160) #160-350 is in Centered position
  Goto(Read_Left_Elbow_Center)
ELSE ($ADC_Rt_Elbow < 160) #Below 160 is not chetered
  uartWrite(2, 0, "1,P"+($Rt_Elbow_Center + 40), "s"+$Both_Elbow_Seek_Speed, 0x0d) #Move Rt Elbow Motor down a little to try to center
endif
Sleep(1000)

# ----------
$ADC_Rt_Elbow = GetADC(2.ADC0)
Sleep(100)
Print($ADC_Rt_Elbow)
if ($ADC_Rt_Elbow >= 160) #160-350 is in Centered position
  Goto(Read_Left_Elbow_Center)
ELSE ($ADC_Rt_Elbow < 160) #Below 160 is not chetered
  uartWrite(2, 0, "1,P"+($Rt_Elbow_Center + 50), "s"+$Both_Elbow_Seek_Speed, 0x0d) #Move Rt Elbow Motor down a little to try to center
endif
Sleep(1000)

# ----------
$ADC_Rt_Elbow = GetADC(2.ADC0)
Sleep(100)
Print($ADC_Rt_Elbow)
if ($ADC_Rt_Elbow >= 160) #160-350 is in Centered position
  Goto(Read_Left_Elbow_Center)
ELSE ($ADC_Rt_Elbow < 160) #Below 160 is not chetered
  uartWrite(2, 0, "1,P"+($Rt_Elbow_Center + 35), "s"+$Both_Elbow_Seek_Speed, 0x0d) #Move Rt Elbow Motor down a little to try to center
endif
Sleep(1000)

# ----------
$ADC_Rt_Elbow = GetADC(2.ADC0)
Sleep(100)
Print($ADC_Rt_Elbow)
if ($ADC_Rt_Elbow >= 160) #160-350 is in Centered position
  Goto(Read_Left_Elbow_Center)
ELSE ($ADC_Rt_Elbow < 160) #Below 160 is not chetered
  uartWrite(2, 0, "1,P"+($Rt_Elbow_Center + 25), "s"+$Both_Elbow_Seek_Speed, 0x0d)
endif
Sleep(1000)

# ----------
$ADC_Rt_Elbow = GetADC(2.ADC0)
Sleep(100)
Print($ADC_Rt_Elbow)
if ($ADC_Rt_Elbow >= 160) #160-350 is in Centered position
  Goto(Read_Left_Elbow_Center)
ELSE ($ADC_Rt_Elbow < 160) #Below 160 is not chetered
  uartWrite(2, 0, "1,P"+($Rt_Elbow_Center + 5), "s"+$Both_Elbow_Seek_Speed, 0x0d) #Move Rt Elbow Motor down a little to try to center
endif
Sleep(1000)

# ----------
$ADC_Rt_Elbow = GetADC(2.ADC0)
Sleep(100)
Print($ADC_Rt_Elbow)
if ($ADC_Rt_Elbow >= 160) #160-350 is in Centered position
  Goto(Read_Left_Elbow_Center)
ELSE ($ADC_Rt_Elbow < 160) #Below 160 is not chetered
  uartWrite(2, 0, "1,P"+($Rt_Elbow_Center - 5), "s"+$Both_Elbow_Seek_Speed, 0x0d) #Move Rt Elbow Motor down a little to try to center
endif
Sleep(1000)

# ----------
$ADC_Rt_Elbow = GetADC(2.ADC0)
Sleep(100)
Print($ADC_Rt_Elbow)
if ($ADC_Rt_Elbow >= 160) #160-350 is in Centered position
  Goto(Read_Left_Elbow_Center)
ELSE ($ADC_Rt_Elbow < 160) #Below 160 is not chetered
  uartWrite(2, 0, "1,P"+($Rt_Elbow_Center - 15), "s"+$Both_Elbow_Seek_Speed, 0x0d) #Move Rt Elbow Motor down a little to try to center
endif
Sleep(1000)

# ----------
$ADC_Rt_Elbow = GetADC(2.ADC0)
Sleep(100)
Print($ADC_Rt_Elbow)
if ($ADC_Rt_Elbow >= 160) #160-350 is in Centered position
  Goto(Read_Left_Elbow_Center)
ELSE ($ADC_Rt_Elbow < 160) #Below 160 is not chetered
  uartWrite(2, 0, "1,P"+($Rt_Elbow_Center - 25), "s"+$Both_Elbow_Seek_Speed, 0x0d) #Move Rt Elbow Motor down a little to try to center
endif
Sleep(1000)

# ----------
$ADC_Rt_Elbow = GetADC(2.ADC0)
Sleep(100)
Print($ADC_Rt_Elbow)
if ($ADC_Rt_Elbow >= 160) #160-350 is in Centered position
  Goto(Read_Left_Elbow_Center)
ELSE ($ADC_Rt_Elbow < 160) #Below 160 is not chetered
  uartWrite(2, 0, "1,P"+($Rt_Elbow_Center - 35), "s"+$Both_Elbow_Seek_Speed, 0x0d) #Move Rt Elbow Motor down a little to try to center
endif
Sleep(1000)

# ----------
$ADC_Rt_Elbow = GetADC(2.ADC0)
Sleep(100)
Print($ADC_Rt_Elbow)
if ($ADC_Rt_Elbow >= 160) #160-350 is in Centered position
  Goto(Read_Left_Elbow_Center)
ELSE ($ADC_Rt_Elbow < 160) #Below 160 is not chetered
  uartWrite(2, 0, "1,P"+($Rt_Elbow_Center - 45), "s"+$Both_Elbow_Seek_Speed, 0x0d) #Move Rt Elbow Motor down a little to try to center
endif
Sleep(1000)

# ----------
$ADC_Rt_Elbow = GetADC(2.ADC0)
Sleep(100)
Print($ADC_Rt_Elbow)
if ($ADC_Rt_Elbow >= 160) #160-350 is in Centered position
  Goto(Read_Left_Elbow_Center)
ELSE ($ADC_Rt_Elbow < 160) #Below 160 is not chetered
  Print("Stop!! Cant Find Center!!!")
  ControlCommand("Soundboard v4", Track_44)
  Halt()
endif

  # ------------------------------------------------------------
:Read_Left_Elbow_Center

$ADC_Lft_Elbow = GetADC(2.ADC1)
Sleep(100)
Print($ADC_Lft_Elbow)
if ($ADC_Lft_Elbow >= 160) #160-350 is in Centered position
  $Both_Arms_Centered = 0 #Sets varable 1=not cnetered, 0=centered
  Goto(End_Script)
ELSE ($ADC_Lft_Elbow < 160) #Below 160 is not chetered
  uartWrite(2, 0, "2,P"+($Lft_Elbow_Center - 40), "s"+$Both_Elbow_Seek_Speed, 0x0d) #Move Lft Elbow Motor a little to try to center
endif
Sleep(2000)

# -------------
$ADC_Lft_Elbow = GetADC(2.ADC1)
Sleep(100)
Print($ADC_Lft_Elbow)
if ($ADC_Lft_Elbow >= 160) #160-350 is in Centered position
  $Both_Arms_Centered = 0 #Sets varable 1=not cnetered, 0=centered
  Goto(End_Script)
ELSE ($ADC_Lft_Elbow < 160) #Below 160 is not chetered
  uartWrite(2, 0, "2,P"+($Lft_Elbow_Center - 30), "s"+$Both_Elbow_Seek_Speed, 0x0d) #Move Lft Elbow Motor a little to try to center
endif
Sleep(1000)

# -------------
$ADC_Lft_Elbow = GetADC(2.ADC1)
Sleep(100)
Print($ADC_Lft_Elbow)
if ($ADC_Lft_Elbow >= 160) #160-350 is in Centered position
  $Both_Arms_Centered = 0 #Sets varable 1=not cnetered, 0=centered
  Goto(End_Script)
ELSE ($ADC_Lft_Elbow < 160) #Below 160 is not chetered
  uartWrite(2, 0, "2,P"+($Lft_Elbow_Center - 20), "s"+$Both_Elbow_Seek_Speed, 0x0d) #Move Lft Elbow Motor a little to try to center
endif
Sleep(1000)

# -------------
$ADC_Lft_Elbow = GetADC(2.ADC1)
Sleep(100)
Print($ADC_Lft_Elbow)
if ($ADC_Lft_Elbow >= 160) #160-350 is in Centered position
  $Both_Arms_Centered = 0 #Sets varable 1=not cnetered, 0=centered
  Goto(End_Script)
ELSE ($ADC_Lft_Elbow < 160) #Below 160 is not chetered
  uartWrite(2, 0, "2,P"+($Lft_Elbow_Center - 10), "s"+$Both_Elbow_Seek_Speed, 0x0d) #Move Lft Elbow Motor a little to try to center
endif
Sleep(1000)

# -------------
$ADC_Lft_Elbow = GetADC(2.ADC1)
Sleep(100)
Print($ADC_Lft_Elbow)
if ($ADC_Lft_Elbow >= 160) #160-350 is in Centered position
  $Both_Arms_Centered = 0 #Sets varable 1=not cnetered, 0=centered
  Goto(End_Script)
ELSE ($ADC_Lft_Elbow < 160) #Below 160 is not chetered
  uartWrite(2, 0, "2,P"+($Lft_Elbow_Center + 10), "s"+$Both_Elbow_Seek_Speed, 0x0d) #Move Lft Elbow Motor a little to try to center
endif
Sleep(1000)

# -------------
$ADC_Lft_Elbow = GetADC(2.ADC1)
Sleep(100)
Print($ADC_Lft_Elbow)
if ($ADC_Lft_Elbow >= 160) #160-350 is in Centered position
  $Both_Arms_Centered = 0 #Sets varable 1=not cnetered, 0=centered
  Goto(End_Script)
ELSE ($ADC_Lft_Elbow < 160) #Below 160 is not chetered
  uartWrite(2, 0, "2,P"+($Lft_Elbow_Center + 20), "s"+$Both_Elbow_Seek_Speed, 0x0d) #Move Lft Elbow Motor a little to try to center
endif
Sleep(1000)

# -------------
$ADC_Lft_Elbow = GetADC(2.ADC1)
Sleep(100)
Print($ADC_Lft_Elbow)
if ($ADC_Lft_Elbow >= 160) #160-350 is in Centered position
  $Both_Arms_Centered = 0 #Sets varable 1=not cnetered, 0=centered
  Goto(End_Script)
ELSE ($ADC_Lft_Elbow < 160) #Below 160 is not chetered
  uartWrite(2, 0, "2,P"+($Lft_Elbow_Center + 30), "s"+$Both_Elbow_Seek_Speed, 0x0d) #Move Lft Elbow Motor a little to try to center
endif
Sleep(1000)

# -------------
$ADC_Lft_Elbow = GetADC(2.ADC1)
Sleep(100)
Print($ADC_Lft_Elbow)
if ($ADC_Lft_Elbow >= 160) #160-350 is in Centered position
  $Both_Arms_Centered = 0 #Sets varable 1=not cnetered, 0=centered
  Goto(End_Script)
ELSE ($ADC_Lft_Elbow < 160) #Below 160 is not chetered
  uartWrite(2, 0, "2,P"+($Lft_Elbow_Center +40), "s"+$Both_Elbow_Seek_Speed, 0x0d) #Move Lft Elbow Motor a little to try to center
endif
Sleep(1000)

# -------------
$ADC_Lft_Elbow = GetADC(2.ADC1)
Sleep(100)
Print($ADC_Lft_Elbow)
if ($ADC_Lft_Elbow >= 160) #160-350 is in Centered position
  $Both_Arms_Centered = 0 #Sets varable 1=not cnetered, 0=centered
  Goto(End_Script)
ELSE ($ADC_Lft_Elbow < 160) #Below 160 is not chetered
  uartWrite(2, 0, "2,P"+($Lft_Elbow_Center + 50), "s"+$Both_Elbow_Seek_Speed, 0x0d) #Move Lft Elbow Motor a little to try to center
endif
Sleep(1000)

# -------------
$ADC_Lft_Elbow = GetADC(2.ADC1)
Sleep(100)
Print($ADC_Lft_Elbow)
if ($ADC_Lft_Elbow >= 160) #160-350 is in Centered position
  $Both_Arms_Centered = 0 #Sets varable 1=not cnetered, 0=centered
  Goto(End_Script)
ELSE ($ADC_Lft_Elbow < 160) #Below 160 is not chetered
  uartWrite(2, 0, "2,P"+($Lft_Elbow_Center + 35), "s"+$Both_Elbow_Seek_Speed, 0x0d) #Move Lft Elbow Motor a little to try to center
endif
Sleep(1000)

# -------------
$ADC_Lft_Elbow = GetADC(2.ADC1)
Sleep(100)
Print($ADC_Lft_Elbow)
if ($ADC_Lft_Elbow >= 160) #160-350 is in Centered position
  $Both_Arms_Centered = 0 #Sets varable 1=not cnetered, 0=centered
  Goto(End_Script)
ELSE ($ADC_Lft_Elbow < 160) #Below 160 is not chetered
  uartWrite(2, 0, "2,P"+($Lft_Elbow_Center + 25), "s"+$Both_Elbow_Seek_Speed, 0x0d) #Move Lft Elbow Motor a little to try to center
endif
Sleep(1000)

# -------------
$ADC_Lft_Elbow = GetADC(2.ADC1)
Sleep(100)
Print($ADC_Lft_Elbow)
if ($ADC_Lft_Elbow >= 160) #160-350 is in Centered position
  $Both_Arms_Centered = 0 #Sets varable 1=not cnetered, 0=centered
  Goto(End_Script)
ELSE ($ADC_Lft_Elbow < 160) #Below 160 is not chetered
  uartWrite(2, 0, "2,P"+($Lft_Elbow_Center + 15), "s"+$Both_Elbow_Seek_Speed, 0x0d) #Move Lft Elbow Motor a little to try to center
endif
Sleep(1000)

# -------------
$ADC_Lft_Elbow = GetADC(2.ADC1)
Sleep(100)
Print($ADC_Lft_Elbow)
if ($ADC_Lft_Elbow >= 160) #160-350 is in Centered position
  $Both_Arms_Centered = 0 #Sets varable 1=not cnetered, 0=centered
  Goto(End_Script)
ELSE ($ADC_Lft_Elbow < 160) #Below 160 is not chetered
  uartWrite(2, 0, "2,P"+($Lft_Elbow_Center + 5), "s"+$Both_Elbow_Seek_Speed, 0x0d) #Move Lft Elbow Motor a little to try to center
endif
Sleep(1000)

# -------------
$ADC_Lft_Elbow = GetADC(2.ADC1)
Sleep(100)
Print($ADC_Lft_Elbow)
if ($ADC_Lft_Elbow >= 160) #160-350 is in Centered position
  $Both_Arms_Centered = 0 #Sets varable 1=not cnetered, 0=centered
  Goto(End_Script)
ELSE ($ADC_Lft_Elbow < 160) #Below 160 is not chetered
  uartWrite(2, 0, "2,P"+($Lft_Elbow_Center - 5), "s"+$Both_Elbow_Seek_Speed, 0x0d) #Move Lft Elbow Motor a little to try to center
endif
Sleep(1000)

# -------------
$ADC_Lft_Elbow = GetADC(2.ADC1)
Sleep(100)
Print($ADC_Lft_Elbow)
if ($ADC_Lft_Elbow >= 160) #160-350 is in Centered position
  $Both_Arms_Centered = 0 #Sets varable 1=not cnetered, 0=centered
  Goto(End_Script)
ELSE ($ADC_Lft_Elbow < 160) #Below 160 is not chetered
  uartWrite(2, 0, "2,P"+($Lft_Elbow_Center - 15), "s"+$Both_Elbow_Seek_Speed, 0x0d) #Move Lft Elbow Motor a little to try to center
endif
Sleep(1000)

# -------------
$ADC_Lft_Elbow = GetADC(2.ADC1)
Sleep(100)
Print($ADC_Lft_Elbow)
if ($ADC_Lft_Elbow >= 160) #160-350 is in Centered position
  $Both_Arms_Centered = 0 #Sets varable 1=not cnetered, 0=centered
  Goto(End_Script)
ELSE ($ADC_Lft_Elbow < 160) #Below 160 is not chetered
  uartWrite(2, 0, "2,P"+($Lft_Elbow_Center - 25), "s"+$Both_Elbow_Seek_Speed, 0x0d) #Move Lft Elbow Motor a little to try to center
endif
Sleep(1000)

# -------------
$ADC_Lft_Elbow = GetADC(2.ADC1)
Sleep(100)
Print($ADC_Lft_Elbow)
if ($ADC_Lft_Elbow >= 160) #160-350 is in Centered position
  $Both_Arms_Centered = 0 #Sets varable 1=not cnetered, 0=centered
  Goto(End_Script)
ELSE ($ADC_Lft_Elbow < 160) #Below 160 is not chetered
  uartWrite(2, 0, "2,P"+($Lft_Elbow_Center - 35), "s"+$Both_Elbow_Seek_Speed, 0x0d) #Move Lft Elbow Motor a little to try to center
endif
Sleep(1000)

# -------------
$ADC_Lft_Elbow = GetADC(2.ADC1)
Sleep(50)
Print($ADC_Lft_Elbow)
if ($ADC_Lft_Elbow >= 160) #160-350 is in Centered position
  $Both_Arms_Centered = 0 #Sets varable 1=not cnetered, 0=centered
  Goto(End_Script)
ELSE ($ADC_Lft_Elbow < 160) #Below 160 is not chetered
  uartWrite(2, 0, "2,P"+($Lft_Elbow_Center - 45), "s"+$Both_Elbow_Seek_Speed, 0x0d) #Move Lft Elbow Motor a little to try to center
endif
Sleep(1000)

# -------------
$ADC_Lft_Elbow = GetADC(2.ADC1)
Sleep(100)
Print($ADC_Lft_Elbow)
if ($ADC_Lft_Elbow >= 160) #160-350 is in Centered position
  $Both_Arms_Centered = 0 #Sets varable 1=not cnetered, 0=centered
  Goto(End_Script)
ELSE ($ADC_Lft_Elbow < 160) #Below 160 is not chetered
  Print("Stop!! Cant Find Center!!!")
  ControlCommand("Soundboard v4", Track_44)
  Halt()
endif

:End_Script
Sleep(50)
uartWrite(2, 0, "1, Powerdown", 0x0d) #Powerdown Rt Elbow Motor
Sleep(500)
uartWrite(2, 0, "2, Powerdown", 0x0d) #Powerdown left Elbow Motor


ARC Pro

Upgrade to ARC Pro

Experience early access to the latest features and updates. You'll have everything that is needed to unleash your robot's potential.

#2   — Edited

User-inserted image

Ingenious? LOL. Ya, like a blind squirrel finding a nut. But thanks for the nice words.  You always have a way to make us fee like we know what we're doing.

DJ for the pointing me in the right direction once again! The area I have these DC worm gear motors are very tight so I have zero space for conventional pots or encoders. I'm using Flat pressure sensitive pots that are activated by a stylist mounted in the joint. I've been wanting a better way to read these. Using a PCB out of a servo and mounted remotely may be the way!!  Thanks to you and the other guys involved in that thread!

PRO
Synthiam
#3  

The flat sensitive pot should work fine with the pcb. When you test it, the resistance of the pot might be a bit wonky if it isn’t the same as the servo was. You can always fix that with a 2 resistors connected to either ground or +5 depending on what way it needs to go. But I imagine it’ll be close anyway and not require any resistors.

#4   — Edited

@DJ, good to know that the pot I'm using will work. I've been wondering if it would.

The pots I'm using are Circular Soft Potentiometer (Ribbon Sensor). Adafruit has them for sale here:

Circular Soft Potentiometer

After looking over their specs it looks like it says there is already a 10K resistor built in but it's hard to tell. It's been years but I'm pretty sure I remember taking an omm reading between pin 2 & 3 and getting 10K resistance. Here is what the spec sheet says :

Quote:

"There is a nominal 10K resistance across the two outer leads. The middle pin resistance with respect to either of the outer pins changes depending on where on the strip one presses. When no pressure is applied, the middle pin floats, so be sure to use some sort of weak pullup, such as 100K ohm."

User-inserted image

#5   — Edited

As long as we are talking about the servo PCB I have one more question about the servo PCB. Any suggestions on what type of servo to remove it from? Are any better then others?  *Digital /Analog *Voltage requirements *Size/amperage *Noise/Lack of Noise *Anything else?

Something else it that I'm using a Kangaroo/Sabertooth to control speed and position. I would assume I'd ditch the Kangaroo and set the Sabertooth to accept RC / servo command signals from the EZB?

I guess I gotta really look this over closer to make sure I understand it fully and really want to do this. I don't want to lose the nice fluid ramping and overall durability of the Sabertooth.

PRO
Synthiam
#6  

You can configure the kangaroo to control the saber tooth like a servo. I did a live hack on it. If you already have the hardware, you don’t need to reinvent with a servo pcb. Just use the saber tooth in conduction with the kangaroo for servo connectivity.

the kangaroo will become a servo. Check my live hack

PRO
Synthiam
#7  

Here’s the live hack

PRO
USA
#8  

huh...i think i missed this hack...Have to watch.

#9   — Edited

I've been using the Kangaroo/Sabertooth for many years now and love the combination. Yes, it does turn the DC Motor into a servo and it will give speed and position feedback to ARC. However you cant send ARC's regular servo commands to control it. The Kangaroo is commanded with Simple Serial commands sent through the EZB Uart's TX and RX ports. I send Simple Serial commands like this to move the DC elbow motors with the connected Kangaroo/Sabertooth:

uartWrite(2, 0, "1,P"+$Rt_Elbow_Center, "s1600", 0x0d) #Move Rt Elbow Motor
#Sleep(200)
uartWrite(2, 0, "2,P"+$lFt_Elbow_Center, "s1600", 0x0d) #Move Lft Elbow Motor
Sleep(3000)

I was hoping to find a easier way to move these DC motors along with several servos at the same time. Now if I want the DC elbow motors in my arm to move as a set with the servos in the rest of the arm I need to send separate commands and manually time it all out. In my EZ Scripts I will command the DC elbow to move with a Simple serial command through the UART to the Kangaroo and then I'll write a ControlCommand command to call an AutoPositionAction to start the servo action I framed up in the AutoPosition control. Looks something like this:

# Called by Arm Anamae script to command the Kangaroo
# to move Rt and/or Lft Elbow motor to postion below.
# this will also move same time  AutoPosition control is moving arm Servos
# Elbow Kangaroo Values:
#
# Right Elbow Motor:
# p3000-Full up, p2500-Center, p1885-Full Down
# s2000-Full Speed, s0-Dead Stop
#
# Left Elbow Motor:
# p1885-Full up, p2490-Center, p3000-Full Down
# s2000-Full Speed, s0-Dead Stop
# #######################################################
# ---------------------------------------
# #Make sure Carrage is out of torso before moving elbow.
if ( $Both_ARS_Extended=1 )
  Goto (Move_Both_Elbows)  #Rt ARS is out of torso so ok to move
ELSEif ( $Both_ARS_Extended=0 )
  Halt()#Rt ARS is still in the torso so Stop
endif
Sleep(50)
# -------------------------------
:Move_Both_Elbows
uartWrite(2, 0, "1,p2800 s1600", 0x0d) #Move Right Elbow Motor
#Sleep(200)
uartWrite(2, 0, "2,p2200 s1600", 0x0d) #Move Left Elbow Motor   

It's all works but I end up having two parts of the arm being controlled by two different methods.

Again, I'm just poking around to see if there may be a better way to move the dc motor and the servos in the arm as a set.

Thanks for the help and ideas. You guys are great!

PRO
Synthiam
#11  

Dave, that live hack demonstrates how to use the kangaroo/saber tooth as a regular servo. Then in arc, it just magically becomes a servo.

Are those Uart commands instructing the kangaroo to move into a position? What’s the breakdown of the command. If you don’t want to switch the kangaroo setup to accept servo commands, then maybe you need a plug-in that does it for you?