From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Simplifying Program

So I made my joystick counter and it works exactly as I want it to. All I had to do was make it monitor 6 joysticks simultaneously, so I essentially just copied and pasted my program 5 times and edited the DAQ assistant. The program itself now takes up a lot of space and is pretty clunky looking so I was wondering what the best way to go about streamlining it was. I don't know if I want to put all the lines through one DAQ assistant because the counter counts up when the while loop goes through an iteration so I don't want one faulty joystick to prevent a cycle from finishing and therefore stopping the counter on all the others. Here's my program so you can see what I'm talking about.

 

0 Kudos
Message 1 of 3
(2,192 Views)

Hi GHLabTech,

 

I took a look at your code and I don't understand how it works.  I am assuming the Direction Acutations is to track how many times a certain direction was pushed.  If that is the case the value should never increment.  You are converting a True to False and then changing that to a 0/1 (it will always be zero).  Then adding zero to the number.  I cut that section out and did some testing on it and the count never changed (0+0=0).  The case structures you have to increment the count can be reduced to the logic below.  You can take this as a subVI and that will help clean things up some. 

 

Update Count.png

 

There also seems to be some other unneeded logic in the code.  Why are you using local variables when you can wire the actual value to the case structures.  The variables are sitting right next to the original wires.  Just wire it over.  This will help reduce race conditions. 

 

You may also consider creating the DAQmx code from the DAQ Assistant and creating a subVI out of the loop.  Then you can just have 6 of your subVI with a control for the channels you want to read from.

 

I hope this helps some. 

 

Best Regards,

Bryan H.
0 Kudos
Message 2 of 3
(2,165 Views)

I've actually hooked the DAQ up to my joystick tester and it actually does work. I programmed it the way I did to ensure that the joystick was actuated and released to make a count. So it actually counts up when the direction goes false. That being said I can take what you showed me and use that to clean up my program a bit. Thanks for the help!

 

Edit: Can anyone point me in the direction of a good how-to or tutorial on how I can log my data, i.e. maybe a simple text or excel file which gives me a start and stop time, and the results on all my counters?

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