LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Timing runs at 1 sample per second with simulated DAQ, but runs slower when connected.

As the title says. 

 

Logs perfectly well without hardware connected.

When the hardware is connected, only logs every 3-4 seconds. 

I feel like I should potentially be initialising the logging outside of the loop and only using one read command, but I just can't seem to work out how this should be set up. 

Could someone show me the correct way to set up hardware measurement please? I've tried following my core 1 and 2 documentation, but I can't work out what it is I am doing wrong.

0 Kudos
Message 1 of 25
(1,423 Views)

Hi LVIEWPQ,

 


@LVIEWPQ wrote:

When the hardware is connected, only logs every 3-4 seconds. 

I feel like I should potentially be initialising the logging outside of the loop and only using one read command, but I just can't seem to work out how this should be set up.


What's the point in starting both DAQmx task in each iteration?

What's the point in killing the DAQmx task in each iteration?

How did you define your DAQmx tasks? (We cannot see that from your task references…)

Why don't you use plain file functions in your loop to avoid opening and closing the file in each iteration?

Why do you need a TimedWhileLoop on your Windows computer? A simple while loop with a 1000ms wait will do the same…

What kind of hardware do you use? Does it even allow to read 16 thermocouples within 1s?

Do you really need floating point numbers with 15 digits precision?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 25
(1,411 Views)

What's the point in starting both DAQmx task in each iteration?
I'm not sure, as I said, I'm not exactly sure I've set it up correctly. It's probably laziness on my part then throwing the timing loop on/bad habits from existing code I've learnt from

What's the point in killing the DAQmx task in each iteration?

Again, I think this just a bad habit from existing code. 

How did you define your DAQmx tasks? (We cannot see that from your task references…)

The tasks are named in NI Max and the names are referenced. 

Why don't you use plain file functions in your loop to avoid opening and closing the file in each iteration?

If I'm honest, I'm not sure what this means. Again, I have taken a format used in existing programs to build this one. The program needs to be able to log at 1sample per second for a 5 hour period. 

Why do you need a TimedWhileLoop on your Windows computer? A simple while loop with a 1000ms wait will do the same…

Again, I think this just a bad habit from existing code. This is how all of our measurement channels are set up

What kind of hardware do you use? Does it even allow to read 16 thermocouples within 1s?
NI 9213 - It does say it's capable of 1 scan per second.

Do you really need floating point numbers with 15 digits precision?

This is the only method I had found to add a time stamp to the data. I require the log to be timestamped to the second. 

I hope this answers some of the strange choices made. 

0 Kudos
Message 3 of 25
(1,395 Views)

@LVIEWPQ wrote:

What's the point in starting both DAQmx task in each iteration?
I'm not sure, as I said, I'm not exactly sure I've set it up correctly. It's probably laziness on my part then throwing the timing loop on/bad habits from existing code I've learnt from

What's the point in killing the DAQmx task in each iteration?

Again, I think this just a bad habit from existing code. 

How did you define your DAQmx tasks? (We cannot see that from your task references…)

The tasks are named in NI Max and the names are referenced. 

Why don't you use plain file functions in your loop to avoid opening and closing the file in each iteration?

If I'm honest, I'm not sure what this means. Again, I have taken a format used in existing programs to build this one. The program needs to be able to log at 1sample per second for a 5 hour period. 

Why do you need a TimedWhileLoop on your Windows computer? A simple while loop with a 1000ms wait will do the same…

Again, I think this just a bad habit from existing code. This is how all of our measurement channels are set up

What kind of hardware do you use? Does it even allow to read 16 thermocouples within 1s?
NI 9213 - It does say it's capable of 1 scan per second.

Do you really need floating point numbers with 15 digits precision?

This is the only method I had found to add a time stamp to the data. I require the log to be timestamped to the second. 

I hope this answers some of the strange choices made. 


Learn from better examples!  You can find them in the examples that are installed with LabVIEW.   There is even a help file section available by clicking the Help button on the Example Finder to teach you how to find examples.

 

It sounds like the developer whose code you are using as exemplar material failed to make use of the shipping examples.   Don't be like him!


"Should be" isn't "Is" -Jay
0 Kudos
Message 4 of 25
(1,388 Views)

HiLVIEWPQ,

 


@LVIEWPQ wrote:

Again, I think this just a bad habit from existing code. 


Why don't you learn LabVIEW from the example VIs coming with LabVIEW instead of repeating "bad habits" from your own code again and again?


@LVIEWPQ wrote:

How did you define your DAQmx tasks? (We cannot see that from your task references…)

The tasks are named in NI Max and the names are referenced. 


Unfortunately we cannot access the settings of MAX on your computer, so this sentence doesn't provide any substantial information…

 


@LVIEWPQ wrote:

What kind of hardware do you use? Does it even allow to read 16 thermocouples within 1s?
NI 9213 - It does say it's capable of 1 scan per second.


The datasheet says "1S/s/ch", but this does not include starting and stopping the measurement task with each iteration…

Start the task before the loop, read samples inside the loop, stop the task after the loop - as is shown in the example VIs!

 


@LVIEWPQ wrote:

Why don't you use plain file functions in your loop to avoid opening and closing the file in each iteration?

If I'm honest, I'm not sure what this means. Again, I have taken a format used in existing programs to build this one. The program needs to be able to log at 1sample per second for a 5 hour period. 


There are "simple" functions like FileOpen, WriteText, FileClose: here the same applies as for DAQmx! Open the file once before the loop, write to the file inside the loop, close the file after the loop…

 


@LVIEWPQ wrote:

Do you really need floating point numbers with 15 digits precision?

This is the only method I had found to add a time stamp to the data. I require the log to be timestamped to the second.


You forgot to mention "Excel" in this sentence, as that's the reason to use that insane resolution…

 

One second is the 86400th part of a day or ~1.1574e-5: writing with 8 digits after the decimal point should be enough for Excel  to differ data from one second to the next. On the other hand you will write 7 bytes less per numeric (8 instead of 15 digits) and so reduce the filesize quite a lot…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 5 of 25
(1,376 Views)

Jumping in

 

I haven't seen the full project requirements. 

 

We should look at the DAQmx configuration.   Open a blank block diagram drop your Task constant on it Select the Task Constant right-click and select Generate code...Configuration.   create a snippet (edit select all on the BD edit create snippet) and drop that image in a reply.

 

You could even go further and generate code... example!!!!!

 

Reporting data to Excel... or saving data in a file Excel can import.are distinctly different. Hacking through a bunch of BS...just look into a TDMS File structure.   DAQmx even has a logging feature that writes Acquisitions to TDMS File without any additional file functions (look it up in the examples)

 

TDMS has one other advantage.  The TDMS Add-In for Excel does the necessary time format change that Time to XL.vi can only hack at because that Add-in has linkages to the OS Timezone definitions collated from the various authorities who legislate civil time.


"Should be" isn't "Is" -Jay
Message 6 of 25
(1,370 Views)

The full project requirements are 16 Thermocouple readings and 3 Pressure Transducer readings logging at a rate of 1 sample/s

I have attached (what I think you need) the requested VI.

With regards to TDMS, it's something I've looked into but just can't seem to make work. It does seem to be more simple than writing to a csv

0 Kudos
Message 7 of 25
(1,361 Views)
Gerd, can you snippet that vi for me. There is still no vi viewer for Android.

Thanks

"Should be" isn't "Is" -Jay
0 Kudos
Message 8 of 25
(1,354 Views)

I don't have DAQmx installed

 

santo_13_1-1680187022621.png

 

 

Santhosh
Soliton Technologies

New to the forum? Please read community guidelines and how to ask smart questions

Only two ways to appreciate someone who spent their free time to reply/answer your question - give them Kudos or mark their reply as the answer/solution.

Finding it hard to source NI hardware? Try NI Trading Post
0 Kudos
Message 9 of 25
(1,350 Views)

Apologies, not know what it is you need to see, I can't really be of much more help in terms of diving deeper. 

0 Kudos
Message 10 of 25
(1,345 Views)