LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Arduino sketch in Labview

Hello,
To read the arduino supply voltage I use a well-known sketch:

 

long readVcc () {
ADMUX = _BV (REFS0) | _BV (MUX3) | _BV (MUX2) | BV (MUX1);
delay (2); // Wait for Vref to settle
ADCSRA | = _BV (ADSC); // Start conversion
while (bit_is_set (ADCSRA, ADSC)); // measuring
uint8_t low = ADCL; // must read ADCL first - it then locks ADCH
uint8_t high = ADCH; // unlocks both
long result = (high << 😎 | low;
result = 1125300L / result; // Calculate Vcc (in mV); 1125300 = 1.1 * 1023 * 1000
return result; // Vcc in millivolts
}
void setup () {Serial.begin (9600);}
void loop () {Serial.println (readVcc (), DEC); delay (1000); }

 

It works.

I successfully tested several examples on linx.
How can I do this in labview? I would like to use this value to improve the performance of some sensors.

 

Thanks.

0 Kudos
Message 1 of 2
(2,398 Views)

Well in general there a couple of ways to use an Arduino with LabVIEW

 

  1. Use LINX
    1. LINX basically turns an Arduino into a USB DAQ device with access to all of the Ardunio's analog and digital I/O and lots of support for various peripherals, but the Adruino must always be connected to the PC to operate
  2. Use the Arduno's native language and communicate with it the same as any other serial device
    1. I prefer this method as the Ardunio can run "stand alone" or communicate with LabVIEW depending on my application.

If you chose method 2 here's a couple pointers...

An Arduino installs a virtual serial port when it is first plugged into your computer

Use that serial port and NI-VISA to communicate with the Arduino just like any other device on a serial port

Doing this you have full control over the serial protocol, query and response formats since you will be writing the Arduno code

Send data using the Arduino PrintLn function as it appends a LF to the end of the data. You can use that LF as a Termination Corrector in your VISA Reads 

Separate data by comas (data1,data2,data3) then you can use "Spreadsheet string to array" with the Delimiter set to a comma to parse the data from the string right into a numeric array.

Get your Arduino code to work with the Arduino Serial Monitor, then work on the LabVIEW to talk to it

========================
=== Engineer Ambiguously ===
========================
0 Kudos
Message 2 of 2
(2,364 Views)