LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Communication between two PCs

Solved!
Go to solution

Hello,

I want to communicate between two PCs using Labview. I am using a null modem cable with USB to RS232 converters. 

I am able to send data from PC1 and receive it on PC2. 

Once this communication is done I want to send data from PC2 to PC1 which I am not able to do.
I want to manage to run this in a loop. 

I tried an example of this and attached the VIs.

 

Thanks!
 

Download All
0 Kudos
Message 1 of 15
(1,295 Views)

Hi ahmed,

 


@ahmedmaken wrote:

I am able to send data from PC1 and receive it on PC2. 

Once this communication is done I want to send data from PC2 to PC1 which I am not able to do.


Why aren't you able to achieve that?

Do you get any errors? Which ones?

(A big problem is your try to close the same COM port reference twice even though you only oopen that port once…)

 

What about thinking about the communication protocol before implementing it?

What about using some command/response schemes?

What about reading books on (FTP or similar) server algorithms to learn from?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 15
(1,285 Views)

I recommend you watch this video to give you some ideas on how to properly format your messages: 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 15
(1,269 Views)
Solution
Accepted by topic author ahmedmaken

Ok, looking at the code a little closer...

 

1. Do not branch your VISA Resource.  You are causing the Write and the Read to happen at the same time and closing it twice.  Do the write, if necessary, and then attempt to read.

2. You need to append a Line Feed to the string you write through the serial port.  This will allow the other side to detect the termination character and stop the read.

3. The rest of your logic makes very little sense.  What exactly are you trying to get the two computers to do?  It looks like a ping-pong setup, which I am not a fan of.  You should have one machine in control of the system.  A tells B to do something.  B sends the data back.  A can then decide to move to the next point and tell B when it is ready for the next measurement.  In this scenario, A is the master, maintaining the state of the system and B just does what it is told.  So perhaps a more obvious command structure would be desired such as sending "Take Measurement" instead of "01".


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 4 of 15
(1,262 Views)

I exactly want to do something like this but I can not find a way to implement it in the code.

0 Kudos
Message 5 of 15
(1,206 Views)

Hello,

I want to communicate between two PCs using Labview. I am using a null modem cable with USB to RS232 converters. 

PC1 (Stage) sends the signal to PC2(which is controlling the Camera) to take pictures at specific points and save them accordingly.

I am able to run these programs in the 'highlight mode' but not without it.

I tried changing the delays value but it still doesn't make a difference.

 

I don't know if I did something wrong here or have not added something important to run the program smoothly.

 

Help Required. Thanks!

Download All
0 Kudos
Message 6 of 15
(1,187 Views)

You definitely should not be constantly and opening and closing the ports.  Open the ports before their respective loops and close the ports after the loops.


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 7 of 15
(1,142 Views)

Like this?

Download All
0 Kudos
Message 8 of 15
(1,128 Views)

You only need to initialize and close the ports once.


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 9 of 15
(1,113 Views)

Okay thanks. I did that too. But still the problem is not solved.

0 Kudos
Message 10 of 15
(1,102 Views)