From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Read Serial Port if Serial Break Detected

Solved!
Go to solution

Hi Everyone,

 

I am attempting to create a VI that will write a serial break, write a serial message, then wait for a serial break to be received and if one is received, read what is at the serial port.  However I cannot get the VI to detect that a serial break has occurred.  I have looked at and followed what was done in the "Detect Break Event.vi" example provided in the Labview examples.  The micro that the VI is talking to is sending a 13 bit break (about 57us in length), as intended, proven by use of an oscilloscope but Labview is not catching it. I have attached the VI in question.  It is used as a sub-vi in a larger program.  Am I missing something or doing something incorrectly?

0 Kudos
Message 1 of 6
(5,672 Views)

You're timeout for the Wait on Break function is only 2 milliseconds.  Are you sure 2 milliseconds is long enough to wait for VISA to determine that a break occurred on the serial line?  I would try a longer timeout.

 

The default Break length seems to be 250 milliseconds.  Since you are breaking the line for only 57milliseconds as the microcontroller end, I would write a much smaller value such as 40 milliseconds to the Serial property for break length, and set the timeout on the Wait for break to be something longer than 57 such as 100 milliseconds.

0 Kudos
Message 2 of 6
(5,653 Views)

Thank you for your response. I think you misread the length of the break that is being sent from the micro, it's 57 microseconds not milliseconds. Looking at the help for the Break Length property it says that valid values are between 1 and 500 milliseconds. Does this mean that Labview is not capable of detecting a break that is less then 1 millisecond in length?

 

I have tried many different values (0-1000) for the timeout on the wait for break and was not able to detect anything.

 

Any help would be great.

0 Kudos
Message 3 of 6
(5,635 Views)

You're right.  I did misread that and start thinking 57 milliseconds.

 

I do believe 57 microseconds would be too short to be detected as a break.  I don't know what your baud rate is, but for the sake of argument, I'll say 9600 baud.  So that means each bit lasts 104 microseconds  (1/9600).   A break of only half that could easily get lost.  I bet the serial ports if presented with a break of that length might just assume it is a fraction of a bit.

0 Kudos
Message 4 of 6
(5,630 Views)

I have a baud rate of 230400 (4.34 microseconds per bit @ 13 bit break is 56.4 microseconds).

 

For my setup, I have the micro connected to an EasySYNC serial communication box and that runs through USB to the computer. Shouldn't the UART on the PC be able to pick up on this break? Is there a way to translate this to Labview?

 

If not I may have to look into sending a longer break from the micro.

0 Kudos
Message 5 of 6
(5,626 Views)
Solution
Accepted by topic author joshk11

I don't know.  230,400 is a very fast rate.  The UART in the PC isn't really in play, but the USB/serial EasySync box is what is the factor.  The fact USB is part of the communication may be adding some complications.  You might have to browse any detailed technical data on the EasySync to see if they talk about it.

 

I would definitely try a much longer break to start with.  If that works, then start working backwards to smaller breaks.  If a long break doesn't work, then you know the problem may be elsewhere.

Message 6 of 6
(5,607 Views)