LabVIEW Interface for Arduino Discussions

cancel
Showing results for 
Search instead for 
Did you mean: 

Max Sample rate??

Solved!
Go to solution

Hi all, someone can tell me what is the MAX SAMPLE RATE that I can read with LIFA, I mean, Can I read an 100Khz analog input with LIFA and show it in a graph?

0 Kudos
Message 1 of 12
(20,794 Views)
Solution
Accepted by topic author Leopac

The max sample rate is a bit subjective- it depends what serial rate you use and a bit on your particular hardware. I tested an UNO up to 10KHZ using continuous sampling. 100KHZ is probably not feasible for streaming back to LabVIEW - you might be able to set something up where you sample at that rate on the Arduino log the data and then transmit it in a big chunk later on. The max sample rate for your particular board can be found on the Arduino site.

Kevin Fort
Principal Software Engineer
NI
0 Kudos
Message 2 of 12
(9,403 Views)

Hi, I'm using a SD card shield for the arduino uno, and i'm able to save sample data on the range of 0 to 1023 (because of the 10-bit adc) in a .txt file. I'd like to be able to read this data later to simulate the sampled signal in labview and properly show that it retains the frequency of the original signal. Could you please give me some hints in how to do this? i'm new to labview. Thanks!

Pavel

0 Kudos
Message 3 of 12
(9,403 Views)

If I recall the theoretical max sample rate (due to hardware limitations) of the Arduino is something like 66KHz (I may be way off here but I remember calculating it at one point .  This is based on the settling time of ADC in the arduino and does not include time to transfer data anywhere (UART, SD Card, even RAM).

SD card read / writes are slow, so you'll again want to buffer as much data on the Arduino as possible before you write it. Unfortunatly the Arduino has very little RAM (2K on the Uno) so you won't be able to buffer much data.

Say you could sample at 50KHz and use the entire Arduino RAM for a buffer (which you can't).

50KHz @ 10-bit resolution = 500Kbits/second = 62500 Kbytes / S.

So with 2KB of RAM you get 2 / 62500 = 32 uS of sampling before you need to write out your data.

The Field Wiring and Noise Considerations for Analog Signals contains some good data about analog sampling that applies to pretty much all analog devices (not just NI prodcuts).

Warning::Shameless NI Plug

If you need to sample faster you might want consider something like myDAQ (Student's should be able to get a considerable discount).  myDAQ can sample at 200KS/s @ 16-Bit resolution +/- 10v and works like a champ with LabVIEW.

-Sam K

0 Kudos
Message 4 of 12
(9,403 Views)

I too have the same problem of obtaining signals of decent frequency over the labview arduino interface. in fact, I couldnt even obtain a clear sine wave of frequency 100 hz let alone at 10khz.

Also, when i tried interfacing a arduino due with labview, i am unable to find the board on arduino 1.0.1 whihc actually supports LIFA and not the latest.

Can you please tell me how to measure the frequency of the sampling rate in my arduino?

also, how to obtain higher frequency range?

should I change the prescaler?if so, how to?

0 Kudos
Message 5 of 12
(9,403 Views)

Attached is a VI that measures the length of time it takes to read 1000 analog samples when using LIFA.   On my PC it takes approximately 8 seconds, which is 125 samples per second.   Your mileage may vary.   This low sample rate is caused mostly by  the length of time it takes to send commands and data between a PC and Arduino.  You won't gain much by changing the prescaler.

You can obtain a higher sampling rate by using LINX.  On my PC it is approximately 400 samples per second.  LInx includes a display of the sample rate when using the Analog Read 1 Channel.VI.

For higher sample rates you could write the data to an SD card.  But even when using an Arduino Uno and a SD card the maximum sampling rate is only around 10,000 samples per second.   Using an ARduino Due or a Teensy 31 and an SD card will get you to about 100,000 samples per second.  For mega Hertz sampling rates I suggest a USB oscilloscope.     

hrh1818

0 Kudos
Message 6 of 12
(9,403 Views)

Thanks a lot! I havent used LINX till now hence I was using LIFA. Luckily, I also have an arduino due so I guess you can use that. Can you guide me a bit through LINX  as I have no idea about using it.

Also, I was thinking about porting the values from arduino due to excel itself using ddl. would that give me a higher speed or logging data on an sd card?

getting even 100k samples per second would be more than enough!

and thanks a lot for the vi!

0 Kudos
Message 7 of 12
(9,403 Views)

You should check out the official website for LINX at http://www.labviewhacker.com/linx.  If you have questions or issues, post in the LabVIEW Hacker forums.

0 Kudos
Message 8 of 12
(9,403 Views)

Near the top of Discussion's first page is the announcement "LIFA Replacement - LINX Officially Released".  Inside is the link "Getting Started with LINX Tutorial here".  That link with guide you through setting up and using LINX.

You may not need to use a SD card. An Arduino Due has 96 kilobytes of SRAM.  Depending upon how much data you wanted to save you could write the data to memory while the test is running.  Then when the test is finished write the data to file.  This approach is not suitable with an Arduino Uno as it only has 2 kilobytes of memory.

A couple of suggestions for writing data to a file are

Processing see:

<https://www.inkling.com/read/arduino-cookbook-michael-margolis-2nd/chapter-4/recipe-4-12>

Python  see:

"https://www.google.com/webhp?sourceid=chrome-instant&ion=1&espv=2&ie=UTF-8#q=python%20write%20serial..."

hrh1818

0 Kudos
Message 9 of 12
(9,403 Views)

hi, i'm Sol.. a degree student. Could you share with me your VI using LINX that you managed to get 400hz sampling rate.. because i tried using LINX previously but only managed 180hz .. i'm trying to access fastest sampling rate possible using labview-arduino, and would be very delighted with any help you could come up, Thank you in advance..

0 Kudos
Message 10 of 12
(5,484 Views)