LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

LabVIEW Arduino Sensor Input Sampling

Solved!
Go to solution

Hello !

 

I am using an LDR sensor to measure the brightness of an external LED. The LDR is connected to Analog Input of Arduino Mega. I am reading the data (analog value) of the sensor using Analog Read function, found in Arduino section of function palette in LabVIEW.

 

I want to know what is the sampling rate of the readings I am getting and how to control it, if possible, and also the factors on which it depends.

 

Also I am writing these values to a .lvm file using the express VI "WRITE TO MEASUREMENT FILE". I want to know the speed at which these measurements are being written and how to control this as well.

 

Thanks !

 

 

 

 

0 Kudos
Message 1 of 8
(4,464 Views)

Hi ksharshit,

 

I want to know what is the sampling rate of the readings I am getting and how to control it,

When you read your data in a "single sample mode" the sample rate is control by your reading loop.

 

I want to know the speed at which these measurements are being written and how to control this as well.

The data is written "as fast as possible" to your file. You cannot control the speed of the file write as this heavily depends on your computer system…

What exactly are you doing here? Why do you need to control the speed of writing a file?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 8
(4,455 Views)

The physical sampling rate is determined by the loop rate on the arduino, but what you get in labview (and when) will depend on how (and if any) buffering is done on the arduino before sending it over the virtual com port to LabVIEW.

 

The writing to measurement file will also depend on the buffering and sending format. For example, if the arduino sends a comma delimited string of X values you will have to handle it differently to a single data point.

 

I have done a few projects with arduinos but I have never used the toolkit you mentioned, so cant say I know what formats it uses to receive data.

0 Kudos
Message 3 of 8
(4,452 Views)

Hi GerdW, thanks for your time to help me out !

 

I open the arduino resource and using the AnalogRead function inside a while loop, i read the value off the LDR sensor. These values are being simultaneously written to a Excel Spreadsheet using "WRITE TO MEASUREMENT FILE Express VI. This is also kept in the same loop.

 

I want to know, how fast am I getting values from Analog Read, is there a way to control it, and also how fast the values are being written and is there a way to control that too, say, I want the value to be saved after every 1 second.

0 Kudos
Message 4 of 8
(4,447 Views)

Hello deceased, thanks for your time !

 

Is there a way to find out, or any how take control of this buffer phenomenon as you mentioned. 

0 Kudos
Message 5 of 8
(4,444 Views)

Hi ksharshit,

 

This is also kept in the same loop.

So your loop determines sample rate- as said before!

 

I want to know, how fast am I getting values from Analog Read, is there a way to control it, and also how fast the values are being written and is there a way to control that too, say, I want the value to be saved after every 1 second.

As said before: your loop rate determines the sampe rate!

And yes: you can save a value to your file once a second. You just need to program your VI that way…

 

Btw. as we are talking about YOUR VI: Do you mind to attach it? (I prefer it saved for LV2014 or older.)

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 6 of 8
(4,443 Views)

Hello,

 

I have attached the VI.

 

Can you please have a look and tell me the sampling rate and the data writing rate in this case.

0 Kudos
Message 7 of 8
(4,438 Views)
Solution
Accepted by topic author ksharshit

Hi ksharshit,

 

tell me the sampling rate and the data writing rate in this case.

The data is read from your Arduino "as fast as possible" as there is no timing in your loop.

The max speed is determined by sample rates of the Arduino ADC (read specs of Arduino and LIFA/LINX!) and the baudrate used for communication between Arduino and LabVIEW: in your VI you used 9600baud. This limits transfer rate to ~1kByte/s…

Data saving to file also occurs "as fast as possible" when your (hidden) button "boolean" is switched to TRUE…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 8 of 8
(4,433 Views)