10-25-2007 03:12 PM
10-25-2007 03:36 PM
The wait is there to give the serial instrument time to place the results of the query into the receive buffer of the pc's serial port. A wait is necessary in this example because the VISA Bytes at Serial Port is used. If the instrument has not completed it's transmission, the VISA Bytes at Serial Port will report an incorrect number of bytes to read.
There are numerous other ways to do a serial write;/read. If the instrument sends back a termination character (i.e. CR or LF) at the end of the data, then the VISA Configure Serial Port will be set up for that, no wait is used, the VISA Bytes at Serial Port is not used, and a large number for the bytes to read, can be wired to the VISA Read. With a termination character, the VISA Read will wait until the termination character is detected and then terminate the read. It does not wait until the number of specified bytes is read. the advanced example is setup like this.
You can also eliminate the wait by using a couple of loops. In the first loop, do a VISA Bytes at Serial Port and exit when the number of bytes is greater than 0. In a following loop, have a VISA Bytes at Serial Port and a VISA Read. Exit this loop when the number of bytes is 0.
What you use will be dependent on the type of data being sent and how it's formatted by the instrument. A simple wait may work if the length of the data is very consistent and a termination character is not sent. If the amount of data is inconsistent and there is no termination character, you might want to use the loop approach. What you don't want to do is have to be constantly modifying the wait to accomadate larger amount of data or have a large wait when small amounts are sent. For example, if you wait for 100 msec and the data is available in 10, you are wasting a lot of time if you have a lot of transactions.
10-25-2007 03:50 PM
10-26-2007 10:51 AM
10-26-2007 12:12 PM
10-26-2007 09:36 PM
Framing errors are an indication that there is a problem at the lowest level of serial communication. I have only seen this error in VB programs I have written if the serial connection is disconnected in the middle of communication. Here is a link with a pretty good description. I would guess that you might have a noisy serial line either through loose connections or EMI. Could you look at the signal using an oscilloscope to see if anything is unusually (like noisy spikes) in the signal? I guess the other possibility is that the clock timebase is slightly different. What is the baud rate for your application?
Search the discussion forum on framing errors. I discovered this link (actually thru google) that talks about null characters causing framing errors.
10-27-2007 10:22 AM
10-29-2007 11:05 AM
10-29-2007 01:48 PM
10-29-2007 04:56 PM