LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Trying to logg my data to excel with a specific time interval

Hello, this is my first post here. Sorry for my bad english.


I have a daqmx program that you can regulate with PID, and the results should bee logged to a excel file, with timing when its logged and the output data. But i am having trouble with the timing. I use the elapsed time express VI to decide the timing. And the Write to mesaurement file express VI to write to excel.

 

What i want is that you can decide how often it should be logged, like every 1 second or every 10 second. But when i sett it to 1 second the logging data in excel shows that it logges every 1,1 seconds or soo. And this is to inaccurate.

asdijasiojd.PNG

This is where my logging system is. Elapse time shuts of the logging every 1 second but in the excel file the timing is every 1,1 seconds or so.

 

ioasjdasio.PNG

This is what i get out of the excel file. Time and date from start to stop. But what i also could like is a second row where its says 10-20-30-40 or 1-2-3-4-5 so its easier plotting into a diagram.

 

Shouldn't i use the Express VI?

 

0 Kudos
Message 1 of 18
(3,397 Views)

Hi/Hey King,

 

This is where my logging system is. Elapse time shuts of the logging every 1 second but in the excel file the timing is every 1,1 seconds or so.

So something in your code needs more than 1s, and so your loop takes ~1.1s to iterate.

 

Shouldn't i use the Express VI?

In general that is a good idea!

 

But what i also could like is a second row where its says 10-20-30-40 or 1-2-3-4-5 so its easier plotting into a diagram.

I guess you need one more column (instead of a row).

Either add that data as additional value for logging - or create your own logging routine…

 

Why do you read data from DAQmx with setting "n samples" and wire "-1" as number of samples? You didn't set any samplerate in your DAQmx task!

Why do you read the samples as waveform? Why do you convert that waveform to a single/scalar value using an ExpressVI?

Why don't you read just one sample using the "1 chan 1 sample" mode of DAQmxRead?

Why do you apply a Median filter? Are you sure you don't want to average (aka Mean) here?

Why do you use that "funny" PID routine instead of the AdvancedPID function coming with LabVIEW? (A PID function should not depend on the iteration count of the loop its placed in…)

 

Btw. it isn't recommended to use LLB nowadays with recent LabVIEW versions. Use a plain folder and a LabVIEW project instead!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 18
(3,392 Views)

Thank you for your reply GerdW.

 

But what i also could like is a second row where its says 10-20-30-40 or 1-2-3-4-5 so its easier plotting into a diagram.

I guess you need one more column (instead of a row).

Either add that data as additional value for logging - or create your own logging routine…

 

Could you show me how?

 

Why do you read data from DAQmx with setting "n samples" and wire "-1" as number of samples? You didn't set any samplerate in your DAQmx task!

What do you mean here? i have set samplerate to -1 so that daqMX determens the samplerate itself.

 

Why do you read the samples as waveform? Why do you convert that waveform to a single/scalar value using an ExpressVI?

Beacuse my main task is to see the trending of my value in a graph. And i figured it was the easiest way.

 

Why don't you read just one sample using the "1 chan 1 sample" mode of DAQmxRead?

This i am unformiliar with. I figured out where to set these settings, but there was way to many of them and my program crashed, what is the right one?

 

Why do you apply a Median filter? Are you sure you don't want to average (aka Mean) here?

Yes have change to mean filter. Thank you!

 

Why do you use that "funny" PID routine instead of the AdvancedPID function coming with LabVIEW? (A PID function should not depend on the iteration count of the loop its placed in…)

The PID block i used came with the basic program, but i have now changed it to the advancedPID.

 

Btw. it isn't recommended to use LLB nowadays with recent LabVIEW versions. Use a plain folder and a LabVIEW project instead!

what is LLB? are you talking about the project library?

 

Updated program is added.

0 Kudos
Message 3 of 18
(3,356 Views)

Hey King,

 

What do you mean here? i have set samplerate to -1 so that daqMX determens the samplerate itself.

Wrong. Please read the context help of DAQmxRead to learn which input you have wired!

 

This i am unformiliar with. I figured out where to set these settings, but there was way to many of them and my program crashed, what is the right one?

Like this:

check.png

 

The PID block i used came with the basic program, but i have now changed it to the advancedPID.

Wrong. This is not the AdvancedPID function, it's the "PID Advanced Autotuning"…

 

what is LLB? are you talking about the project library?

See your attachment from your first post: that is a LLB file!

LLB were used in ancient LabVIEW versions to allow bundles of several VIs with filenames larger than 8.3. Nowadays you don't need them anymore: place all project-related files in a folder, including the lvproj file!

 

Could you show me how?

Like this:

check.png

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 4 of 18
(3,348 Views)

How do i get this to write to excel? and i want a start stop function on it, so i dont logg all the time.

Looking for something like this:

asiodjasiod.PNG

0 Kudos
Message 5 of 18
(3,330 Views)

Hi King,

 

to handle differently formatted values within a row you need to do the formatting on your own:

check.png

The FOR loop with a random function is representing your 3 data items you want to log…

 

On your VI:

You read just one sample from DAQmxRead: why did you choose the waveform datatype? Why not read a scalar DBL value and get rid of that last ExpressVI?

 

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 6 of 18
(3,326 Views)

Thank you so much for your help!

I don't understand where i decide what heading goes over what value, in the logging part, how do i decide that this value goes under for example: PID-output heading. Is it the table control that you have used? where do i find this?

Also i want my PID regulation program to run when i start my program, but i want to chose when to start and stop my logging, without this stopping the whole program. How do i do this? Is there an independent loop or something?

0 Kudos
Message 7 of 18
(3,291 Views)

Hi King,

 

I don't understand where i decide what heading goes over what value,

You decide that by the order of data items in the BuildArray part!

When you build an array of "PID sp", "PID cv" and "PID output" values, then your header line should match that order…

 

i want to chose when to start and stop my logging,

Use a case structure to enable/disable the logging code…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 8 of 18
(3,285 Views)

When im using a case structure only the last value gets saved to the 'logging' file. How do i get continuous logging?

0 Kudos
Message 9 of 18
(3,277 Views)

Now this happened when trying to save as .csv

asidjoasiod.PNG

0 Kudos
Message 10 of 18
(3,273 Views)