06-18-2009 10:43 AM
Hey, Im using a Model 81000 ultrasonic anemometer and Im having a few problems with visa errors. I have it running at 38400 baud rate, which is what it should be running at. Ive run it in hyperterminal and it works fine.
The problem Im mainly getting is that when I run it, sometimes it starts with a random sybol or character, and then it stops running and tells me I have a framing error. Sometimes as well, when I start it, nothing happens at all, and then after a lttle wait, it says I have a timeout error. Another error I sometimes get is the string that comes in is separated and placed on to 2 separate lines which I cannot work with. About half of the time it works fine, but for the other half im getting these errors.
When running fine, it should read one line of data which works out to 35 bytes. I have the anemometer running at 32 lines of data per second, so I changed the delay to give me just one line so that I can break up the string into various tokens, which I then save to a file.
Any help would be greatly appreciated.
06-18-2009 03:24 PM
My suggestion is to not use the "hard-wired" 35 into the Read. Use Bytes at Port inside a loop or state machine that reads the bytes until the expected number of bytes have arrived. At that point, use Read.
06-18-2009 05:10 PM
You've indicated you have two different problems. One is the timeout error. Since you've disabled termination character recognition on reads you need to specify the correct number of bytes to read. The previous suggestion is the correct approach. You will need to use a shift register to carry around what's been read so far, and when you actually have 35 characters then you can do whatever it is you need to do.
The other problem is the framing error. Framing errors are generated by the UART on your motherboard. Thus, it's hardware-related. A typical cause is a mismatch in baud rate or other serial port configuration. Another cause is a bad cable or noise on the line. Do a search on framing errors and you'll come across a lot of hits.