FIRST Robotics Competition Discussions

cancel
Showing results for 
Search instead for 
Did you mean: 

What is wrong with my code?

I have had troubles running the LabView on the robot. I can't get it to control a PWM drive. I wrote some simple code to send a signal to the drive through the front panel but nothing worked except the drive light went solid while the other unused drives flashed. This tells me that something is happening, but not much. Later I will add joysticks but I wanted a simple version to be working first. I have included photos for addition descriptoin. Please help.

begin VI.png

TeleOp VI.png

0 Kudos
Message 1 of 7
(7,379 Views)

Hi,

so you are changing the value on the front panel right?

I'm not too sure but it is probably easier to just incorporate a joystick than to mess with the front panel control.  Or just try setting constants before you deploy the code to get an idea.

Check out my code below.  Just focus on the Drive References (the rest is for our arm system).

Also don't forget to incorporate the Watchdog like in my code.

My code runs 4 motors (2 PWMs) on 2 joysticks (Tank drive). So joystick 1 will run PWM 1and joystick 2 will run PWM 2.

Begin VI

Begin.png

Teleop VI

Teleop.png

Finish VI

Finish.png

There ya go.

Hope this helps.

Davis Catherman

0 Kudos
Message 2 of 7
(3,415 Views)

I don't know if it's just for your debugging purposes, or if this is the entire extent of the problem, but I noticed that in your TeleOp code the pause button in the toolbar is red.  That means the VI will pause when it executes, ie not run until you un-pause it.  So, start by making sure your VI is actually running when you think it is.

If that isn't the source of the problem, try making use of the error clusters.  Specifically, wire the "Error Out" terminal from get motor reference to the "Error In" terminal of set motor, then put an indicator on the error out terminal of set motor and see if you get an error.  You might also put a probe on the wire to make sure that it executes (if it doesn't, the timestamp on the value won't update).

Are you connecting the Driver Station when you're running this code?  If not, make sure it's connected.  Do you get any errors on the Driver Station?

I'm unfortunately not currently working with an FRC team so I can't test this, but my understanding of the Safety Config document is that the watchdog timer that Davis mentioned is not required this year.

0 Kudos
Message 3 of 7
(3,415 Views)

Yea,

that was mentioned in an earlier thread but i kept getting timeout errors after so many seconds and it kept repeating. 

When i added the watchdog it became fixed.  Also i was at a pre-ship tournament and another team was encountering this error, so i added the watchdog to their code and it worked. I don't know if you have to add the safety config connections in the code or not.

But either way, your issue is running the code, not a timeout error.

Davis Catherman

0 Kudos
Message 4 of 7
(3,415 Views)

Thanks guys for giving me a helping hand. Out of 230 views only you two helped and I appreciate that. At the moment I can't work on it, but as soon as I get the chance I will try to get back to you if it was successful or not. Please stay tuned because this may or may not work.

0 Kudos
Message 5 of 7
(3,415 Views)

For some reason whenever I try to edit one of the joysticks on LabView, the other joystick will change too. It is as if they are the same thing but from what I can tell they are not hooked into each other. This is extremely frustrating and I would like someone to tell me what exactly is going on.

Cap 1.png

1. I set Joystick 1 to USB1.

Cap 2.png

2. I set Joystick 2 to USB2.

THE REAL CAP3.png

3. Joystick1 is now set to USB2.

Cap 3.png

What is the need to have two of the same thing here?

If you have any idea on what is going on, please reply.

0 Kudos
Message 6 of 7
(3,415 Views)

There's nothing weird going on here other than a slight misunderstanding about how LabVIEW works.  You're calling the Open Joystick and Registry Set subVIs (functions) twice, once per joystick.  Presumably the calls for Joystick 1 happen first, followed by the calls for Joystick 2.  When you open the VI's front panel you're seeing the values with which that function was most recently called, so you're seeing the values for Joystick 2.

0 Kudos
Message 7 of 7
(3,415 Views)