FIRST Robotics Competition Discussions

cancel
Showing results for 
Search instead for 
Did you mean: 

Limit Switch Labview Programming - HELP!!!

I am trying to make the shooter arm withdraw after launching and hitting a limit switch. Upon hitting the limit switch, I want the shooter controls to be disabled while the arm is moved to its original position. How would I program this?

(Program image in the attachment below)

0 Kudos
Message 1 of 13
(9,184 Views)

The best method to do this is to develop a state-machine and only react to the joystick button press when it is in the "Fire" state.

www.frcmastery.com has a great example video creating a FRC state machines found at

http://www.frcmastery.com/labview-for-frc/2010-videos/state-machines/

The video was created using the 2010 template but it is still very well done and the concepts are still relevant.

Hope this helps

Mark

0 Kudos
Message 2 of 13
(4,266 Views)

Which function(s) would I be using? WPI Robotics Library->I/O->Digital Input ?

0 Kudos
Message 3 of 13
(4,266 Views)

Unfortunatly the answer is not that simple.

The WPI Library contains vis that read sensors or set outputs.

In order to acomplish your goal you will need to build code that inteligently sets outputs based on joystick and sensor inputs.

To do this you  will use Case Stuctures, Shift Regiters, TypeDefs and other functions to build the inteligent code.

A state-machine is a combination of functions called a pattern that helps a programmer create inteligent code to do what you are asking. The video link explains what a statemachine is and how you would create one in the FRC environment.

Mark

0 Kudos
Message 4 of 13
(4,266 Views)

How do I know what DIO Channel the Limit Switch(es) is/are?

0 Kudos
Message 5 of 13
(4,266 Views)

If you go to Help>>Find Examples..

Go to the Browse tab

Open the FRC Robotics>> Digital folder and select "Simple Digital Output.lvproj"

FRC Digital PM.png

When you open it you should see the front panel.

Digital FP.png

You will need to select a set of DIO pins on the side car to connect your limit switch.

The row that the limits switches are connected to will be the DIO number you select in the DIO channel drop down.

Example:

  1. Connect you limit switch to Row 6(Sig) and 6(-)
  2. Next Select DIO 6 from the DIO Channel Dropdown.
  3. Run the program while connected to the cRIO.
  4. You should see the Digital Input Value indicator change state when the limit switch changes state.

We talked about wiring limit switches in posts last year found here.

https://decibel.ni.com/content/thread/16301?tstart=60

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

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

https://decibel.ni.com/content/thread/16333?tstart=60

0 Kudos
Message 6 of 13
(4,266 Views)

How do I run it? I'm new to this, so how would I run it while connected to cRIO?

0 Kudos
Message 7 of 13
(4,266 Views)

If you haven't setup your cRio and driver station yet start by following all the instructions in the LabVIEW Quick start guide

found at

https://decibel.ni.com/content/docs/DOC-34661

0 Kudos
Message 8 of 13
(4,266 Views)

I already had cRio set up; what I meant was: do I just open the vi and click, "Run"?

I did that, and got this

Capture.PNG

0 Kudos
Message 9 of 13
(4,266 Views)

You are going to have to give step by step details of what you have done so far in order for me to help you further.

0 Kudos
Message 10 of 13
(4,266 Views)