REED SWITCH TROUBLE IN TELE-OP

Our reed switch isn’t working the way we want it to, and we were wondering was there anything wrong in the code ? We have a water wheel mechanism on our robot that holds the game pieces until we press the button and it moves forward, we want everytime that we press the button the water wheel which is hooked to a speed controller…moves forward until the reed switch is triggered and then to stop the motor…and with us pressing the button again, the same tasks happens.

Thank you very much.

Here is our code in the Periodic Tasks.vi:

Reed Switch Code.jpg


Reed Switch Code.jpg

I’d think that code would have a problem clearing the Reed switch.
If the reed switch is on, from the start or from the last time it stopped the sequence, then it will prevent it from ever running again.

You need a frame or a loop (tied to the one you already have) that makes sure the reed switch turns off before looking for an ON again.

So if I added a frame after the motor has turned on, with the reed switch cutting off, then would it stop, and would the code work ?

And another question that I had is that if I am calling all this in the Periodic Tasks, do I need to call it in the Tele-Op also ? Right now we have the code in both. The reed switch code pictured above in the PT.vi, and establishing which button to push in the TO.vi, and what speed the motor should be…

The code should be in a single place, not several places. That’d be like two people trying to type on a keyboard at the same time using the same keys.
It’ll interfere with itself otherwise, and the long pauses would disable Teleop.

Periodic Tasks is the right place for a sequence like this.

  1. Check for start of sequence (joystick)
  2. Turn motor on/check for reed switch OFF
  3. Check for reed switch ON
    *]Turn motor OFF

Okay I understand what you are saying referring to the calling it in both places. Thank you on that. Now I’m not quite sure if we actually checked to see if it was on in the added sequence we just made ?





The reed switch check will depend on if it’s wired to be Normally-Closed (NC) or Normally-Open (NO). Many types of switches give you the option.

The code as you have it is good for a switch that’s wired to be NO. The output of the DIO Get will be true when the switch is off and false when the switch is on.

You might still need to have your original check for when the joystick button is released, before allowing the sequence to queue up again.