|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
|
|
Thread Tools | Rate Thread | Display Modes |
|
|
|
#1
|
||||
|
||||
|
Re: Using a limit switch to limit motion
Now that I have cleaned my glasses.....
One way that you can do what you need is to create you own functions like the ones in the FRC default code that I will copy in here. Just use these in place of the code you are now using that forces your arm back and then allows it to move forward again. These examples are straight out of the default code and will need to be modified to match your existing code. These are examples only, and will not work "as is". Code:
void Limit_Switch_Max(unsigned char switch_state, unsigned char *input_value)
{
if (switch_state == CLOSED)
{
if(*input_value > 127)
*input_value = 127;
}
}
Code:
void Limit_Switch_Min(unsigned char switch_state, unsigned char *input_value)
{
if (switch_state == CLOSED)
{
if(*input_value < 127)
*input_value = 127;
}
}
For your code, substitute in your PWM to be limited for "*input_value" and your limit switch input for "switch_state". I assume someone on your team understands code, at least in a limited way, otherwise you would not have been able to get your code operating the way it is already. They should be able work with these. |
|
#2
|
|||
|
|||
|
Re: Using a limit switch to limit motion
Thanks for all the suggestions. Potentiometers are a bit beyond us (we're FTC, and I don't think Vex has a pot), but the gravity suggestion got us thinking that we need little or no motor input to back away from the limit. Before, we were running the motors at full power when we backed away, so there was lots of wobble. Slowing the motors, there was far less wobble, and it's now in the tolerable range.
|
|
#3
|
||||
|
||||
|
Re: Using a limit switch to limit motion
Quote:
http://www.chiefdelphi.com/forums/sh...ad.php?t=59901 The entire thread is useful, but the simplest way to do it is located in the second-to-last post. |
|
#4
|
||||||
|
||||||
|
Re: Using a limit switch to limit motion
Quote:
|
|
#5
|
||||
|
||||
|
Re: Using a limit switch to limit motion
Quote:
I won't have to make my own any more! |
|
#6
|
|||
|
|||
|
Re: Using a limit switch to limit motion
After some futzing with the terminal window, our programmer was able to retrieve the joystick position and use it to stop upward motion on the joysticks if the limit is reached, but still enable the joysticks for downward motion (now there is no wobble). His comment on this discovery was "Programming with Vex is Jawesome!"
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Using a limit switch | thunderbolt | Programming | 1 | 02-04-2007 19:36 |
| limit switch | wedellm | Electrical | 4 | 16-02-2007 13:01 |
| Limit Switch Basics | JWSnedden | Programming | 6 | 30-11-2006 19:48 |
| Limit switch in easy c? | chadbarbe | Programming | 6 | 02-02-2006 09:51 |