LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Need to output time

Hi! I've got a slight problem with my Labview code, and I was hoping you could help me. I'm outputting counts from three sepearte channels and would like to know the time (how many milliseconds from when the vi started) each value was taken. Right now, I just get three columns, each with the counts taken from my three channels. I need a fourth column to specify the time. I've included my code to give you a better view of what i'm talking about.

Thaks!
Katie
0 Kudos
Message 1 of 6
(3,123 Views)
Use the tick count vi as a time base outside the while loop and subract this from a tick count vi inside the while loop to get the elapsed time since the start of the vi. See attached. NOTE: You can't run the attached vi because your attachment did not include some sub-vi's, but you should be able to see how to do what you want.

Dave.
==============================================

0 Kudos
Message 2 of 6
(3,123 Views)
Unfortunately, that doesn't work. I'm attaching a sample output file and my VI (with all necessary subvi's). Only 10 time values are read out and they are very wrong (programs runs for 5 sec, but the time is at 27218 milliseconds.) Any advice on what's going on would help.

Thanks, katie
Download All
0 Kudos
Message 3 of 6
(3,123 Views)
I am pretty sure the tick timing you see is accurate. I stripped down your code to just the tick part and attached it below. You will see that it works as expected.

To get better timming stats for the first run, you might consider puting the outside tick count in a sequence that is allowed to run after all the counters are configured but before the while loop.

There is the remote possiblity that the tick count rolled over while your program was running. Do you get the same results everytime you run your code? You might cosider just running your data points to the edge of the while loop, right clicking on the tunnel, and choosing to auto index. That should simplifiy your code somewhat and help you troubleshoot the outputs.


As far as further troubleshooting goes, I recommend paying attention to the counters. There may have a strange configuration setting that returns many values and not one value at a time.
0 Kudos
Message 4 of 6
(3,123 Views)
Yeah,I keep getting the same results, so I don't think it's the timer turning over. I worry that it might have to do with my buffered counting and the DMA channels. I have 3 DMA channels and all are being used in the counting. Could that somehow affect my counting? Thanks a lot. I'm a novice to Labview and don't understand a lot of the inner workings.

Katie
0 Kudos
Message 5 of 6
(3,123 Views)
I believe the buffered counting could be the problem. You might consider posting to the daq forum for help on this aspect of your code.

Were you able to learn anything when you auto indexed your wires? I was thinking over lunch that the default values for numerics is zero and when you concatenate arrays of different lengths the shorter one is increased in length with default values. If your loop itterats fewer times than you think, this would explain the column of zeros.
0 Kudos
Message 6 of 6
(3,123 Views)