LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Restart VI on serial communication failure

Hi,

Attached is a simple VI which is used to transmit the string 'Read' through the PC serial port & receive a 20 byte string in response.The Rx lamp indicates healthy communication.

I am using a USB to serial converter which sometimes latches up. Then the VI has to restarted to start communication once again.

I need to find a way to programmatically restart the VI in case of serial communication failure.

Can anyone give any ideas?

I am using LabVIEW 2015.

Thanks in advance.

0 Kudos
Message 1 of 10
(776 Views)

Hi shantanu,

 


shantanu@india wrote:

I need to find a way to programmatically restart the VI in case of serial communication failure.

Can anyone give any ideas?


Idea:

  1. Check for serial communication errors.
  2. When an error occurs: close the COM port, wait for 2s, open the port again.
  3. back to item 1.
Best regards,
GerdW


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

Thanks GerdW.

Then I need to have the VISA close VI, error handler VI & the VISA initialization VI inside the while loop isn't it?

0 Kudos
Message 3 of 10
(760 Views)

Is there any way to programmatically restart the VI using state machine ?

I am not very familiar with state machines but I have read that it can be used under similar situations.

I'll try out your suggested method though.

0 Kudos
Message 4 of 10
(758 Views)

shantanu@india wrote:

Is there any way to programmatically restart the VI using state machine ?


Yes, a State Machine is exactly what you need here.  The basic idea is that you have specific states that do a single job.  For example, you may have "Initialize Port", "Read", "Error", "Close", and "Exit".  If the Read state detects an error, it should set the next state to run to be Close which will then set the next state to Initialize Port.  It is all about setting what to do next depending on whatever factors are involved.


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 5 of 10
(714 Views)

Thanks.

I'll try to write it using state machines & post it here for your comments.

0 Kudos
Message 6 of 10
(711 Views)

shantanu@india wrote:

 

I am using a USB to serial converter which sometimes latches up.


That USB to Serial converter doesn't happen to have a Prolific chipset in it? Years ago the market was flooded with USB-Serial adaptors made with counterfeit chipsets. Prolific released new drivers that could detect the counterfeits and disable them, which makes them appear to randomly lock up. No error is thrown by the Prolific driver, you just get a VISA timeout.

 

========================
=== Engineer Ambiguously ===
========================
0 Kudos
Message 7 of 10
(686 Views)

I am using ATC-820

0 Kudos
Message 8 of 10
(666 Views)

shantanu@india wrote:

I am using ATC-820


The web page says they use FTDI chipset so it's probably not that. 

========================
=== Engineer Ambiguously ===
========================
0 Kudos
Message 9 of 10
(660 Views)

Hi,

I tried for a few days to develop a bulletproof state machine code but for the time being dedcided to use a Ethernet-to-RS485 converter to tide over the immediate issue of the USB-to-serial converter dropping off service in Windows.

Shall definitely rewrite using state machines to enrich my knowledge.

0 Kudos
Message 10 of 10
(563 Views)