Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Programming (http://www.chiefdelphi.com/forums/forumdisplay.php?f=51)
-   -   Motor Limits (http://www.chiefdelphi.com/forums/showthread.php?t=43277)

Idaman323 04-02-2006 01:40

Motor Limits
 
Is there a way to make a limit on how far a motor can turn? We have our turret moutned on a tourntable. The mounts for the hopper are on the sides, and we don't want the motor to turn our gun right into them if its tracking for the green light.

We also have a gate that opens and clases and we dont want it to close too far.


PS. Has anyone gotten their algorithm made and programmed for their gun to shoot yet?

Thanks



whoops sorry for posting it in the wrong forum... cmucam not programming

ForgottenSalad 04-02-2006 01:46

Re: Motor Limits
 
We're using limit switches to do the same type of thing. Two limit switches came in the kit.

If your motor was hooked to pwm01 you'd use...

Limit_Switch_Max(rc_dig_in01, &pwm01);
Limit_Switch_Min(rc_dig_in02, &pwm01);

That would (should) stop your turret's turning as soon as it hits the limit switches.

DISCLAIMER: I have not yet physically tested this yet, I didn't use any limit switches last year, and didn't get to test if that was stopping our turret today. I compiled and uploaded, but never tested the switches. That *should* work though.

You could also do it with a pot (I originally tried this way) but the limit switch, in my opinion, is much easier.

Idaman323 04-02-2006 01:59

Re: Motor Limits
 
Is the limti switch something in the program or or a piece of equipemtn to put on. Im not at our "workshop" so I cant look now..

sanddrag 04-02-2006 02:01

Re: Motor Limits
 
It is just small switch (physical) with a little metal arm on it to make it easier to press. See this pic http://www.omron.com.au/product_info...mit_switch.jpg You mount the switch such that when the device reaches maximum travel, the switch is pressed. The RC reads the state of the switch as being closed. And your program shuts off the motor (in that direction) accordingly.

Jared Russell 04-02-2006 02:02

Re: Motor Limits
 
It is a physical switch you mount so that it gets pressed when your turret is at the maximum extent of its rotation.

You could also put a potentiometer (analog sensor) or encoder (digital sensor) on the turret shaft/motor and limit the rotation manually in software.

ForgottenSalad 04-02-2006 02:02

Re: Motor Limits
 
EDIT: Ah, abw and sanddrag... beat me to it :P

The limit switch looks something like this.



You'd have to mount one at the far right and one at the far left to constrain the turret's movement. You'd then have to add those two lines of code and it should stop the motor when it hits either the far left (min) or far right (max) switch.

And as far as using a potentiometer, maybe there's a better way to do it, but I find it much easier for purposes of limiting motor movement to use the switches. Problem I had with the pot was getting instant stopping of the motor and sometimes the pot's base would turn with the motor, instead of just the bar turning, and it'd return feedback that was off and become useless for it's purpose. I find pots better for when you need to work with things along the motor's rotation, not for just stopping the motor at the ends.

Idaman323 04-02-2006 02:09

Re: Motor Limits
 
Okay, does that need to hook up to anything special? Victor (Dont think so), Spike (dont think so either). Does it just need power to run?

And does anyone know by chance how many of these you get with the kit?

ForgottenSalad 04-02-2006 02:12

Re: Motor Limits
 
Two came in the kit this year.

You have to hook them up to the digital inputs on the RC.

Make sure your programmer sets them right in the code and your electrician wire them up correctly and you should be set.

Idaman323 04-02-2006 02:34

Re: Motor Limits
 
Heh, Im not only the driver, but the only programmer we have. I am also the youngest on the team, 15..

We arn't meeting til Monday so I wont be able to check it out till later. We may need like 2 more, for our gate. Or mayeb we can somehow just make sure we dont hit it farther then needed :) Saves some money. Since we have a team of 10. Ya need all the help and money you can get, hehe.

Thanks for all the quick replys!

So has anyone set up their algorithm for the gun yet?

ForgottenSalad 04-02-2006 02:40

Re: Motor Limits
 
As far as saving money goes, I'm pretty sure you can get them at radioshack for a pretty cheap price. On a different note, good luck with your robot this year! I hear "turret" and "gate" in your posts... I draw that you might be going for both...

Idaman323 04-02-2006 19:23

Re: Motor Limits
 
gate meaning the side goals? That wasn't what I was reffering to. But our end robot will be able to push a ball or two in there if needed. The gate I was reffering to was the motor that opens and shuts the opening for the balls dropping into the gun. Because you dont want to make a shot from accross the field... thatd be ridiculous :)... but cool if we made it.

Were definatly getting closer, our teacher is getting nervous that we wont finish it, heh. Ill check radioshack on Monday or tomorow if I am by there see if they have them. Thanks.

ForgottenSalad 04-02-2006 19:35

Re: Motor Limits
 
Heh, our local radioshack appearantly doesn't stock them though I could swear I've seen them there before. I don't know if yours will, I haven't checked the website if any of the stores stock them.

Jared Russell 04-02-2006 19:50

Re: Motor Limits
 
Quote:

Originally Posted by ForgottenSalad
EDIT: Ah, abw and sanddrag... beat me to it :P

The limit switch looks something like this.



You'd have to mount one at the far right and one at the far left to constrain the turret's movement. You'd then have to add those two lines of code and it should stop the motor when it hits either the far left (min) or far right (max) switch.

And as far as using a potentiometer, maybe there's a better way to do it, but I find it much easier for purposes of limiting motor movement to use the switches. Problem I had with the pot was getting instant stopping of the motor and sometimes the pot's base would turn with the motor, instead of just the bar turning, and it'd return feedback that was off and become useless for it's purpose. I find pots better for when you need to work with things along the motor's rotation, not for just stopping the motor at the ends.

If you use a pot, you can either set the limit to be some tolerance away from the real max you want (motor overshoot accounting for that tolerance), or use a feedback loop that deadens the motor response the closer it gets to the tolerance. Either way, or with a limit switch for that matter, a mechanical stop is recommended.

Donut 05-02-2006 00:53

Re: Motor Limits
 
Limit switches definetly recommended for physical stops over pots. We had a problem last year with a pot rotating with our arm, causing one side to only shut off when it hit the limit switch, and preventing us from turning in the other direction because we designed the code to stop if it hit a certain pot value or the limit switch. A locked arm was pretty close to useless.

On the note of a gate to stop balls, you might want to use a pneumatic or servo instead. It won't be a massive amount of weight to hold back so either of these should work, if you already have pneumatics you might as well use one more (that's what we're going with).

Idaman323 05-02-2006 14:28

Re: Motor Limits
 
Well, the gate I think we decided on the window motor. And when the limit switch is hit, it will stop the motor. Will the motor still be able to turn in the opposite direction. BEcause we dont want a locked arm.

And I just went to Radio Shack, they had them. They only had two left. They were only $2.69 so I decided to buy them right then.

http://www.radioshack.com/product/in...entPage=search

Al Skierkiewicz 05-02-2006 15:35

Re: Motor Limits
 
The limit switches will be listed as "micro switches" in a catalog or at Radio Shack. Digikey and Mouser both have tons of different types. On a really important application, back up a pot with a limit switch set (mounted) to the absolute farthest travel you can allow. The pot works but might not stop a fast moving motor in time to prevent damage.

Idaman323 05-02-2006 23:36

Re: Motor Limits
 
Okay, so we got his code from Salad

Quote:

If your motor was hooked to pwm01 you'd use...

Limit_Switch_Max(rc_dig_in01, &pwm01);
Limit_Switch_Min(rc_dig_in02, &pwm01);
Where in the code would you put this? And is this all you would need to get it to work properly?

ForgottenSalad 06-02-2006 00:15

Re: Motor Limits
 
Quote:

Originally Posted by Idaman323
Okay, so we got his code from Salad

Code:

If your motor was hooked to pwm01 you'd use...

Limit_Switch_Max(rc_dig_in01, &pwm01);
Limit_Switch_Min(rc_dig_in02, &pwm01);

Where in the code would you put this? And is this all you would need to get it to work properly?

I don't exactly know why that code wasn't working for us (although it's probably something stupid and obvious that I'm missing) but all it was doing was slowing down our motors when they hit the limit switches instead of stopping them. If someone would please clear that up it would be greatly appreciated by me and I'm sure by Idaman as well.

NOTE: Yes, our speed controllers are calibrated.

Donut 06-02-2006 08:02

Re: Motor Limits
 
That should be the code to stop them. We have it in the code, but haven't tested it yet.

When hit, the limit switch should only stop your motor from moving in one direction, unless their was an error made programming it.

What pwms and inputs are you using when it's not working properly? I keep hearing bad things about pwms 13-16, if you're using one of those try a different one.

Idaman323 06-02-2006 20:56

Re: Motor Limits
 
Hmm, does that get put some where in the user_routines.c file? If so, what section of it? I woudl liek to see how it works with our motors. Thanks

Donut 07-02-2006 00:08

Re: Motor Limits
 
The call to the limit switch function can be put where ever you like it (this will be in a function called in user_routines.c or directly in there), just make sure that it is called AFTER the other code you use to set pwm values. It makes no sense to limit your motor so it can't drive further, then to command it to drive beyond it afterwards, since the last command will be the one the motor sees.


All times are GMT -5. The time now is 20:59.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi