LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

VISA serial read returns previous value

Hi I am trying to read from an unit using following VI (screen shot attached). For the first loop, I end up reading the previous value from the unit. I am expecting that after trigger (T command through VISA write) and then read (VISA read) should return me the current value. the time delay is 200 ms second before read as mentioned in the manual. What is going on?

0 Kudos
Message 1 of 8
(4,590 Views)

Hi Jpdas,

 

you need to flush the IO buffer before sending commands to your device!

And use FlushIOBuffer instead of CLR!

 

You don't need an additional delay between VISAWrite and VISARead when the buffer is empty…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 8
(4,583 Views)

You are sending two commands, "N5" and "T".  Do each return a repsonse?  You are only reading 1 response right after you send the "T".  If each sends a response, then every iteration you are receiving 2 responses, but only reading 1, probably the response to the "N5" command.

0 Kudos
Message 3 of 8
(4,579 Views)

I tried flush IO buffer before sending the write command (N5). Also, replaced the CLR with flush IO buffer. So I have two flush IO buffer, in begining and after read, is that the way you suggested? Also, I am not sure about the mask option in flush io function. I tried all options but nothing works. 

0 Kudos
Message 4 of 8
(4,544 Views)

N5 command do not return a response, only T return a response.

0 Kudos
Message 5 of 8
(4,543 Views)

Where is the manual?

 

If you are writing 2 commands, only 1 is responding, and you are reading 1 time, you should not be having a problem.  And if you are clearing the buffers before writing, you certainly should not be getting stale data.

 

Are you sure your device is working right?  How do you know it is returning a previous value and not a new value that just happens to be the same?

0 Kudos
Message 6 of 8
(4,532 Views)

I am changing the magnetic field in every while loop and for that there is a corresponding voltage on the unit i am trying to read. So when i am running 0 to 3 loop, my i = 0 loop returns the last value (volts measured by the unit), for my i=1 loop, i am getting value that suppose to be measured for loop 0..and so forth. so when i am running n loop, my reading is for n-1 loop.

I dont have real manual, this unit is part of a mass spectrometer control unit without any technical support. I reverse engineered the commands through source code given for the old software written in Modula 2. 

0 Kudos
Message 7 of 8
(4,526 Views)

If you are sending a command and then reading a response, perhaps it takes some time for the device to act on the command you sent it.

 

Try putting a wait delay between the commands.

0 Kudos
Message 8 of 8
(4,494 Views)