LabVIEW Interface for Arduino Discussions

cancel
Showing results for 
Search instead for 
Did you mean: 

Analogread port slow sample rate

Hi folks I wonder if anyone can help me,..

I am using an arudino nano 3.1 to acquire data on analog channels 0-5, As I have seen suggested throughout the discussion boards I am using the analogread port method to take the 6 reading simulaneously. I have seen somewhere on the discussion board that using this method means the Arduino is reading all 6 ports as quickly as it can, as such I was expecting a 5KHz/6 sample rate, however I am getting a very low  sample rate of roughly 56Hz rather than the 833Hz I was expecting. I have tried to initialise each pin to conitously acquire data using the 'continous aquistion on' vi to speed up the sample rate but I then get inconsistent readings in the returned array and a similarly unexpected sample rate, albeit 3 to 4 times the original sample rate without initialising with for continuous aquistion.

Another issue I am having is getting some indication of when the sample was taken on the arduino side so that I can attribute a reasonably accurate t0 timestamp in labview which can be used to build waveform data for the read analog signals?

Any help would be greatly appreciated, I can post more info on the project if required ( iwanted to be brief!).

Cheers 

Matt

0 Kudos
Message 1 of 7
(10,648 Views)

Analog Acquisition:

  • Analog Read Port.vi can only go as fast as the serial communication will allow.
  • The finite or conintuous sampling only works for a single pin.

Waveform:

  • In your application, do you need an actual data/time for the data or are you simply wanting to build a waveform for plotting the data?  If the latter, you can simply wire any time into the t0 input.

It might be helpful if you described your actual application to determine if what you want to do is possible.  I don't have that much experience with data with data acquisition (on an Arduino) but there are a few that do.

0 Kudos
Message 2 of 7
(5,214 Views)

Thanks for your response Nathan_B.

Essentially I am in the process of building a 0.5m diameter scale model tidal stream turbine. The LabView program I am writing aquires data from various sources and performs test control. The data sources are:

1) A PXI with input from a force block attached to the turbine stanchion to measure the overall thrust on the turbine and input from an ADCP to measure the flow rate during testing.

2) Data is aquired through a Bosch Indradrive motor drive (motor installed in the turbine to provide counter torque and achieve differing rotational velocities for a given flow rate) which is communicated with via modbus TCP/IP - this both for test control and data logging - data aquired here is from the motor encoder and internal control obtaining information such as direct and quadrature current, voltage and power etc.

3) Via an instrumented hub fitted with an arduino for serial comms out of the turbine data is recorded from two strain guaged beams fitted into a blade to measure the thrust and moment about said blade, the instrumented hub also reads signals from an ADXL 335 accelerometer as well as monitoring two moisture sensors in a parrellel circuit to stop power to the motor if any of the seals fail.

Data logging from the other sources is fine and has been written with adequate sample rates achieved, so I am just trying to finish the code by finishing the arduino aquire part of the code and writing a synchronisation routine at the begining of aquistion.

Back to the arduino: Initially I was reading each of the analog inputs seperately but as I am keen to know when each measurement was taken, in order to compare measurements from other sources, I have recently opted to read the arduino data using the read analog port method as I mentioned. In terms of sample rate I would like to achieve above 100Hz is required but upto 500hz would be preferable, I was ambitious at first and hoped to get upto 5KHz but that seems unlikely and therefore the high frequency nature of turbulent loading on the blades is likely to be missed.

It seems as though the options I have are to speed up the serial communications - have tried increasing the buad rate as per - http://forum.arduino.cc/index.php/topic,61381.msg444421.html#msg444421 but labview is then unable to find the arduino, do you have any advice to this end? I have altered the baud rate in both the labview code and the LIFA base....

Alternatively, if I have to aquire from the analog pins seperately how can I measure the delay between reading of one pin to the next?

Also it may be of significance that the serial connection is made via a usb repaeter over a 5m distance, I do however get the same sample rate with and without the repeater,

Considering the initial synchronisation:

Am I able to measure the time taken between taking a sample (13 ADC cycles) and recieving the sample at the other side of the seial connection? I can then at least time stamp at the start of aquistion using the pxi and adjust for the delay between 'asking' for the reading and 'getting' the sample giving myself a reasonable interval of confidence as to when readings are being taken, making the comparison between the various aquistion sources easier.

I have attached a screenshot of the simple VI i have created for measuring the arduino sample rate as it will be similar to the code in situ.

Sorry for the rambling!!!!labviewarduinoscrnsht.jpg

0 Kudos
Message 3 of 7
(5,214 Views)

Oh wow, I certainly was not expecting such an advanced application.  Since you have a PXI chassis, is there a reason you don't use that?  I'm assuming there must be a significant reason.

0 Kudos
Message 4 of 7
(5,214 Views)

The reason for not using the pxi is getting communications out of the nose cone of the turbine - the arduino nano is the perfect size to mount on a circuit board built to the hub specifications also - there probably was some work around but we had suitable USB slip ring in the lab plus the added bother of getting wires out of the turbine while maintaining the seal integrity was an issue.

Cheers

Matt

0 Kudos
Message 5 of 7
(5,214 Views)

That reminds me of a cool display that NI had at NI Days Chicago.  They had a couple cRIO's on a spinning arm that was controlling a bunch of LEDs.  It tracked the position of the arm and manipulated the LEDs to create an image as it spun.  This used slip rings for the network and power connections I believe.

Back on topic, I found a couple discussions where Sam and Kevin talked about acquisition rates.  One of them talked about buffering the data on the Arduino but it isn't very much for an Uno and therefore you couldn't buffer all that much data before having to send it back.

Sam will probably have a better idea of what you might be able to try.

0 Kudos
Message 6 of 7
(5,214 Views)

For a work around the relatively slow data acquisition rate of LIFA you could use a data acquisition shield.  See:

<https://www.adafruit.com/product/1141>

This shield includes a real time clock to time stamp your data.  As the advertised Arduino Uno analog sampling rate is 10 KHz you should be able to obtain a sampling rate of 2.5 KHz when data storage overhead is included. After a test run the data can be easily transferred to a PC file for analysis by Labview.

The Arduino IDE includes the millis() function. It  can be used to measure the time between two events. However, it only has a resolution of 1 milli second and can't be used to measure the time interval between two samples. See:

<http://arduino.cc/en/Reference/Millis>

hrh1818

0 Kudos
Message 7 of 7
(5,214 Views)