Programming a limit switch for two buttons

We have two buttons that allow the arms of our robot to move up and down a shaft. One moves up, and one moves down. How to we implement a limit switch so that the arms do not move too far down or too far up?

I’ve seen the examples from team 358, but they haven’t been of much help. I really don’t know what to put into the begin vi or the telop(if that’s even where it goes).

How does the limit switch know when to stop? How to I put in a limit switch for code that already deviates between -1 and 1? Do I have to use an encoder to determine the rpm?

Thank you for any help you can give us :slight_smile:

Tell us more about your setup, e.g.,

  • What kind of limit switches are you using?
  • Are they mounted to be pressed when the arm is in the up and in the down positions?
  • How are they wired-Normally Open or Normally Closed?
  • What kind of motor controller are you using, e.g., Talon using PWM?
  • How are you controlling the arm motor, e.g., joystick, button?
  • How are the controls expected to work, e.g., push forward on the joystick the arm goes down, pull back and the arm goes up?
    *]What have you tried that didn’t work? What were the symptoms of the failure?

And…which programming language are you using?

This is the LabVIEW sub-forum…

I need to put a postit on my monitor to check that.

Check the find examples page under help in labview. It will give you the code for seeing if a limit switch is true or false. After you are able to read the switch think about using a select statement and a case structure to achieve you desired outcome.

Begin.vi gets the Open connected to a RefNum Set (with an incoming arrow) in order to define the hardware pins and give them a name to use later.

Teleop.vi gets pretty much everything else, starting with a RefNum Get (with an outgoing arrow) connected to either a Get or a Set, depending on whether you’re reading a sensor or controlling an actuator.

This question in particular clues me in that you need help with the mechanical situation as well as programming.

A limit switch is simply a switch that is engaged as a moving part reaches (or approaches) the design limit of its range of motion. There are a wide variety of designs; click the link to see a nice sample.

Programming and wiring to take advantage of a limit switch is rather simple - you just have to make sure that when the limit switch is engaged, any attempts to move the actuator in that direction are nullified. You still want to allow motion away from that limit, otherwise the actuator will be unusable.

The real key to making a limit switch work well is in selection, placement, and mounting, so that it consistently and reliably knows when to stop.

As you will probably notice, many of the limit switch designs feature a rather long arm which is in contact with the switch button somewhere near its fulcrum. This is because you don’t want the switch receive the force of the moving actuator, just report it. Often, the switch body is mounted beside the actuators path, not in the path. Alternately, the limit switch can be mounted inside/behind the mechanical stop so that only the plunger or arm reach into the path of the load.

Selecting a style and mount for a limit switch is best approached creatively. I’ll spend the rest of this post in a litany of examples; perhaps one of them will inspire you. There are also two examples shown in the attached images.

Our robot this year has twelve limit switches, in three distinct styles:

  1. We have two switches to detect as we’re beginning to drive onto the scoring platform. These are actually optical interrupts mounted inside the front plate. We mounted some 3/16" steel pins on springs and passed them through holes in the KOP chassis intended for #10 machine screws. When we hit the ramp, the pins are pushed up between the sensor arms and interrupt the light path.
  2. Our lift has four switches. One is at each end, and another is about five inches inside of these. These are roller switches (similar to the ones pictured with the cams below), and are mounted so that the lift plate pushes the rollers to the side as it reaches the locations. The “warning” switches will enforce a reduced speed towards the nearby limits.
  3. We have six plunger style switches (similar to many refrigerator light switches) mounted on the front of our lift plate which activate when we make contact with a tote or RC. We have so many because of the corrugated pattern on the side of the totes; they are wired in pairs so that they only use three DIO ports.

Around the house and car:

  • The switch that turns the refrigerator light on and off when you open and close the door.
  • the switch in the car door that does the same thing with the dome light. Some cars also have these in the tailgate/trunk, hood, glove box, or fuel door, either for task lighting or to trigger a warning light on the dashboard.
  • the switches in the doors of the washer and dryer and microwave oven which shut off hazardous processes when the doors are open. Copiers, printers, food processors, and a variety of appliances have these sort of switches.
  • inside the toilet tank. In most cases there’s no electricity; it’s a water valve that’s being switched when the water reaches a limit
  • if you have an older-style thermostat on your heater/AC, it’s really a mercury limit switch. There’s a bimetallic strip that coils and uncoils as it heats and cools, which changes the angle of the mercury switch. When the angle reaches a certain limit, the mercury rolls to the other side of the switch, opening or closing a circuit

    mechanical-limit-switch.gif
    cr201.jpg


    mechanical-limit-switch.gif
    cr201.jpg

This is what our limit switch looks like: https://encrypted-tbn3.gstatic.com/images?q=tbn:ANd9GcQeJ09K9X-nSayeS_Ydjb4xOiCWY7yliAk631vrr0xYWMp2FzsgSw

We have one at the top of our robot that becomes closed when the arms hit it. We may or may not add one to the bottom of the robot for the same effect. We are using talon via PWM. The arms are controlled to go up and down with two separate buttons on a PS3 controller. We are using labview.

We haven’t tested anything with the limit switch since we’ve not been able to complete the programming. The main problem is that we can’t figure out how to combine the examples titled switch and limit switch. One appears to show both the begin and teleop stages, but the other only show teleop. We can’t figure out how to allow our motor to stop when the switch is true.

The Begin.vi part is common to every example that uses switch inputs. Replace the Teleop.vi part with the code in the example, suitably modified for your purposes.