LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Can anyone help me how to read multiple sensors on Visa?

Solved!
Go to solution

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);
}

0 Kudos
Message 1 of 6
(492 Views)

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.

0 Kudos
Message 2 of 6
(460 Views)

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


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 3 of 6
(446 Views)

if that so can you help me to checked my arduino program? is there any problem from the program that I sent before?

0 Kudos
Message 4 of 6
(423 Views)

so I should remove the bytes port, right? and change it to  50 like this?

Screenshot 2022-03-03 112602.png

 

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.

Screenshot 2022-03-03 113419.png

0 Kudos
Message 5 of 6
(417 Views)
Solution
Accepted by topic author brighti

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

 

SS2ACapture.PNG

========================
=== Engineer Ambiguously ===
========================
0 Kudos
Message 6 of 6
(412 Views)