LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Slow Vi using analog I/O

Hello,

 

I'm having issues fixing my labview code to have an efficient response time. I tried multiple things to fix my issue, but can't seem to find a solution. I'm not as comfortable with LabVIEW as I am with other coding languages so troubleshooting this problem has been tough for me.

 

The purpose of this code is to take in an analog input of a limit switch being pressed, and upon doing so, switching the control from one channel to the other channel. The code works the way I want it to, but the issue is that it's just too slow for the application. Any assistance with this code would be much appreciated.

0 Kudos
Message 1 of 5
(2,798 Views)

"Too slow" is not very precise.

 

The program appears to require about 2 seconds for each interation of the loop due to the sampling settings on the Formula Waveform VIs.  Is your program taking much longer than that?

 

There are far easier ways to generate constants to feed to the DAQ output.

 

You have a lot of duplicated code.

 

What kind of DAQ device are you using? I do not have the DAQ Assistant so I cannot tell what settings you have used.

 

What kind of voltages and timing are required to switch the control channels?

 

Lynn

0 Kudos
Message 2 of 5
(2,781 Views)

Thank you for the response, I'll number your questions and statements try to respond them the best I can.

 

1) I'm looking to get a 200ms response time or better

2) My program takes about 3 seconds to make an output response

3) I thought there might be. Do you have an example for me?

4) Which part could I do without?

5) I'm using a NI ELVIS

6) I'm using the constant 5vdc power supply as the trigger voltage.

 

Justin

0 Kudos
Message 3 of 5
(2,756 Views)

Justin,

 

1. and 2. Most of the 3 seconds comes from the signals you are feeding to the DAQ Assistants. The 2000 constants in the image are the sampling parameters: 2000 samples per second and 2000 samples. That means you have a 1 second signal. You do this twice with different amplitudes and formulas.  To get to less than 200 ms with this program structure you need to change the sampling rate or the number of samples.

 

Sampling data.png

 

3. The code in the case structure is identical in both cases except for a Stop Task (which probably is not needed at all) and the boolean output.  Move the DAQ stuff outside the case structure and only have one copy. The code in the two frames of the sequence structures is the same except for the formula and amplitude. Create arrays of the formula strings and amplitude values and put just one copy of the code in a for loop. You can use the error wires to create data dependencies to make things happen in the desired order.

4. and 5. Anything which is duplicated probably only needs to be there once. If ELVIS retains the values put on the outputs, you would only need to write one sample for each value at the time you want it to change. Your code writes 2000 identical samples and then 2000 more of a different value.

6. How does a constant power supply generate a trigger if it never changes?

 

I presume the DAQ Assistant2 reads the limit switch.  However, nothing in your code behaves differently as a result of the inputs except the boolean indicators.  If the DAQ writes are supposed to change the channel, you need to write something different for false and true.

 

Is there a reason for using buttons for indicators? This tends to confuse users who wonder why pushing the buttons does not do anythimg.

 

Here is a cleaned up version which should work the same as yours.  I do not have any DAQ hardware or the DAQ Assistant so I did not test.

 

Lynn

0 Kudos
Message 4 of 5
(2,737 Views)

Thank you for all of your help.

 

My apologies for the late response, but I was just able to return to my DAQ today. I was able to run the code today and the time delay is no longer an issue.

 

The button indicators were primarly for me to make sure the program was behaving the way I wanted it too and have a display for the boolean logic. I also wanted them because I planned on using the boolean cases as flagged events. This way I could switch between channels without ever having both channels on at the same time. The bicep true and tricep true would be the events that trigger the switch between outputs.

 

Justin

0 Kudos
Message 5 of 5
(2,698 Views)