如何在 LabVIEW 中读取 Adafruit INA 219?如何使用 LabVIEW 从 Arduino 获取串行数据?
How can I read Adafruit INA 219 in LabVIEW? How can I get Serial Data from Arduino using LabVIEW?
我尝试使用 Arduino 从 Adafruit INA 219 传感器读取电压和电流,我得到了正确的结果。问题是我需要结果来分析它们,我需要在 LabVIEW 中读取传感器的值或将结果从 Arduino 发送到 Labview。
Arduino代码:
#include <Wire.h>
#include <Adafruit_INA219.h>
Adafruit_INA219 ina219;
void setup(void)
{
Serial.begin(115200);
while (!Serial) {
// will pause Zero, Leonardo, etc until serial console opens
delay(1);
}
uint32_t currentFrequency;
Serial.println("Hello!");
// Initialize the INA219.
// By default the initialization will use the largest range (32V, 2A). However
// you can call a setCalibration function to change this range (see comments).
ina219.begin();
// To use a slightly lower 32V, 1A range (higher precision on amps):
//ina219.setCalibration_32V_1A();
// Or to use a lower 16V, 400mA range (higher precision on volts and amps):
//ina219.setCalibration_16V_400mA();
Serial.println("Measuring voltage and current with INA219 ...");
}
void loop(void)
{
float shuntvoltage = 0;
float busvoltage = 0;
float current_mA = 0;
float loadvoltage = 0;
shuntvoltage = ina219.getShuntVoltage_mV();
busvoltage = ina219.getBusVoltage_V();
current_mA = ina219.getCurrent_mA();
loadvoltage = busvoltage + (shuntvoltage / 1000);
Serial.print("Bus Voltage: "); Serial.print(busvoltage); Serial.println(" V");
//Serial.print("Shunt Voltage: "); Serial.print(shuntvoltage); Serial.println(" mV");
Serial.print("Load Voltage: "); Serial.print(loadvoltage); Serial.println(" V");
Serial.print("Current: "); Serial.print(current_mA); Serial.println(" mA");
Serial.println("");
delay(500);
}
Try to read Adafruit INA 219 with LabVIEW
当前您的值正在被 Arduino 读取并作为字符串发送到串口。
如果您想使用该格式与 LabVIEW 通信,则无需使用 LINX 工具包 - 您只需通过 VISA 节点使用串口即可。
然后您需要将字符串转换为数值,以便能够对它们执行某些操作 'useful'。您可以尝试使用 Match Pattern or Match Regular Expression.
之类的东西
您可能正在寻找类似的内容:
顺便说一句,虽然我总体上喜欢 Whosebug,但对于与 LabVIEW 相关的问题,您可能会在 forums.ni.com 上得到更快的回复(并且不太可能因为讨论相关或重复而被关闭)。
我尝试使用 Arduino 从 Adafruit INA 219 传感器读取电压和电流,我得到了正确的结果。问题是我需要结果来分析它们,我需要在 LabVIEW 中读取传感器的值或将结果从 Arduino 发送到 Labview。
Arduino代码:
#include <Wire.h>
#include <Adafruit_INA219.h>
Adafruit_INA219 ina219;
void setup(void)
{
Serial.begin(115200);
while (!Serial) {
// will pause Zero, Leonardo, etc until serial console opens
delay(1);
}
uint32_t currentFrequency;
Serial.println("Hello!");
// Initialize the INA219.
// By default the initialization will use the largest range (32V, 2A). However
// you can call a setCalibration function to change this range (see comments).
ina219.begin();
// To use a slightly lower 32V, 1A range (higher precision on amps):
//ina219.setCalibration_32V_1A();
// Or to use a lower 16V, 400mA range (higher precision on volts and amps):
//ina219.setCalibration_16V_400mA();
Serial.println("Measuring voltage and current with INA219 ...");
}
void loop(void)
{
float shuntvoltage = 0;
float busvoltage = 0;
float current_mA = 0;
float loadvoltage = 0;
shuntvoltage = ina219.getShuntVoltage_mV();
busvoltage = ina219.getBusVoltage_V();
current_mA = ina219.getCurrent_mA();
loadvoltage = busvoltage + (shuntvoltage / 1000);
Serial.print("Bus Voltage: "); Serial.print(busvoltage); Serial.println(" V");
//Serial.print("Shunt Voltage: "); Serial.print(shuntvoltage); Serial.println(" mV");
Serial.print("Load Voltage: "); Serial.print(loadvoltage); Serial.println(" V");
Serial.print("Current: "); Serial.print(current_mA); Serial.println(" mA");
Serial.println("");
delay(500);
}
Try to read Adafruit INA 219 with LabVIEW
当前您的值正在被 Arduino 读取并作为字符串发送到串口。
如果您想使用该格式与 LabVIEW 通信,则无需使用 LINX 工具包 - 您只需通过 VISA 节点使用串口即可。
然后您需要将字符串转换为数值,以便能够对它们执行某些操作 'useful'。您可以尝试使用 Match Pattern or Match Regular Expression.
之类的东西您可能正在寻找类似的内容:
顺便说一句,虽然我总体上喜欢 Whosebug,但对于与 LabVIEW 相关的问题,您可能会在 forums.ni.com 上得到更快的回复(并且不太可能因为讨论相关或重复而被关闭)。