Blend DC Motor Control With Servo Control


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
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:
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:
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!
I'm still poking around looking for different ways to move my simple serial language controlled DC elbow motors (powered by powered through a Kangaroo/Sabertooth motor controllers) in unison with the servo motors in my robot's arm. I need to look closer at this and figure how it works but could this servo script skill help me?
https://synthiam.com/Support/Skills/Scripting/Servo-Script?id=19068
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?