LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Visa read

I'm trying my best to use VISA lately with 7.1, rather than reverting back to the trusty old Serial vi's. I'm hitting some snags - things that worked before might nort work now. Please view the attached screen shot. This is how I am reading the com port. On occasion, I get a framming error, but now always. I've checked the normal stufff - parity, stop bits, baud rate, etc. Is there anything inherently wrong with what I'm doing here? Would you do it differently?
note: the "1RPA0" is the command for the serial device to check a digital input. Elsewhere in the program, there are lots of serial writes but no other reads.
Richard






0 Kudos
Message 1 of 6
(3,268 Views)
I would put the VISA read in a case structure, and only execute it if the Bytes At Port was greater than 0. Better yet, create a loop to read Bytes At Port and exit the loop only when Bytes is greater than 0 or some timeout value. Then read VISA if loop has not exited due to timeout (bytes > 0). Put a timer in your loop to allow time for all bytes to be recieved to get to the port.
- tbob

Inventor of the WORM Global
Message 2 of 6
(3,268 Views)
Thanks. While your suggestions didn't fix the problem, they did remind me to make sure I have bytes before I read them. Now I can check for comm failures.
What DID seem to work was adding a Flush Buffer function before I do the write/read.
I have attached the fix. Does this make sense? Why did the old serial vi's work fine every time, whereas the VISA function require more code?
Richard






0 Kudos
Message 3 of 6
(3,268 Views)
forgot attachement
Richard






0 Kudos
Message 4 of 6
(3,268 Views)
My guess is that your serial port had received garbage characters before the Visa read was done, possibly corrupting your read with a framing error. By flushing, you get rid of those extra characters. Don't know why the old serial read worked whereas the Visa read needed flushing beforehand.
- tbob

Inventor of the WORM Global
0 Kudos
Message 5 of 6
(3,268 Views)
Me neither. Maybe bacuase I didn't use the error handlers in the old VI's, I was getting garbage, or hiccups, and not realizing it. The VISA stuff forces the issue in reagrds to errors.
It's working fine now. Thanks tbob
Richard






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