LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

delay when introducing serial port to main loop

Solved!
Go to solution

From looking at your code, it's clear what is happening.

 

You are getting timeout errors from the serial port code. When you attach the wires to your main loop you force the serial port code to execute before the main loop executes. This is what causes the startup delay.

 

Without the wires - the two sets of code run in parallel so you don't see the delay that is always occurring in the serial port code.

 

So first off, your serial port code is not working. Since the vis are not included, that's all I can say at this point. Is the device connected? Can you communicate with it using hyperterminal?

 

Second, when wiring items on the block diagram, try to keep wires as straight as possible and rarely (and I mean very very rarely) loop a wire backwards. This makes the code more readable and maintainable.

 

I noticed this comment in the tab control: "One more time in error handler for good luck". That gave me a chuckle.

 

steve

 

 

 

 

----------------------------------------------------------------------------------------------------------------
Founding (and only) member of AUITA - the Anti UI Thread Association.
----------------------------------------------------------------------------------------------------------------
0 Kudos
Message 11 of 15
(1,227 Views)

Thanks Steve.

This is good info and is what i was looking for.

That timeout is hitting the mainloop each time on my real program, i just didnt notice it until now..

Its most noticeable right when it starts up though, like you said.

 

What is funny is that, the serial device is connected to the PC serial port and working fine.

Its communicating every time time the code is run, regardless of slow responce times and regardless of it being connected to the while loop . It even streams data from the while loop when i do calls inside the while loop, although slower then it should be.  I know from debugging the problem has to do with switching baud rates of the remote device and then on the local comm.

 

I think we are pretty much set with this. I think im just going to not swtich rates although id still love to know why im getting an error although it seems to be working.   The code for the initializtion of the serial port, even in the example file, is so big that it would fill most of a screen shot image that was requested so i just made sub vis. I did forget to upload them. here you go.. Attached i think.

 

Message Edited by jimmyinct3 on 10-29-2009 04:49 PM
Download All
0 Kudos
Message 12 of 15
(1,216 Views)
its still weird too that the error handler case statement is only triggered when its wired to the whlie loop too
0 Kudos
Message 13 of 15
(1,211 Views)
Solution
Accepted by jimmyinct3

Hi Jimmy,

 

I had to reply to this one, since I remember many long hours on the first floor of ITEB and the third floor of EII.

 

Moving on from nostalgia, one thing I might add is that most of time you don't need to set the input buffer size or the XON/XOFF character, though I don't know the device you're attempting to communicate with.  Those are pretty nitpicking options if you're got a really finicky device.  Generally speaking, the following paradigm (in the attached screenshot) is a good place to start, in my humble opinion.

 

I hope this helps you out and makes life a bit easier. Unfortunately I'm about to go home for the evening, so I won't be able to reply much more.

 

Good luck,

 

Jim

(Uconn grad)

Message 14 of 15
(1,209 Views)

you got it

if the input buffer size is set in the manner specified, the delay goes away.

The error trap is also not triggered.

 

kudos to the uconn grad!

 

 

0 Kudos
Message 15 of 15
(1,193 Views)