From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.


Showing results for 
Search instead for 
Did you mean: 

unreliable serial comms

Go to solution



I've been fooling with this for awhile and can't seem to get it to work properly so I thought I'd ask for help.


I've written an interface for a PIC and can't seem to get it to send commands and receive them reliably.  Sometimes, they'll go through and other times they won't.  The PIC output is read through another 'while loop' repeating every 10 ms, while the user commands are sent in another 'while' loop that runs only upon front panel activity.  I'm not sure if the two different run times have anything to do with it.  The 'read' portion is much slower than it ought to be when compared with hyperterminal and it often doesn't read at all.  


I know part of the problem has to do with RF leaking into the serial cable because the program runs better at my desk than at the test setup, where our device is emitting RF.  Other than that, though, I don't know what the problem is.  Hyperterminal seems to communicate with the PIC much more reliably.  Does anyone have any suggestions? Do I need to send commands multiple times?  Why is the 'read' so unreliable?  I know all of the commands are being sent correctly and in the correct format, BTW.  


The first 2 attachments are sub-VIs and the last is the main program.


Thanks in advance. 

0 Kudos
Message 1 of 13

Update: OK, it turns out that it was actually reading, but that the 'read' loop was cycling so quickly that what was being read just flashed on the screen and you would only see it occasionally.  The 'read' loop now looks like this:






I changed the read loop delay to half a second and now you can see the output from the PIC.  I also added a property to the read property node so that the VISA read would just grab whatever bytes were available.  


What I really want to do is make a scrollable waterfall display of the incoming commands from the 'read' that just continually appends more.  Does this make sense?  

0 Kudos
Message 2 of 13

OK, I've attached an image of what I'd like the 'read' loop to do, but LabView won't allow it.  Any suggestions?
0 Kudos
Message 3 of 13
Of course you have a broken wire. You are trying to wire an array to a single string indicator. You would have to wire the array to a string array. If you want to display all of the data in a string indicator, use the concantanate string function and not the build array. You'll also probably want to set the position if you append to the end of the string. do that with a scroll position property. Or, put the new string at the beginning of the previous string.
Message 4 of 13

If you want to store it as an array of strings, you would need to do the following:


0) Disconnect the input of the shift register (right side).

1) Connect the output of the build array to the shift register (right side).  [You don't want the output of the read going to the shift register]

2) Disconnect the output of the first read going to the shift register (left side).

3) Connect the output of the first read to a build array (single input).  [The output of that will be a 1-D array with one element in it]

4) Connect the output of the build array in step 3 to the shift register (left side).

5) Delete the PIC output indicator

6) On the output of the build array inside the loop, right click and select Create--> Indicator

-Matt Bradley

************ kudos always appreciated, but only when deserved **************************

Message 5 of 13

Is this what you meant? (attached)


It wouldn't allow step 4 so I couldn't get it to work. 

0 Kudos
Message 6 of 13

I think you meant "wire the left side of the shift register to the input of the 'build array' function" for 4). (see 1st attachment)


That seems to work almost the way I want, but it still has this indicator on the side and doens't really show the current command coming down the pipe and the last few, which is what I want.  Instead, you have to keep clicking up on the indicator (see 2nd image).  I want it to look exactly like HyperTerminal's display

Download All
0 Kudos
Message 7 of 13



Is this what you meant?  I'm not quite sure how to wire up the scroll property node to get it to show the most recent command and the past few.  

0 Kudos
Message 8 of 13
First, right click on the property node and select "Change to Write'. Then, right click on the input and select 'Create Constant'. Just use some very large number.
0 Kudos
Message 9 of 13



Thanks a lot.  Is this what you meant?  (attachment 1)  It works!


The only issue I have now is that I want to turn the read 'on' and 'off', but when it's 'off,' I still want to be able to scroll back through what has already been read.  I tried adding a true/false case statement inside of the 'while' loop and putting the  'read' inside of the 'true' statement (attachment 2), but I don't quite know what to do with the 'false' statement (att. 3).  It seems to me that it will keep concatenating as long as the 'while' loop is running, and I only want it to concatenate when the 'read' control is flipped to 'on.'  

Download All
0 Kudos
Message 10 of 13