Right now my team is making a tower with a hook system that goes up and down. As of now I have the tower programmed so I can control the speed the thing goes up using the axis 3 whiling holding a button, and the same for the thing to come down. Right now we have two limit switchs hooked up to the hook thing so when the object hits the limit switch the motor Should stop in that direction. How can I program a limit switch to do that? I don’t know how to program a limit switch at all. Below I have a picture of my code for the motor going down without a switch, so how do I make that work until I hit the bottom limit switch thanks a ton. Visuals are awesome. Thanks
I’ve attached screenshots of how our team used limit switches to limit movement in 2011. The first screenshot shows how we initialized our limit switches, and the second shows how we implemented them in our Teleop code.
The VI with the arrow and question mark in the second screenshot is In Range And Coerce, which is a VI many people don’t know about - primarily the Coerce part. It takes whatever number you input (in this case, our motor signal) and forces it inside a specified range if it falls outside the limits.
In our code, if the upper limit switch is pressed, it sets the upper end of the range to 0 so we can’t move up any farther. (So our range is -1 to 0.) Likewise, if the lower switch is pressed, we set the lower end to 0 (range: 0 to 1).
So what should I add, another case structure or what to make it do what I want right now when the button isn’t hit, but stop it when the button is on the limit switch?
I’m not sure I understand what you’re trying to do…are you trying to control your tower height with a joystick, or with a button? I’m not sure what your control scheme is, so I’m not sure how you need to code your limit switches.
So should this code work, for an upper limit and a lower limit, but what should I put in the case structure for default then? Thanks a ton everyone.
That depends. Why is the code conditionally reading the joystick? What is the down/default thing that is determining the joystick shouldn’t be read?
If you are in the condition where the joystick isn’t controlling the mechanism, what is? That has to produce the number to drive the motor.
Greg McKaskle
First off, I don’t really see how you could ever get a value of less than 0 when you modify the throttle input like that. If I’m understanding correctly, the code you wrote would scale the throttle value from 0 to 1.
Regardless, though, I would use another Select to choose your output rather than a case structure. I’ve attached a screenshot explaining (very roughly) how I would structure this.
Right now my motor doesn’t even move up or down. The jaguar light is a solid green when the code is enabled, but when I click and hold the up button or down button and push forward the throttle the green light doesn’t change at all it appears like the motor is at 0 constantly, so I don’t know if the pwn is bad or not or how can I tell just by looking at it? My big question is assuming the code is right, it has to be the wiring, and assuming that the jaguar is wired right it has to be the limit switch wiring. My coach says that if we leave the limit switches unhooked altogether the limit should be false by default, because there is no limit switch plugged in. Is that true when a limit switch isn’t plugged in it’s naturally false in the code, or since the limit switch isn’t plugged in the labview reads it as true, because my motor isn’t moving and the only reason I see is since the limit switch isn’t plugged in it’s screwing it up? Also how is a limit switch suppose to be hooked in if we want it normally open. Thanks for all the help or if you do see an error in my coding let me know thanks. picture with the limit switches doesn’t work, but the picture without the limit switches in it works just fine so I don’t know where the problem is if it’s in the coding.
I’d look for a document on the Jaguar, but I believe that an open switch on the Jaguar prevents movement in that direction. Put jumpers on the Jag limit connectors and try again.
Greg McKaskle
Yea, limit switches wired into the Jaguar directly must be Normally Closed.
The Jag only goes in that direction if the pins are shorted.
An open circuit prevents movement.
I have my limit switches plugged into the DIO… But if I were to hook them up to the jaguar directly do I need to code anything for them or does the jaguar do it all automatically? Thanks
automatically.