LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Slow serial com/Cant do serial write and read at the same time

Hi,

 

I am just trying to do a basic serial communication between arduino and labview, but I am having trouble doing serial read and write at the same time.

 

On my arduino side of code, I am just doing a very basic Serial.println and just sending values for a counter/timer. So currently my problem is, I have a control for the write buffer, if I left the write buffer empty, I can read normally. However, as soon as I start writing something into the write buffer, I cant read anything. I have tried putting read and write in sequence (both read and then write, and write and then read), but I get a at least 1 second delay in the while loop. I have also tried flushing the receive buffer after a read. 

 

I have tried a lot of examples found online, including the examples come with labview, I either get a massive delay (>1 seconds) or cant receive or write probably.

 

Please find attached my labview vi. Any help would be appreciated!! Thanks 🙂

Download All
0 Kudos
Message 1 of 4
(4,154 Views)

Serial mean that you can read or write, but not both at the same time. Maybe you get long period because no data in read buffer, but Visa read wait it (see timeout settings)

 

You can check bytes at port, and then read it if number >0

visa.png

 

0 Kudos
Message 2 of 4
(4,139 Views)

Hi Artem,

 

Thx for the reply. I have also tired bytes at port before, but it always returns 0 when I write something, and as long as im sending something in the while loop it stays 0. It becomes normal again after I empty the write buffer. If I dont use the Bytes at port and just leave read and write in a sequence, it will keep reading. However, it has pulses of long delay. What I mean by that is something like this: delay 20ms -> 20ms -> 20ms-> 1000ms -> 20ms. 

 

Capture.PNG

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

1. Do not use the Bytes At Port to determine how many bytes to read.  Since you are using PrintLn, you can just let the termination character tell the VISA Read when to stop reading.  Just use a "large" constant for the number of bytes to read.

2. Are you getting any errors?

3. Could you share your Arduino code as well?  There is a change that your problem is in there.

 

Here is a cleaned up version of the main VI:


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
Message 4 of 4
(4,123 Views)