FIRST Robotics Competition Discussions

Showing results for 
Search instead for 
Did you mean: 

Limit Switch Questions.

Go to solution

So i was going trough various example pictures for limit stwitches both here on of the NI community, Cheif Delpi, and other varios randome team websites with limit switch diagrams, but i havent been able to figure out where to start.

I'v looked up a few different ways people have made their codes over the years, but what i dont understand is which way is best to set up the code,

like in Team 358's 2019 codes?LabVIEW Limit Switch Example

or would it be best to create a diologe box in an example code i saw is an earlier queston MArkBala answered in response to Omar_II' question on limit a limit switch.()

Either way im not totaly sure what to do. The program i have right now has some other diologe boxes for my joystic code, but im not sure how i'd be able to combine   the two(as in the Limit switch code with the andJoystick code). (And the diologe boxes are in my teleOp.)

Any help would be greatful! Im a second year programmar with little to almost no knoledge of complex programing.

And to just exempt programing in general for the limit switch, is it legal to hook a limit switch directly to a jaguar? I had seen this in a form/thread from 2009 or so, but in that same thread it said that this had been deemed illegal that year. Is it legal to do that this season/year? As in hooking up a switch to the jag so that when it reaches a certain distance, it'll hit the switch and cut the power. (no programing involved)

0 Kudos
Message 1 of 2
Accepted by topic author duckhead96

The "best" way to program a limit switch depends largely on what sort of functionality you want out of it. I'm not sure what dialogue box you are referring to, but in the case of programming on a cRIO it is best to avoid dialogue boxes as you will usually want to turn your code into an executable in the end and dialogue boxes will not work when you are running an executable on a cRIO since there's no user interface. To explain the three examples above:

1) Team 358's single limit switch code sets the motor output to zero if both the joystick is telling the motor to move in the direction of the limit switch and the limit switch is on.

2) Team 358's second limit switch code uses a series of functions. It uses a In Range and Coerce Function. There are two Select functions each hooked up to one of the limit switches. If the forward limit switch is on then the the select function sends 0 to the In Range or Coerce Function as the maximum of the range, otherwise a 1 is the max. If the reverse limit switch is on then the select function attached to this digital input sends 0 to the In Range or Coerce Function as the minimum of the range, otherwise the minimum is -1. The value of the In Range and Coerce Function is then sent to the Set Output VI.

3) The third example you posted once again uses select functions. It first checks if both the upper limit switch is on and the joystick is sending a signal to move forward. In this case it sets the output to zero, otherwise it passes the output along. It then checks if both the lower limit switch is on and the joystick is telling the motor to move in reverse then it sets the output to zero if both are true.

All three of these implementations should work. Which is best for you is dependant on how you want your switches to behave and how you want to set up the logic.

As for whether physical limit switches are legal or not, it would be best to look in the FRC manual which you can find here, . I believe they talk about limit switches in section 4.1.9.

Miles G.
National Instruments
Staff Applications Engineering Specialist
0 Kudos
Message 2 of 2