10-20-2011 11:44 AM
Hi, I use VISA write and read function in serial communication app, the device continuously sends 0x00 if it is not receive a request from Labview program running on PC.
And the request sent by labview is programmable. I met a weird problem, each time the request changes, the VISA read buffer output port still shows the last request firstly, from second time, shows the right request.
It works like: Req code: ... 50, 51,51,51,50....; VISA Read buffer: ...50, 50, 51, 51, 51, 51, 50....
Please refer to the program.
10-20-2011 12:15 PM
How are you running this? You don't have a while loop around it. Is it part of a larger VI? Please don't tell me you are using the run continuously button.
You don't have any wait statement between you VISA Write and your bytes at port. So it is very likely the receive buffer is still empty since you didn't give your VI time to wait for the device to turn around and give a reply. If you read 0 bytes, your VISA read string will be empty. How does your decoder subVI (which you didn't include) handle an empty string?
10-20-2011 12:41 PM
This vi is used to test VISA. in the program, it is a subvi inside a for loop, since I need to read 9 sensor's data, each sensor have it's own reqest code.
Now I met the problem is I can't add much delay between VISA write and Read, I have to meet the time requirement.
I used an array to store the request frames, for loop to index the array and read data.
10-20-2011 01:34 PM
Rereading your first post again, I'd say the problem is either with not having enough delay, you get the old value because you didn't give it enough time to read the new request and send out the new value.
Or the problem is in your device.
Are you always expecting 1 byte back for every request? Instead of doing bytes at port and reading that number, try reading 1 byte. If the byte isn't there, then the VISA Read will wait (up to the timeout value) for that byte to come in.