03-01-2022 09:34 PM
I'm trying to make power monitoring and controlling using Arduino UNO with labview but for the monitoring stuck in reading the sensors. it can't be serparate between the current sensor and the voltage sensor
this is my arduino cofing
const int pinADC = A0;
int sensitivitas = 185;
int nilaiadc= 00;
int teganganoffset = 2500;
double tegangan = 00;
double nilaiarus = 00;
int nilai_pwm = 00;
const int output_pwm = 2;
float voltageOut= 00;
float voltage= 00;
void setup() {
Serial.begin(9600);
delay(2000);
char Buffer[100];
int nilaiarus = 0;
int sensor2 = 0;
void data_olah(){
nilaiadc = analogRead(pinADC);
tegangan = (nilaiadc / 1024.0) * 5000;
nilaiarus = ((tegangan - teganganoffset) / sensitivitas);
}
void loop() {
nilai_adc = analogRead(input_sensor);
nilai_pwm = map(nilai_adc, , 1023, , 255);
analogWrite(output_pwm, nilai_pwm);
voltageOut = nilai_adc * (5.0 / 1023.0);
sprintf(Buffer,"%04i\t %04i\t",nilaiarus,voltageout);
Serial.println (Buffer);
delay(1000);
}
Solved! Go to Solution.
03-02-2022 03:03 AM
I'm not entirely sure i understand your question correctly, but if you have all these sensors hooked up to arduino UNO, then all you need is one visa communication open, with the arduino.
Reading all the sensor values is then done by the arduino itself and has nothing to do with visa.
How sensors are read is then up to you, you'll need to program the arduino to your satisfaction.
03-02-2022 07:47 AM
DO NOT USE THE BYTES AT PORT!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! (still not enough emphasis)
Remove the Bytes At Port and just set the number of bytes to read to a number more than you ever expect in a message. In this case, I would probably use 50. You can do this because of the termination character the Serial.println() appends to the data on transmission. The VISA Read will stop reading when it encounters the termination character (by default ON and set to the Line Feed character).
For more details: VIWeek 2020/Proper way to communicate over serial
03-02-2022 09:46 PM
if that so can you help me to checked my arduino program? is there any problem from the program that I sent before?
03-02-2022 10:34 PM
so I should remove the bytes port, right? and change it to 50 like this?
and can you tell me how about to separate the output from the sensors?
I use 2 sensors (voltage and current sensor) but when I run the labview, the indicators of both sensor display the same value I mean the current value still display in voltage indicator and also the voltage value.
03-02-2022 11:27 PM - edited 03-02-2022 11:31 PM
Program your Arduino to send your sensor data in one line separated by commas. Just send the numeric values, you don't need to label them as you should know what order they are being sent.
Then it is really easy to parse the string and convert it back to numeric by using "Spreadsheet string to array" and set the delimiter to a comma