Award
Congratulations Richard R, for answering the question and has received an EZ-Credit award! Share what you have learned and create a tutorial to help others by clicking here.

Best Way To Script And Build A Limit To Cont Servo

Assistance Requested

Help Jayutmb with their question and receive $10 of EZ-Credit to get more robots and parts from our store. The following information was provided about their previous efforts searching tutorials for a resolution.

Jayutmb claims to have checked these sources:
 
#1

Ok I am sure someone has it listed in the threads ( cant find a specific one however)
I have hacked printer parts to make a periscope lifter for my R2,and I am using an EZB 360 servo to power it.. however I need to be able to limit the up and down pretty precisely when I have the ezb execute the lift and lower script... I am guessing the only way to do this would be limit switches at the top and bottom of the physical lifer mechanism.. If so can anyone guide me on how that would look like scripted ? And no I cant do a simple "timing" script as the timing varies and a half second off either way will break the lifter.
Thanks in advance Smile

I have found a few conversations, tutorials and activities that may help with your question. Take a look at these links. I've sorted them by what I believe to be most relevant but that is not always the case as I'm still learning.


Also, consider reviewing the Learn section for informative lessons and activities. Check it out!


#2

As you mentioned you could use limit switches (you will need a pull up or pull down resistor depending on how you wired them) and something like ADC_Wait to monitor the switches
Maybe something like this?

#180 value may need to be 1 if the servo moves in the wrong direction and vice versa

Code:


if($periscope = 0) #periscope is down so move it up
Servo(D0,180) #may need to be 1

ADC_Wait(ADC0, LOWER, 50) #might need to use HIGHER instead of LOWER here
$periscope = 1 #periscope is up
Servo(D0,107) #servo 360 stop command

else #periscope is up so move it down
servo(D0,1) #may need to be 180

ADC_Wait(ADC1, LOWER, 50) #bottom switch on adc port 1
$periscope = 0 #periscope is down
Servo(D0,107) #servo 360 stop command

endif


Also I would advise you update to the new ezb4 x/2 board (if you haven't done so already) as it way faster at monitoring analog and digital reads. Not to mention other superior features as well...

#3

Thank you ! Smile

#4

Another way you can do this is to wire microwitchs into the motor circuit. One one each of the power lines. Then when the motor hits one of the switches the power will be cut and the motor stops. The trick to get the motor moving again after power is cut by the open switch is to place a diode on each switch in the proper way to get the motor to accept reversed power from a hbridge. Then all you need is script a digital on, sleep() for however long it takes the move to complete and then digital port off.

#5

Also, have you thought about using the electrical PCB and potentiometer of a Standard Servo and hack to your application?

I'm with Richard on recommending the /2 upgrade as well. I see you have a /1 comm board still. The /2 will provide increased communication speed (about 100 times faster): EZ-B v4/2 Comm Upgrade

#6

How many turns of the 360 servo does it take to fully deploy or retract the periscope? Could you use a sail winch servo? https://hobbyking.com/en_us/turnigytm-tgy-6114md-digital-sail-winch-servo-drum-type.html for instance can be programmed to turn 1 to 6 full rotations.

You'll need to calibrate with the EZ-B since position 0 to position 180 won't indicate degrees anymore, just min and max.

Alan

#7

Thanks for help guys Smile
I got lazy (still recovering from holidays ) and just put a limit switch at top and one at bottom. Now I have a peri up button and peri down with each respective button having a termination of script once digital port reads "true" and its working good for my lazy man fix Smile ( Cant say my bootleg limit switches are pretty ...but they work lol )

#8

Quote:


I got lazy (still recovering from holidays ) and just put a limit switch at top and one at bottom. Now I have a peri up button and peri down with each respective button having a termination of script once digital port reads "true" and its working good for my lazy man fix Smile ( Cant say my bootleg limit switches are pretty ...but they work lol )



Perfectly legitimate solution. A lot of times a bunch of us will throw out a bunch of answers to a question just to show those coming later that there are multiple ways to do things. Some will work better in a situation than others. Limit switches are perfectly fine as long as you absolutely have the script that listens for them running any time the periscope is moving.

Alan