Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

problem with multiline reading from serial RS232

Hey misio,
 
Unfortunately that's not how it works with previous versions of LabVIEW.  Could you convert it back to 7.1, or could someone else be so kind as to save it to 7.1
 
Thanks again,
0 Kudos
Message 11 of 20
(2,028 Views)
Hi,
 
Here it is in 7.1
 
I see that the error cluster is not connected to a shiftregister in the while-loop.  And the error indicator is out-side the loop.
This way you will only see the result of the last loop run after you exit and not while your VI is running. You can also add a event for errors to display the error.
 
If you wait 200msec before reading your device you must be absolutely sure that your device is ready after 200msec.
0 Kudos
Message 12 of 20
(2,015 Views)
KC, i experimentally detrmined the delay necessary plus some margin added but frankly it could sometimes happen that it may take longer for the device to respond
is there any better way for serial port to make sure that all we waiting for is ready to be read? assuming i dont exactly know number of bytes i need to read from the device, if i knew i guess its enough to just count the bytes
 
regards,
michal
0 Kudos
Message 13 of 20
(2,018 Views)

Hi Michal,

I cannot say that the VI i use is better but it works for me for all my devices at RS-232 and RS-485 interfaces.

The VI writes data to the COM port and then waits for the number of bytes OR waits for the same number of bytes at the com port for the last 5 cycles (100msec  / cycle) or times-out.

Like you said if you know the number of bytes it's easy. But it also helps if you only know the maximum number of bytes.

The VI works fine for me also for jobs where I don't know the number of bytes to receive. Just give it a try.

 

Message 14 of 20
(2,017 Views)
thx a lot for this, its good to learn new tricks!
0 Kudos
Message 15 of 20
(2,012 Views)

Misio,

Thanks for your efforts.

KC,

I too work with an undetermined amount of bytes to read from many instruments so I can hopefully make use of your COM vi.  Also, thanks for saving the other vi in 7.1, I appreciate it.

 

Regards,

0 Kudos
Message 16 of 20
(2,001 Views)
Blah.  It is also saved in 8... Smiley Indifferent
0 Kudos
Message 17 of 20
(1,996 Views)

For a few stars I'll do everything  Smiley Wink

Here it is. Although it's not much

0 Kudos
Message 18 of 20
(1,992 Views)
KC,
 
It's funny how the littlest of things can help you realise something so simple.  The send string in your VI immediately resulted in a timeout error and it gave me an idea to "piggyback" my scan (?SCU\r) command with the desired ACK response (\06).  Simply by sending the ?SCU\r\06 string I get a byte count greater than 0 every time.  Before my vi was messed up with something of a race condition problem that I've been having a lot of trouble with and sometimes I would get a byte count around 100, and sometimes I would get a 0 byte count.
 
Thanks KC
0 Kudos
Message 19 of 20
(1,986 Views)
Steve,
 
Looking back problems are always simple, even more simple when your manager is looking over your shoulder  Smiley Very Happy
 
Glad to see that it helps you.
0 Kudos
Message 20 of 20
(1,983 Views)