11-12-2019 12:16 PM
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.
11-12-2019 02:20 PM - edited 11-12-2019 02:21 PM
Well in general there a couple of ways to use an Arduino with LabVIEW
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