03-15-2012 08:32 PM - edited 03-15-2012 08:34 PM
I dont know why im getting a timeout error at the VISA read function(error says "timeout expired before operation completed"). I made sure the Labview serial port and my devices serial port are configured exactly the same. I even tested hyperterminal with the same port settings as in labview and it works perfectly but my labview program gives me an error. My device terminates each command it sends with a carriage return so i set up VISA READ to stop reading data when it encounters the CR character. I also made sure the carriage return was infact being sent by my device. Any thoughts?
Solved! Go to Solution.
03-15-2012 08:57 PM
Are you sure the command you are sending is formatted correctly?
I don't usually use a "send termination character on writing" option, preferring to add the termination character manually. Are you sure the termination character for the sent command is correct and being sent?
03-15-2012 09:46 PM
Have you tried increasing the time out period? Your picture shows a 100mS timeout .
That seems pretty short to me for a 9600 baud serial com.
03-16-2012 07:50 AM
You can use 'serial port monitor' to see actual data sending from hyperterminal and then with LabVIEW. See where is the difference. Might help.
03-16-2012 08:11 AM
@RTSLVU wrote:
Have you tried increasing the time out period? Your picture shows a 100mS timeout .
That seems pretty short to me for a 9600 baud serial com.
As RTSLVU said, increase the timeout period, reading 1000 bytes at a baud rate of 9600 will take more than 100 ms.
Ben64
03-16-2012 08:22 AM
I know im sending the correct commands because my controller is doing what the command tells it to. Ive tried increasing the timeout as well and still get the error(Ive tried changing it on the front panel and using property nodes). The only way I got it to work is if I simply dont connect the error wire to the VISA read function. If i do it this way i get no error and Im able to read and write correctly. I dont know if this is good programming practice or if it could cause problems somehow but its the only way it works.
Working code
03-16-2012 08:46 AM
I think it's not seeing your termination character on the read and/or write. When I send a string to the serial bus, I always use "Concatenate Strings" to add the appropriate termination character(s) to the end. Assuming your read termination is CR/LF, I've always had better luck stopping on the LF and stripping the CR with "Trim Whitespace."
Also, don't be afraid of making the timeout a second or two. If everything is going right, it will (normally) give the serial port plenty of time to complete its operation, but if things are going wrong, it will give you time to "notice" something is wrong.
03-16-2012 08:52 AM
Also, consider cleaning up the block diagram (straighten wires, place terminals in easy-to-see places, etc.). Sloppy wiring is like random indenting in text-based code. It doesn't matter to the compiler, but it makes it hard for a human to read.
Besides, your program will run slower because all those bits need to navigate those sharp corners (j/k, of course). 😄
03-16-2012 09:26 AM
Im pretty sure its seeing the CR because the "actual bytes read" indicator is showing the correct number of bytes that i expect to read for a particular command. I will manually add the CR just incase.
03-16-2012 09:37 AM
Still get the error. I guess i'll just leave the error terminal unwired.