LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Read 3 serial port from Arduino in labview

Hello everyone

i want to read data from 3 Arduino with serial.print ( serial port ) in visa port of Labview.

i put my simple code here. i will be happy if anyone help me about it.

thanks

 

0 Kudos
Message 1 of 16
(3,183 Views)

Can you put your vi for version 2017 or a picture of it?

0 Kudos
Message 2 of 16
(3,182 Views)

Hello everyone

i want to connect 3 arduino to labview and then read serial port of them in labview same time.

i put my code here.

what do you think about it. should i need to change my code or do some change in labview or arduino.

thanks

 

0 Kudos
Message 3 of 16
(3,181 Views)

I have labview 2018.

here is code and picture

 

Download All
0 Kudos
Message 4 of 16
(3,178 Views)

Hi amkamyab,

 

please don't create duplicate threads for the very same topic.

Especially when you don't even attach a down-converted version of your VI!

 

Edit after your last message:

To downconvert a VI you go open the File menu -> Save for previous…

 

what do you think about it. should i need to change my code or do some change in labview or arduino.

Yes, surely you NEED TO change your code!

1. Don't use BytesAtPort! Just wire a constant larger than the expected message size! (You set VISASerialPortInit to wait for TermChars!)

2. There is no error handling at all right now!

3. Separate each communication (COM port) in its own loop.

4. Use more descriptive labels for your controls.

5. You don't need to open the COM port, VISASerialPortInit is sufficient.

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 5 of 16
(3,176 Views)

when i don't use byte at port labview show error when start run.

0 Kudos
Message 6 of 16
(3,169 Views)

Hi amkamyab,

 

what kind of messages do you want to receive from your Arduino(s)? How are they formatted?

Please provide more information!

You also don't show how your VI looks like right now…

 

At VISASerialPortInit you enabled the TermChar and set LF as TermChar, so I guess your messages are send using a Serial.PrintLN command at the Arduino. (If this is not the case you need to use a better setup at initialising the COM ports and adapt your reading loop.)

 

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 7 of 16
(3,166 Views)

Thanks for your care.

here is my real code for labview

and also my code for Arduino

 

Download All
0 Kudos
Message 8 of 16
(3,158 Views)

2017 version of my VI

0 Kudos
Message 9 of 16
(3,157 Views)

Hi amkamyab,

 

OMG!

What is this monster of a VI made to do?

Why do you need SO MUCH duplicated code?

Why do you need to convert arrays to clusters so often - just to get 2 boolean values???

Why is there so much dead code in yur VI? (All those HighResolutionTimer calls!)

 

There still is no error handling.

There still is no explanation of the message and its formatting.

 

You seems to receive a value from 0 to 20 from your Arduino. Then you add a boolean TRUE to an array, depending on the value you received. WHY don't you use just ONE array to store all data, with the received value used to index an element/row in the buffer???

What kind of data (structure) do you need?

 

Edit after noticing that Arduino code:

The only relevant line of code is this:

Serial.write(buffer2[i] );

"buffer2" is initialized as array of bytes, so that Serial.write is sending just one byte (aka U8).

 

- You need to disable the TermChar at the VISASerialPortInit function!

- You need to read exactly one byte (aka char). No need for BytesAtPort! (Well, you could read more than one byte, but then you need to handle the received byte array in a loop.)

- You need to convert the received string to an U8 array instead of using FractStringToNumber!

-

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 10 of 16
(3,153 Views)