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 Interface for Arduino Discussions

cancel
Showing results for 
Search instead for 
Did you mean: 

Cannot Reconnect over TTL serial connection

I'm having a problem with both LIFA and LINX when trying to reconnect using the TTL serial lines on an Arduino Uno (pins DIO 0 and DIO 1).  I've loaded the LINX firmware onto the arduino, and can run the LINX-Blink example VI and blink the light as I should.  When I'm using the arduino's usb connection, I can stop the Blink VI and then restart it and I'll eventually (wish this reconnection were faster) be able to control the LED again. 

My problem is when I'm trying to use the hardware serial pins, DIO0 and DIO1.  Once the arduino is first powered on, I can run the Blink VI and connect and control the LED with no issues.  However, when I stop the VI and then run it again, the connection will always time out and show Error 5003.  Digging through some of the init VIs it looks like the "wait for packet" VI never sees any data on the computer's port. 

On a side note, when using LIFA, I was able to remedy this problem by disabling the VISA Clear block in the arduino init VI right before the VISA configure serial port block.  However, once reconnected I would have poor performance when controlling a servo using the Write Pulse Width block. 

Any information on this issue would be greatly appreciated! 

0 Kudos
Message 1 of 6
(4,012 Views)

If you are having issues with LINX, you should post on the LINX forums (because the author is only supporting LINX and on the LINX forums).

About stoping/restarting the VI:  How do you stop the VI?  Do you use the while loop stop condition (presumably with a boolean button on your front panel) or do you use teh 'Abort' button (the little stop sign button near the run button)?

0 Kudos
Message 2 of 6
(3,174 Views)

Thanks for the response   I've posted this issue in the LINX forum as well.  Testing some scenarios with LIFA this morning I've had these results.  I have modified the LIFA firmware on the arduino to include a communications timeout, so it sets the servo to a neutral position if no messages have been received.   I could run these tests again with stock LIFA to see if the results are the same.

1. Communicating with the Arduino's usb port, I can stop and run the program (not the abort button) and I'll regain communication as expected, and servo control is normal.

2. Communicating with the Arduino's usb port, stopping the program with the abort button, I can regain communication, but servo performance is "jittery" and not normal

3. Communicating with the Arduino's TTL ports via a USB to TTL adapter, stopping the program with the button, I can regain communication but the servo performance is "jittery".  Resetting the arduino, then running the program again will produce a normal result.

4. Comminicating with the Arduino's TTL ports via a USB to TTL, aborting the program, I can regain communication, but the servo is "jittery" again. 

Screenshots of the program and front panel are below.  Thanks for any input!

Screenshot 2014-12-03 09.45.33.pngScreenshot 2014-12-03 09.45.45.png

0 Kudos
Message 3 of 6
(3,174 Views)

I tried again with the unmodified LIFA firmware and here are my results.  Also, these results were obtained by disabling the VISA Clear block in the LIFA Init VI.  If the VISA Clear block is enabled, I cannot resync to the arduino over TTL.

1. Communicating with Arduino's USB port, I can stop (using the stop button) and run the program, and I'm able to communicate normally and servo operation is normal.

2. Communicating with the Arduino's USB port, if I abort the program, I can regain communications however the servo control is "jittery"

3. Comms via the TTL lines, if I stop the VI with the button then run the program I'm able to communicate but the servo is "jittery". A power cycle or reset will fix the issue.

4. Comms via the TTL lines, if I abort the VI then run again I'm able to communicate but the servo is "jittery".  A power cycle or reset will fix the issue. 

Thanks!

Screenshot 2014-12-03 13.23.22.png

0 Kudos
Message 4 of 6
(3,174 Views)

LIFA was only tested using the built-in USB port on the Arduino so that is the only thing that you can reasonably expect to work correctly IMO.

You should never abort the program if at all possible.  If you do abort, you simply need to run the Close.vi (with the correct COM port selected) to fix it.  If that doesn't fix it then there is something else wrong.

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

I've been able to overcome the connection issue with the TTL port.  It seems that something on the arduino side does not like receiving a Serial Break from labview or any other program.  In the Init.vi I replaced the VISA Clear with Flush I/O and wired 192 to the mask to discard the recieve and transmit buffers.  This seems to be the same thing the VISA Clear block does minus the break.  

Regarding the "Jittery" servos, my issue was getting into a state where I "attached" the servos twice.  I ended up writing a little function in LIFA to detect if the Set Num Servos command or the Configure Servo command had been previously called.  Labview could then query if these have been commanded previously and then decide to run the Set Number of Servos or Configure Servo VIs accordingly.  This helped me to recover much better when I lose communications or abort the VI. 

Thanks for the input!

0 Kudos
Message 6 of 6
(3,174 Views)