12-13-2006 11:41 AM
12-13-2006 12:55 PM - edited 12-13-2006 12:55 PM
Are you initializing the serial port out side of the main loop? If you are you don't need the shift registar.
Don't forget to close your port when your loop stops.
As for the error handling, it all depends on how you using the error to stop your loop.
Good Luck
Message Edited by arvin labrat on 12-13-2006 10:57 AM
12-13-2006 01:21 PM
12-13-2006 02:31 PM
Use the Bytes at Port function to see if there is something to read before you attempt to read. You can put this function in a while loop. Exit the loop on any of 3 conditions: bytes at port reports more than 0 bytes, an error occured, or the iteration terminal got larger than a certain number (timeout). Don't forget to put a small delay in the loop so that the CPU doesn't get tied up. If you get timeouts, then your serial port is not receiving anything. Check what you are sending to ensure it is the right command to cause a response.
Also, I usually wire the error wires to a shift register in the main while loop of a state machine. This way, errors get propogated to the next state. You have to put code to handle the errors, and perhaps exit the loop upon error.
12-13-2006 02:31 PM
What kind of instrument are you connected to and how is your state machine set up? Do you do a write before every read or is the instrument set up to constantly write without getting a request? How are you determining the number of bytes to read?
If you could post the VI you've written and the make and model of instrument, that would help someone diagnose your problem.
12-13-2006 03:51 PM