FIRST Robotics Competition Discussions

cancel
Showing results for 
Search instead for 
Did you mean: 

Double Limit Switch for Motor

We have two limit switches we want to prevent the motor from going too far in reverse as well as forward. We have some code that uses the limit switches to stop the motor from moving, but have not been able to get it to work. Also, we are having trouble getting indicators for the DIO's on both the driver station and the dashboard. Code attached. Thanks for your help!

Download All
0 Kudos
Message 1 of 3
(4,338 Views)

In Teleop, your "In Range and Coerce" needs to include the upper limit.

Right now it only pays attention to the lower limit switch.

Right-click on the "In Range and Coerce" and choose "Include upper limit" from the pop-up menu.

You should check that the boolean values coming from the limit switches are what you expect them to be.

If you run in Debug you can probe the wires to see the values generated by pressing/not pressing each switch.

The values differ depending on whether the switch was wired Normally-Open (NO) or Normally-Closed (NC).

On your Dashboard I don't see where you added the "Digital Input 2" boolean indicator.

I'm probably just overlooking it.

0 Kudos
Message 2 of 3
(2,840 Views)

If you haven't already please read these discussions

https://decibel.ni.com/content/thread/16150?tstart=0

and

https://decibel.ni.com/content/thread/16068?tstart=0

As these discussions explain your code will only work if you have a NC limit switch connected to Sig and [-] on the digital side car

If you want to see the limit switches on you Dashboard you will need to add an indicatior to the Front Panel and wire it to a

SD Read Boolean vi in the Dashboard pallet.

indicator.pngcode dashboard.png

After you have coded in all your indicators you will need to build the new dashboard into an executable.

Follow the tutorial on building a new dashboard.

Make sure the exe is named dashboard.exe

Then rename the old dashboard and place the new one in the same folder.

My dashboard folder is C:\Program Files (x86)\FRC Dashboard

When the driver station starts it goes to this folder and runs dashboard.exe

Good Luck

Mark

0 Kudos
Message 3 of 3
(2,840 Views)