|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
|
|
Thread Tools | Rate Thread | Display Modes |
|
|
|
#1
|
|||||
|
|||||
|
Re: Limit Switches help.
As a C beginner, I wouldn't reccomend you use ternary operators. I've been through various programming courses and have wrote software for many years and I don't use them.
|
|
#2
|
||||
|
||||
|
Re: Limit Switches help.
What it looks like the original poster wants to do is limit the motion of a motor based on whether a limit switch is active.
It looks like you want the motor to go only in reverse (less than 127) when that switch is active. I'm not too good with C, but in pbasic, you'd use the MAX and MIN declarations, e.g. p1_y = p1_y MAX 127 MIN 0 I'm not sure if there is an equivalent in C, or how it would be implemented, but I think that's what you'd be looking for- to set that condition when the switch is enabled. |
|
#3
|
|||||
|
|||||
|
Re: Limit Switches help.
Be careful when using limit switches, eh?
On our bot, we had three switches on our lift system; one at the bottom, top, and middle (height for grabbing 2X ball). Now the problem with our lift is that if we kept trying to run the motor to lift it up past its max, it would bend the shafts. So we tossed the limit switch at the top so when it tripped we couldn't make it go any higher even if we tried. Our programmer decided to allow the lift to raise up again when we dropped it down to trip the middle limit switch (God knows WHY he did it THIS way... -_- ![]() Anyhow, in one of our matches, our robot fell backwards quite a bit and the top limit switched tripped from hitting the PVC tubing of the stationary goal. Because it tripped (when our lift was all the way down) we couldn't raise the lift up at all (we couldn't trip the middle switch) and couldn't hang. So after that we forced our programmer to put in an override switch on the joystick. So whatever it is you're doing with limit switches, you might want to consider using a button or something to override the code if need be. ![]() |
|
#4
|
|||||
|
|||||
|
Re: Limit Switches help.
Or just cover them up. It's an engineering bug, not a software bug. But good idea.
? 127 : Joy_1 is a short-hand If-Else. In the form of A ? B : C, If A is true than the ternary returns B, else it returns C. It's also really nice for macros. The pair of If's is for bottom and top. And Aliases are a must for many things. PS- When do you stop being a beginner C programmer and move up to the next level? This is my fist real use of C. |
|
#5
|
||||
|
||||
|
Re: Limit Switches help.
Quote:
![]() |
|
#6
|
||||
|
||||
|
Re: Limit Switches help.
Thats good to know, im working on a program for auton that needs theese switches so as soon as i get ahold of the robot again im going to try what ever i can.
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Raising the $3500 limit? | Eric Bareiss | General Forum | 25 | 01-04-2004 03:15 |
| Limit switches | Team168 | Programming | 8 | 10-02-2003 16:22 |
| Team selector switches on ISAAC | Lloyd Burns | Robotics Education and Curriculum | 0 | 17-12-2002 08:32 |
| Need help with custom switches | archiver | 2001 | 3 | 24-06-2002 00:35 |
| Wiring custom toggle switches into operator interface | DanL | Electrical | 9 | 13-02-2002 17:13 |