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.
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.
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.
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.