Welcome to Synthiam!

Program robots using technologies created from industry experts. ARC is our free-to-use robot programming software that makes features like vision recognition, navigation and artificial intelligence easy.

Get Started
Asked — Edited

How To Limit Range Of A Motor

Afternoon All

So I'm using an H-Bridge and panel to turn the head section of my robot. It works great but I want to limit the range of the revolution. For example I'd like to have the section only be able to move from 2:00 position to the 10:00 position and no more. I've experimented with various controls haven't had any luck.

Anyone care to chime in?

Thanks,

Daniel

AI Support Bot
Related Content
Synthiam
United Kingdom
#1  
Timing is never an accurate method, if it could cause damage to the robot if the stops were missed I wouldn't suggest it.

Dave has used Pots connected to the ADC ports for his B9 along with limit switches and relevant scripting. I'm sure he will chime in with the details soon:)

For safety though I would always advise putting in some limit switches just after the point of where it should stop, but before the point of any damage. A simple switch which will cut the power to the motor if it is triggered (a normally closed microswitch should do it, put in line on the Vcc to the motor, when the motor oversteps it's mark, switch is hit causing it to open circuit and the motor stops.

Another alternative is, if you can find one, strip a servo guts out and replace the servos motor with the motor you are using, relocate the pot to the motor spindle or whatever is moving somehow, this will allow you to use the Servo() command and have much better accuracy. You will require a servo which has the guts to drive a motor of the same current demand though which may be the biggest challenge.
#2  
Thanks Rich

I have limit switches on all my actions (waist and radar). Dave has taught me well :-)

Aameralis I'll start taking a look at your suggestions.

Daniel
#3  
I'm looking forward to seeing aameralis's end result with his timing preference for positioning. I hope he can work the script out to his liking in real life operation. if so it's a much easier solution then mounting a pot and using ADC ports with scripts. If you or he are using RC or other control for movement then position can be stopped with the joystick on the handheld control you've interfaced into your robot.

However I'm on the side of the fence with Rich. Using a feedback pot connected to an ADC port of EZB has let me stop at any point on a radius. I just send a variable value from one script to the movement script and that movement script will start the motor, move it in the direction of the value it receives and stop when it gets there.

Here's an example of the two scripts I use:

This one sends the specified variable where I want the radar to stop at (I can also set the speed (PWM) of the motor from here):

Code:


PWM(D7,80)
$adcRdrSpecified = 146
ControlCommand("Script Manager", ScriptStart, "Move Radar")


Here's the Movement Script that will receive the specified variable. It uses math to figure it all out. ARC and EZB gets this from the pot connected to a ADC port:

Code:


#Script that calls this needs to use
#$adcRdrSpecified = "any value between 117 and 153"
#to move the radar.
#Example: $adcRdrSpecified = 146

:Start

$adcRdrCurrent = GetADC(adc7)

if ($adcRdrCurrent < $adcRdrSpecified)
goto(RotateRight)
EndIf

if ($adcRdrCurrent > $adcRdrSpecified)
goto(RotateLeft)
EndIf

If (($adcRdrCurrent >($adcRdrSpecified - 2) and $adcRdrCurrent <($adcRdrSpecified + 2)))
goto(RotateSlow)
EndIf

If (($adcRdrCurrent >($adcRdrSpecified - 3) and $adcRdrCurrent <($adcRdrSpecified + 3)))
goto(RotateStop)
EndIf

goto(Start)

:RotateRight
#PWM(D6,50)
Set(D9, on)
Set(D8, off)
Return()

:RotateLeft
#PWM(D6,50)
Set(D9, off)
Set(D8, on)
Return()

:RotateSlow
PWM(D7,30)
Sleep(0250)
PWM(D7,20)

:RotateStop
Set(D8, off)
Set(D9, off)
Halt()


Here's how it all ended up working:


You are welcome to use any or all my already written scripts if they help. You will just have to adjust the port values.

Hope this helps, Dave
#4  
I don't want to hijack this thread, but I have a question that is related. In my robot, I am using windshield wiper motors. They have a built in switch that stays closed throughout most of the rotation, and opens up briefly each time around. This is used to bring the wipers home when you shut them off. I am wondering if I send 5 volts through this switch and connect it to an analog port, could I write a script that would turn it four pulses one way, for instance, when I say "turn left" or eight pulses when I say "about face" (assuming eight revolutions of the motor turn the torso one half turn) and then bring it back to the center when I say "face forward?" It would have to keep track of the last command to know how far, and what direction to bring it back to the front.

I haven't played with the scripting much at all, but it would seem that a voltage dropping off would be just as effective as a trigger as one turning on. If worse came to worse, I could use a spdt relay to reverse the pulse and have it power on for the brief moment that the switch actually opens.

I guess at this point, I am just kicking around ideas. Any feedback would be appreciated.
#5  
@Danger , I cannot know for sure but I believe that switch is just a pulse trigger for the wiper relay to reverse direction. I do not believe you will be able to accurately utilize it to start and stop positions at a particular time. You may consider using a encoder and using ADC port to read to position as it turns. You can also use like aameralis suggests to set a specific time for the action and it's not perfect but it is pretty close for non precision use. My personal favorite option is getting a servo and hitting the potentiometer and controller out of it and connect that control board to a h bridge to control your wiper motors:) it would then be a giant servo. It just depends on how you want to do it.
United Kingdom
#6  
To add to that, how would you connect the servo control board to a h-bridge for it to control the motor?
#7  
I saw a video once on how to hack into a Futaba servo and use relays to run a DC motor. I opened one of my bargain Futaba Servos only to find that I had bought counterfeits. Nothing inside was the same as the video. I never got it to work.

That being said. the wiper motor turns continuously in one direction. The "park" switch is a simple on/off. In the car, power is supplied through that switch so that if it is shut off mid-cycle, it continues to get current until it reaches the bottom. My thinking is that this steady on-off cycle could be used by EZ-B to keep track of how many turns the motor makes.

I do appreciate the input Josh. I may end up going with the encoder idea. However, if this switch is already clicking away in the motor anyway, I'd like to try to use that.

One final note. I am not just asking for my situation. These motors are heavy and not very efficient, but they are dirt cheap ($19.99) and very rugged. Others building large robots might find them useful.
User-inserted image

#8  
@rich , the servo output is a pwm that can reverse voltage. As long as you give the servo board 5 volts the pwm output is 5 volts too and you can use that to trigger an h bridge just like a digital pin. It would take some wiring and a resistor inbetween to limit the current.

I didn't see this post was updated I have not received EZ robot automated notifications for a while. I went through my spam box and I don't get them there either. So I never know when there is a reply to a thread I commented on now.
#9  
You could use micro switches at each of the max travel and hook them to digital inputs. Or a few guys here have used pots and hooked them to acd I believe. Then set up your limits as variables.