LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to read Serial Data from Arduino using labview VISA?

Solved!
Go to solution

 I am getting this data on serial moniter of arduino..

Real_Power=3874.44 Apparent_Power=3774.76 PowerFactor=1.03 Supply_Voltage=353.91353.91 Current=10.67
Real_Power=3876.42 Apparent_Power=3776.56 PowerFactor=1.03 Supply_Voltage=353.80353.80 Current=10.67

 

by running this code

#include "EmonLib.h" // Include Emon Library
EnergyMonitor emon1; // Create an instance


void setup()
{
Serial.begin(9600);


emon1.voltage(5,172,2.3); // Voltage: input pin, calibration, phase_shift
emon1.current(1,5); // Current: input pin, calibration.
}

void loop()
{
emon1.calcVI(20,2000); // Calculate all. No.of wavelengths, time-out
pinMode(7,OUTPUT);
//emon1.serialprint(); // Print out all variables

float realPower = emon1.realPower; //extract Real Power into variable
float apparentPower = emon1.apparentPower; //extract Apparent Power into variable
float powerFActor = emon1.powerFactor; //extract Power Factor into Variable*/
float supplyVoltage = emon1.Vrms; //extract Vrms into Variable
float Irms = emon1.Irms;

Serial.print("Real_Power=");
Serial.print(realPower);
Serial.print(" Apparent_Power=");
Serial.print(apparentPower);

Serial.print(" PowerFactor=");
Serial.print(powerFActor);
Serial.print(" Supply_Voltage=");
if (supplyVoltage<5)
{
Serial.print(0);
}
else
{
Serial.print(supplyVoltage);
}
Serial.print(supplyVoltage);
Serial.print(" Current=");
Serial.print(Irms);
Serial.println();

delay(1000);
}

 

I want to send this data to lab view and plot its graphs on lab view

0 Kudos
Message 91 of 143
(3,134 Views)

Hello guys please I need some help over reading serial data from arduino I want to be able to read some RFID tags IDs but there is a lot of data coming to serial port including the Ids I couldn't extract them I don't know how to use the string match pattern function so please if someone could help that would be great

the Id is written as follows ID byte card[4]=A7BF5E7A; I attached my VI thank you

0 Kudos
Message 92 of 143
(3,100 Views)

can you please post a clear picture of the connections with arduino LM35,etc??

 

0 Kudos
Message 93 of 143
(3,024 Views)

A picture wouldn't help - I designed a custom circuit board.

However if you Google "LM35 Arduino" there are tons of resources and tutorials from people who have done that already. For example:

http://www.instructables.com/id/ARDUINO-TEMPERATURE-SENSOR-LM35/

http://www.circuitstoday.com/lm35-and-arduino-interfacing

https://www.dfrobot.com/wiki/index.php/DFRobot_LM35_Linear_Temperature_Sensor_(SKU:DFR0023)

 

If you need more resolution then you would have to amplify the signal or change the A/D converter reference voltage:

https://playground.arduino.cc/Main/LM35HigherResolution

Cheers

0 Kudos
Message 94 of 143
(3,017 Views)

I will send and receive data between labview and arduino using portus, I need arduino code and interface under labview

0 Kudos
Message 95 of 143
(2,701 Views)

We are currently doing our project in VLC, so im in need of transmit the modulated binary data zeros and one's from an one dimensional array through an ARDUINO. we are currently using LINX but we face error cant to transmit the loop timeout soon. so can you help me to transmit a data through visa ,here i have attached my vi file. i hope you understand once if you seen my vi. Thankyou

0 Kudos
Message 96 of 143
(2,413 Views)

We are currently doing our project in VLC, so im in need of transmit the modulated binary data zeros and one's from an one dimensional array through an ARDUINO. we are currently using LINX but we face error cant to transmit the loop timeout soon. so can you help me to transmit a data through visa ,here i have attached my vi file. i hope you understand once if you seen my vi. Thankyou

0 Kudos
Message 97 of 143
(2,409 Views)

for labview LM35 and code

0 Kudos
Message 98 of 143
(2,199 Views)
0 Kudos
Message 99 of 143
(2,179 Views)

Is this a new question?  It doesn't directly relate to the older posts, isn't really a question, and doesn't say what you are having a problem with.  You should have created a new thread with more details in your message.

 

I do see a couple issues with your code.  The first problem is that you used "Bytes at Port" which is the wrong thing to use 99% of the time.  We don't know about your communication protocol, but since you are using String to Number, I'm going to assume you have data coming through in human readable format, preferably with some separators between them, and that you are using a termination character.  Your Serial Configure subVI is set up to use a line feed as a termination character.  So you should take advantage of that and read a number of bytes larger than the longest message you expect to receive.

 

A bigger problem is that you have a huge race condition. You split your VISA wire and do bytes at port twice and VISA read twice in parallel, which makes no sense for a "serial" connection to do something in parallel.  You have no control over which of those functions occur first and you could wind up with wrong parts of your message beting read at different times and going to different indicators.

 

Do one VISA Read only, and split up your incoming string appropriately using whatever delimiter character you are using to separate the data elements.

0 Kudos
Message 100 of 143
(2,173 Views)