LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Issue with finding time difference between 2 signals and displaying a light

Hi experts!

I am having some issues with my Labview code (I am new to coding the software, and my lab has an older version). My goals is to find the time difference between 2 signals coming in, and display a light (green or red) if this time is within a certain range. I want it to continue doing this for each pair of signals that comes through, as my participants will be completing a task where they're moving between 2 targets for a set of 100 or so and I want them to know if they're moving fast enough each time. I've set up my DAQ assistant and tested the code with artificial inputs and the code shows no errors and the input is successfully graphed. However, there is no change in the light colour, and no display of the time difference. I'm wondering if anyone has some ideas as to what I'm doing wrong and what I can do to fix this.

I have tried to used case structures to identify when the first target is left and a 5V pulse changes to 0 and when the second target is achieved and changes from 0 to 5V. If this is true, I then want the time that those events happened to be recorded, the difference found, and then have that compared to a predetermined time. Should it be beyond 10% of the predetermined time, I want a red light displayed and should it be within this, a green light displayed.

Happy to give as much detail as needed. Thankyou so much!

0 Kudos
Message 1 of 7
(222 Views)

Use DAQmx Examples instead.

Most shipping examples return data in waveform data type. The waveform datatype contains the timing information including start time and time interval. See Accuracy of the Waveform Timestamp Returned by NI-DAQmx

-------------------------------------------------------
Control Lead | Intelline Inc
0 Kudos
Message 2 of 7
(211 Views)

Let's assume the signals are fine and this is a programming question.

 

As a first step, you need to understand the basics of dataflow, so start with the learning resources.

 

  • Your stop terminal needs to be inside the loop, else you just get the value when the loop started. Changing the boolean later will no be noticed by the code.
  • Code segments will only output data once they complete, meaning that everything after the loop will never get any data, because the loop never completes. All that code needs to be inside the loop if it should react to the current data while the loop is running.
  • Your timing makes absolutely no sense, because you most likely only see one tick per iteration when the other is zero from the default tunnel. The difference will be a gigantic number!
  • Your shift register has no purpose because you never even look at the output on the left. It is just a glorified output tunnel.
  • etc.etc.

 

We can give much more specific help once you attach your VI. We cannot debug pictures because many things are hidden. For example we cannot see how the express VI is configured and how many points you get. Wiring a dynamic boolean data to a case structure probably does not do what you think it does..

0 Kudos
Message 3 of 7
(176 Views)

See if this simple simulation can give you some ideas...

 

altenbach_0-1716571691879.png

 

0 Kudos
Message 4 of 7
(170 Views)

Thankyou so much for your ideas and suggestions! As I said this is very new to me, so just finding my way, obviously with lots of errors at this stage.
Are you suggesting that the latter part of the code that displays whether or not the time difference satisfied the predetermined criteria and displays a light also be in the loop?

I'm working through your suggestions currently, and have attached the vi in the meantime.

Thankyou 🙂

0 Kudos
Message 5 of 7
(153 Views)

Thankyou, I will try this and see how it goes

0 Kudos
Message 6 of 7
(150 Views)

@cr922 wrote:

Thankyou so much for your ideas and suggestions! As I said this is very new to me, so just finding my way, obviously with lots of errors at this stage.
Are you suggesting that the latter part of the code that displays whether or not the time difference satisfied the predetermined criteria and displays a light also be in the loop?

I'm working through your suggestions currently, and have attached the vi in the meantime.

Thankyou 🙂


As already discussed, the code you have attached is completely wrong, of course. I don't have DAQ installed, so I cannot see how your express VI is configured.

 

My earlier example assumed that you get both full traces and see both peaks. If you get the data one point at a time, you would just put the tick into a shift register whenever signal A goes high and get the time difference when B goes high. Should be equally simple to implement...

0 Kudos
Message 7 of 7
(119 Views)