Encoder position status
jonyjib
Posts: 20
in Propeller 1
Hi Guys!
I need a little help figuring this out:
I am working on a cablecam project, where I have an encoder riding on the rope/cable of a cable camera. As the rig drives down the cable, the encoder is counting and keeping track of the position along the length of the rope. I also have a provision for the user to manually Set A and Set B points on the cable that are safe zones to keep the unit within these zones.
The total cable run of 1000' provides 400,000 impulses from the encoder. (about 400 pulses per foot) When the rig is within 25 ft (10,000 impulses) of the Set A or B, I need the servo output set to 1500 uS so the unit will stop and then manual control (the opposite direction) can resume after the position variable remains the same for a few passes of the program. (showing that the rig has stopped)
In this code I just made the rig pass the Set point, slow down to idle and slowly return to the Set point. Then they can resume full control. This is working OK, but its not efficient when trying to get an important shot quickly...
pub process_encoder
position := encoder.read(0) ' sample encoder position reading
if(setA > 0) ' push Set A button to read & store (near) position
stopA := position
if(setB > 0) ' push Set B button to read & store (far) position
stopB := position
if(reverse == 1) ' if reverse switch is activated
if(position < stopA) ' if position passes stopA stop
outcservo := 1600
elseif(position > stopB) ' if position passes stopB slow down
outcservo := 1400
else
outcservo := cservo
else ' if reverse switch is not activated
if(position < stopA) ' if position passes stopA slow down
outcservo := 1400
elseif(position > stopB) ' if position passes stopB slow down
outcservo := 1600
else
outcservo := cservo
John
I need a little help figuring this out:
I am working on a cablecam project, where I have an encoder riding on the rope/cable of a cable camera. As the rig drives down the cable, the encoder is counting and keeping track of the position along the length of the rope. I also have a provision for the user to manually Set A and Set B points on the cable that are safe zones to keep the unit within these zones.
The total cable run of 1000' provides 400,000 impulses from the encoder. (about 400 pulses per foot) When the rig is within 25 ft (10,000 impulses) of the Set A or B, I need the servo output set to 1500 uS so the unit will stop and then manual control (the opposite direction) can resume after the position variable remains the same for a few passes of the program. (showing that the rig has stopped)
In this code I just made the rig pass the Set point, slow down to idle and slowly return to the Set point. Then they can resume full control. This is working OK, but its not efficient when trying to get an important shot quickly...
pub process_encoder
position := encoder.read(0) ' sample encoder position reading
if(setA > 0) ' push Set A button to read & store (near) position
stopA := position
if(setB > 0) ' push Set B button to read & store (far) position
stopB := position
if(reverse == 1) ' if reverse switch is activated
if(position < stopA) ' if position passes stopA stop
outcservo := 1600
elseif(position > stopB) ' if position passes stopB slow down
outcservo := 1400
else
outcservo := cservo
else ' if reverse switch is not activated
if(position < stopA) ' if position passes stopA slow down
outcservo := 1400
elseif(position > stopB) ' if position passes stopB slow down
outcservo := 1600
else
outcservo := cservo
John
Comments
-- Ramp up to desired max speed
-- Note delta between current position and half-way point of move
-- Continue to mid-point at max speed
-- Run delta (second half of move) at max speed
-- Ramp down
-- Adjust ramp as you get very close
I used this strategy in Camera Turret products and it worked very well.
Speed is always a positive number. Velocity includes a direction component, given by the sign of position - end_position. Also, unless MINSPEED is zero, you will need a separate check to see if position is close enough to end_position to set speed to zero.
-Phil
PID... Agreed...but coupled with the discreetized profiling, per the document I posted will provide velocity control under varying load conditions.
Was just asking about you in another thread
This is how to do it (Tablet is only HMI)
nice
Mike
Client was Jaguar Land Rover.
Siemens control died and no longer supported. Machine was in great shape. A replacement would have been $200K.
I saved them a bunch