LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How can I build a table with the time values of a timer from a while loop

Hi:
 
I have a question concerning building a table:
 
Every 100ms I read a value from a sensor (while loop with a timer). I would like to build a table with the actual time and the concerning value. For example:
 
0msec         1V
100msec     2V
200msec     3V
300msec     4V
etc.
 
If I use the Express VI for building a table, I always get the date and time, but I don't need the date and the time is in the following format: HH:MM:SS, which is nonsensical for me as I can't differentiate within msec. Can I change the format anywhere?
 
Can I also save the table to a file or even to an Excelsheet? How can I do that?
 
Thanks for your help!
 
 
0 Kudos
Message 1 of 21
(4,442 Views)

Hi,

If your acquisition is giving out timestamps, you can simply subract them from one another to give you a time in seconds.  If it is not doing this you can use the get ms tick value and subtract them.  Because there is no IP to the get mS tick value i often put it into a Sequnce block and wire something to it so i pick up the time at the specific point in the data flow.  However windows is not a RT OS so your mS value is pretty much up to when windows decides to give it to you, although it is a fairly good quick guide.

 

Have a look at my vi to see how i get ms multiples.

Good luck

Craig

LabVIEW 2012
0 Kudos
Message 2 of 21
(4,425 Views)

Hi:

 

thanks a lot! It works: )

Do you also know how I get the time continuously? Shall I put the "get actual time and date" in a while loop or is there a more easy way?I need it for a formula.

 

Thanks!!

0 Kudos
Message 3 of 21
(4,408 Views)

Hi,

You could just put the "Get date and time" in a while loop but i dont see how it could tie in to your data measurements, however if it suits your purpose then go ahead.  If you need more resolution, you could mayby get date and time once every half a second or so then use one of the "1D interpolate" functions from the maths palette to get your desired times.  I am a bit vague on exactly what you are after, hence the vague answer, however if your still stuck throw me some more questions and i will see what i can do.

Have fun!

Craig

LabVIEW 2012
0 Kudos
Message 4 of 21
(4,402 Views)

Hi Craig:

 

thank you very much. To solve the mystery : ) :

I want to drive a stepper motor with a specific frequency. To get the current degree value of the motor I would like to measure the current time (from the beginning of the move on). (With a formula I get the degree value out of the time)

Concurrently I would like to get data from a torque sensor and from a pressure sensor. That's why I asked you about the time and the table. The measurement should start with the movement of the motor. How can I do that? Right now I have different block diagrams (different while loops) (see attachment) and I would like to put them in one.

I haven't done the block diagram for the pressure sensor yet, so there is only the one for the torque sensor and the one for the motor.

I also would like to set a mark in the table when the voltage value of an analog input gets under a specific threshold value. Is that possible?

I'm sorry, I'm a novice in LabVIEW. But maybe you can help me.

 

Thank you very much!

 

Steffi

 

Download All
0 Kudos
Message 5 of 21
(4,362 Views)

Hi Steffi,

If you are trying to find position using time there may well be a problem.  The time values given back are not RT and so may vary slightly and may ultimately cause a drift in your accuracy due to rounding errors or the like.  If this is not a problem then i would get the time constantly by putting it in the Motor.vi Diagram within the While loop.

To run the loops concurrently you could put them both into one vi with the loops side by side.  To start them off at the same time you could use an event case or an error string or something to ensure they execute at the same time. Take a look at my attached example to see how you can run two loops in parrallel.

Also in my example i have shown how to detect a threshold and just use it to create another column in the spread sheet.  The array could be anything (Boolean True or false etc etc)

Sorry i couldnt be more help but kinda busy at the moment.  However feel free to ask more questions.

Craig

LabVIEW 2012
0 Kudos
Message 6 of 21
(4,344 Views)
Hi Steffi,
 
You could probably monitor the acquired data points for threshold level
When you insert the point to a particular cell in the table, you could chage the color of the background of that cell, to indicate that its value is below the Threshold value
 
Look at attached VI to get an idea
 
Any doubts, do ask Smiley Happy
 
Regards,
Dev
0 Kudos
Message 7 of 21
(4,341 Views)
Dev: that's exactly what I thought of, thank you. But when I run the block diagram several times, the colors stay there from the previous run. Do you know how I can reverse it? I save the values of my table to an excel sheet: Do you know how I can save it with the colors, so that the colors are also in the excel sheet (as they are in the table)? It only saves the values without the colors right now.
 
Craig: That's great with the loops and the event case!
 
Thanks a lot guys!
 
Steffi
 
0 Kudos
Message 8 of 21
(4,332 Views)

To reverse the table color, the best method would be to re-color the blocks using the 'active cell and cell BG color Property nodes' inside a for loop, before entering the while loop

Or you could assign white color to that particular cell, inside the false case of the case structure

Regarding coloring the blocks in a excel sheet, If you have LabVIEW Report generation toolkit for MS office ( an addon toolkit) installed, you could use the 'Excel Set Cell Color and Border VI' to do that.


 

0 Kudos
Message 9 of 21
(4,311 Views)
Unfortunately I don't  have the LabVIEW Report generation toolkit for MS office . Is there another possibility?
 
I tried to run two while loops concurrently as Craig recommended, but they don't run concurrently. Do they have to have the same timer? My while loops have different timers: ( They run one after the other.
 
Maybe my attached block diagram is useful to answer my questions.
 
THANK YOU!!
0 Kudos
Message 10 of 21
(4,291 Views)