Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

Different Response from 'Run' and 'Single stepping'?

Solved!
Go to solution

Hi!

I am working on a mini project to control a monochromater (Model: Acton SP 2150i) and a photon-detecter.

 

In my program, the first step is to get the initial condition of the monochromater, including current wavelength, grating no. and scan speed. Please refer to step.bmp to overview the block diagram.

 

What confuses me is that  when I 'Single Step' the program, it comes out the right value to me (step.bmp and stepfromt.bmp show: current wavelength:299.995nm, scan speed:15nm/s, grating no.:#1), while I 'run' the same program directly, it comes the odd responses(run.bmp shows: scan speed:0.016666 nm/s, current wavelength:0 nm, grating no: #1).

 

Anyone could give me some tips? I am a new-comer to LabVIEW, and this problem exists for weeks...

 

Thanks!!

Download All
0 Kudos
Message 1 of 22
(5,070 Views)
Solution
Accepted by topic author TriStones

TriStones,

 

The fact that this runs when you single step it is an indicator of a timing problem.  You are writing the command to the instrument and then immeadiately checking to see how many bytes are in the rcv buffer.  Normally I'd suggest some delay between the VISA Read and the VISA Write to allow the entire reply from the instrument to be received by the COM port.  In this case, there's a better way to fix your code.  Your instrument uses a termination character when it transmits and you should configure your COM port accordingly.  VISA Read will continue to read from buffer until either the termination character is received or a timeout occurs.  I always suggest configuring the COM port in your LV code.  Don't like to rely on computer or MAX settings.  Someone may change something and break your program. 

 

Attached snippet should fix your problem.  Suggest you do a little reading on NI-VISA and how termination characters work.

 

Message 2 of 22
(5,049 Views)

Hi, Wayne. C !

 

Thanks so much for your reply, so appreciate of it.

 

Could you please recommend some reading materials related to LV, including NI-VISA? Coz I just read LabVIEW for everyone : graphical programming made easy and fun / Jeffrey Travis, Jim Kring. which seems to be a starter's guide.

 

 

0 Kudos
Message 3 of 22
(5,032 Views)

Here's a tutorial just on termination.

 

http://zone.ni.com/devzone/cda/tut/p/id/4256

0 Kudos
Message 4 of 22
(5,025 Views)

Hey, Wayne, may I ask a stupid question again???

 

In your program, what's the difference between '/'  and '\'?

Coz you write '\r' in the string constant, but '/r' in note box. Also, '?nm\min' is the command, but you write'?nm/min\r'

 

Thanks

Message 5 of 22
(4,994 Views)

Hi, Wayne.

 

I got it. '\'Codes display rather than '/'Codes display. 🙂

Thx!

Message 6 of 22
(4,982 Views)

That's not a stupid question, just an embarassing one for me.  Apparently I went a bit dyslexic in Monday AM fog.  Should look like this.  Note that I set each VISA Read up to read an arbitrary number of bytes as well.  Sorry about that.

 

 

 

0 Kudos
Message 7 of 22
(4,980 Views)

Good morning, Wayne~ Wait you for a long time:) (I am in Hong Kong, hah~time zone leads....)

 

I modified my program (initialization.png), following your advice.

1. I don't know how to add a Termination Character like that in your program, I have to get it 'indirectly', is it OK? Could you please tell me how to add a ASCII '\n' like yours? (my labview version is 8.0, possible?)

 

2. A new problem emerges... When I open the LV program from the file, run it for the first time, it always gives me the response of 0 nm/s scanspeed, 0 nm wavelength and 0 grating no. However, after I stop the program and run it again, the answer is right. Why so odd?

 

3. I noted your latest reply, which shows a 15 byte constant of the reading operation. Is it better to set a property node??

 

initialize.png

 

Another new problem is that, there is an even called 'GOTO', which ask the SP 2150i to move to a new wavelength, including 2 simple Sub_VI

goto.png

scanspeed.vi:

scanspeed.png

goto.vi

goto_subvi.png

The problem is that, after I run this event, seems data bytes are stuck in the COM terminal. I guess it's from the two read operation in the sub_vis...

If I stop the program here and run the program again, the initialization would give strange response, which seems that it reads the data from the last running.

Is it the data won't be eliminated automatically but keep accumulating?

 

I am getting crazy about the above odd cases... wait for your help. Thanks a lot

Download All
0 Kudos
Message 8 of 22
(4,966 Views)

upstairs is me~!!!! TriStrone...

I didn't notice that I logged in another account....

0 Kudos
Message 9 of 22
(4,958 Views)

1. I don't know how to add a Termination Character like that in your program, I have to get it 'indirectly', is it OK? Could you please tell me how to add a ASCII '\n' like yours? (my labview version is 8.0, possible?)  That constant is a numeric constant, representation is set to U8, radix is displayed and set for HEX.  Search the Labview help for 'numeric representation' and 'numeric radix'.

 

2. A new problem emerges... When I open the LV program from the file, run it for the first time, it always gives me the response of 0 nm/s scanspeed, 0 nm wavelength and 0 grating no. However, after I stop the program and run it again, the answer is right. Why so odd?  Not odd at all.  Very predicable.  You keep using the Bytes at Port property node right after you send a command to the instrument.  That means that the first time the program runs the bytes at port will return 0 and not try to read the buffer.  After that you are reading data from buffer that is acutally a reply from a previous command.  Try putting a probe on the value returned by Bytes at port and see for yourself.

 

3. I noted your latest reply, which shows a 15 byte constant of the reading operation. Is it better to set a property node??  Get rid of the property nodes. 

0 Kudos
Message 10 of 22
(4,956 Views)