LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Need help reading a response from an instrument (herein my case : monochromator)

Solved!
Go to solution

In this Vi I am not able to read the correct response from the monochromator.

 

I also want to know how pause time should be given between writing a code and then reading its response from the instrument.

 

In the manual its return to access a wavenumber:

1).  Send 5, wait for it to get acknowledged (ack).

2).  Send 10, ack 10.

3).  Send Filter Status, ack it.

4).  Send WaveNumberMSB, ack it.

5).  Send WaveNumberLSB, ack it.

Now for me problem comes here in the next (6th) i.e:

 

6). Wait for any of following response: 20 or 14 or 7 from the monochromator

now question:

(i)    To read the response, I use the VISA read buffer so how much pause I should give between the                  acknowledgement of the above 5 steps and waiting for response?

(ii)   How do I know how much time to wait for the response?

(iii)  In the above 5 steps what is meant by acknowlegement of a cose by the monochromator? (what i think is that when I give 5 to the monochromator, I wait for it give me back 5 saying that hey I received your code, man send the next). Please do tell if I got the meaning of ack right.

(iv)  Now while acknowledging should I give a pause time b/w the visa write and read buffer?

(v)   Also I am getting a status code of 1076376924 while ack-e-ing the codes, should I worry here, if yes how to remove this?

(vi)  I have waited for 60sec for reading the repnse(20 or 14 or 7) but when I ran the vi it did not read anything.

 

I have attached the manual and the vi

Please help ASAP.

Thanks in advance....

 

 

 

Download All
0 Kudos
Message 1 of 6
(1,547 Views)
Solution
Accepted by topic author yogesh10994

All I know is what your little pdf says.  We know nothing about your instrument.  But here are a few things:

1. DO NOT USE THE BYTES AT PORT!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! (I hope I emphasized that enough...)

You are expecting 1 byte to come back from the instrument.  So just tell the VISA Read to read 1 byte.  If the instrument does not response for some reason, you will get a timeout error (currently set to 10 seconds).

2. That error code you stated does not make any sense.  I would possibly expect a warning saying "Number of bytes requested was returned therefore there may be more data."  If you get that warning, you can ignore it.  Anything else sounds like a problem.

3. Once the instrument acknowledges the byte, you should be free to send the next one.

4. Are you getting any data back with the ACKs?  If not, my guess is you have a hardware issue.

  • Wiring issue
  • Some other serial setting not mentions on that sheet is wrong
  • The instrument has to have the serial port enabled through some menu

I did some cleaning up of your VI.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 2 of 6
(1,526 Views)

First of all I would like to thank you very much for your prompt response and help. I would like to tell you it worked the way you told me. I am getting the desired wavelength(hence the colour) from my monochromator.

 

For the sake of knowledge I would like to know:

 

1). What is the purpose of 'Bytes at Port' ? Since it was already given in the manual to read and write one byte, so i fed one byte to the read buffer. But if it was not given then I guess I should have used it?

2). Reason for not using Bytes At Port?

3). Since I am reading only one byte it gives a warning code no: 1076376294 meaning "Number of bytes requested was returned therefore there may be more data." So why am I not interested in reading those other data? What type of data r they that we r not interested?

4) In order to read 'those other data' should  I put a read buffer in a loop? But then until how much time shall I run the loop?

4). I want to know the concept of talking with the instrument.

When I write something in the write buffer what am I actually doing? When I write something in the write buffer it instantly goes to the instrument or when I write something it is stored temporarily in the memory (which?) or    it is stored in the port (say usb port thru which we r talking) and through the cables that goes to the instrument?

5). Same way I want to know the working of read buffer?

6). In some vi examples I have seen people wait between reading and writing a code to the instrument. Is this correct then how do we know how much to wait?

 

 

Thank you once again.... I have attahed the vi.. Wavelength in loop is the main vi whereas the other two r subvi s used in the main vi

 

0 Kudos
Message 3 of 6
(1,467 Views)
Solution
Accepted by topic author yogesh10994

@yogesh10994 wrote:

First of all I would like to thank you very much for your prompt response and help. I would like to tell you it worked the way you told me. I am getting the desired wavelength(hence the colour) from my monochromator.

 

For the sake of knowledge I would like to know:

 

1). What is the purpose of 'Bytes at Port' ? Since it was already given in the manual to read and write one byte, so i fed one byte to the read buffer. But if it was not given then I guess I should have used it?

I can't really think of a reason any more to use it.

 

2). Reason for not using Bytes At Port?

(See 1) above)

 

3). Since I am reading only one byte it gives a warning code no: 1076376294 meaning "Number of bytes requested was returned therefore there may be more data." So why am I not interested in reading those other data? What type of data r they that we r not interested?

The reason why it throws this warning is to let you know of the possibility that there could be more data.  It's like buying a soda from a vending machine.  You bought one soda, and you got one soda, so you know that there was at least one soda in the vending machine.  (Let's just pretend the "sold out" light wasn't working.)  But there may be more.  But if you tried to buy 10 sodas at once (let's pretend the vending machine could vend several sodas at once) and only one came out, you would know that there was only one soda in the machine.

4) In order to read 'those other data' should  I put a read buffer in a loop? But then until how much time shall I run the loop?

You don't need to worry about this.

4). I want to know the concept of talking with the instrument.

When I write something in the write buffer what am I actually doing? When I write something in the write buffer it instantly goes to the instrument or when I write something it is stored temporarily in the memory (which?) or    it is stored in the port (say usb port thru which we r talking) and through the cables that goes to the instrument?

Probably you should Google serial communications.  The concept of VISA is so you don't have to wirry about stuff like that.  The idea is that (ideally) you don't even have to know what the interface that you are communicating with is.

5). Same way I want to know the working of read buffer?

See above.

6). In some vi examples I have seen people wait between reading and writing a code to the instrument. Is this correct then how do we know how much to wait?

You wait if the programmer's guide tells you to wait.  In fact, having to add hardcoded waits if not explicitly required is a good indicator that you do not truly understand how to communicate with your equipment.

 

 

Thank you once again.... I have attahed the vi.. Wavelength in loop is the main vi whereas the other two r subvi s used in the main vi

 


 

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
Message 4 of 6
(1,459 Views)
Solution
Accepted by topic author yogesh10994

yogesh@10994 wrote:

1). What is the purpose of 'Bytes at Port'?

In your situation, it just causes problems.  I have 1 use case for the Bytes At Port and that is for a device that randomly sends data (non-deterministic, no command to request data).  In that one case, I use the Bytes At Port to see if a message has started to come in.  I then tell the VISA Read how many bytes to read.  NEVER USE THE BYTES AT PORT TO TELL VISA READ HOW MANY BYTES TO READ.

2). Reason for not using Bytes At Port?

In a nutshell: Race conditions.  In your case, you send a byte and expect a byte back at an acknowledgement.  If you check Bytes At Port immediately, it will say there are 0 bytes.  You then read 0 bytes and wonder why the acknowedgement did not work.  Since you know you will get 1 byte back, just telling VISA Read to read the 1 byte eliminates these race conditions.  VISA Read will return the byte you asked for as soon as it comes in.  So this also eliminates wasted time waiting.

3). Since I am reading only one byte it gives a warning code no: 1076376294 meaning "Number of bytes requested was returned therefore there may be more data." So why am I not interested in reading those other data? What type of data r they that we r not interested?

Per your protocol, you only get 1 byte back.  So trust the protocol.  You will get a data error later on if something is broke in the protocol.

4). I want to know the concept of talking with the instrument.

When I write something in the write buffer what am I actually doing? When I write something in the write buffer it instantly goes to the instrument or when I write something it is stored temporarily in the memory (which?) or    it is stored in the port (say usb port thru which we r talking) and through the cables that goes to the instrument?

VISA passes the data to whatever communication chip was referenced.  In your case, a UART chip was used.  So this chip takes that data and sends it out the serial port per the RS-232 standard.  To you, this is instant.  To the computer, there are a few clock cycles for this to happen.  As previously said, you don't care.  You write the data and data comes back from the instrument and you can be happy.

5). Same way I want to know the working of read buffer?

Same as the write, just in reverse.

6). In some vi examples I have seen people wait between reading and writing a code to the instrument. Is this correct then how do we know how much to wait?

As previously stated, it depends on your instrument.  Most instruments do not need the additional wait.  If you do need to wait, it should be documented somewhere in the manual how long you need to wait.


 


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 5 of 6
(1,444 Views)

When I run the main VI (lia vid mono), I get an error in the visa read in both the subvi (reset the monochromator and set wavelength)  "VISA:  (Hex 0xBFFF0015) Timeout expired before operation completed." But this error occurs only in the FIRST ITERATION of the while loop (however the reset subvi runs only once). When I press the continue button  (when the error message pops up), then this error does not occur for the rest of the remaining iterations of the while loop and I am able to record the correct values from the lock-in-amplifiers.

 

Also when I run both these SubVi individually I don't get any error.

 

 

 

0 Kudos
Message 6 of 6
(1,419 Views)