12-16-2009 12:36 PM
Hi,
I have a program that reads voltages and temperatures every ~10seconds. There is also an actuator card which will turn on and off heaters depending on the temperature of the thermocouple attached to it. The error I am having is in the communication with the Agilent 34970A. The communication via GPIB has no problems (used when I need multiple Agilent units), however there are random problems when using RS232. It normally takes a day or two before the error occurs, I come back and the Agilent shows that there were several "Query Interruption" errors, which causes some unexpected data.
I want to leave the session to the COM port active, since I will be calling the serial port regularily and nothing else should be using the port. I have been messing around with this code for a while, it seems like it's becoming more complicated than it needs to be. If anyone could give me some advice it would be appreciated.
12-16-2009 01:04 PM
12-16-2009 01:13 PM - edited 12-16-2009 01:16 PM
Thanks for the quick reply. The 'Clear' call was just one the the things I added in to see if it would fix it. I was getting the error prior to adding it, and I thought that clearing the buffer might help fix the problem (but it didn't). I have removed it.
I am running the test again right now with a few other modifications. I am doing a check on the number of bytes available on the port, and reading until I receive a new line return. I put that in a loop which will run for up to 10 seconds. (I thought this is what the regular read command should do, but the old code I have from the previous developer works and thats what he did).
I am using VISA 4.3 (all our computers are running XP)
12-16-2009 01:23 PM
12-16-2009 02:20 PM
The default endchar is a line return, so I never bothered setting it (don't know if it is better practice to always put it in there).
The byte count was just how many characters to read, it was just a control that was always set to 1024 bytes, large enough for any return data. The new modifications I made would only read what is available, so the byte count variable is gone.
Is it better practice not to have local variables on this sort of vi?
12-17-2009 03:41 AM
Hi
It is always better to have no local vars if not really needed. They can introduce race conditions in your code!
Indeed make that bytecounta constant and make sure you send a linefeed and/or a carriage return.
I don't know the character line return....![]()
But check also what you send out. The output character that you expect to be sent is only there when explicitly asked for.