01-17-2011 07:05 AM
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!!
Solved! Go to Solution.
01-17-2011 08:07 AM - edited 01-17-2011 08:09 AM
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.

01-17-2011 09:25 AM
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.
01-17-2011 10:35 AM
01-18-2011 12:19 AM
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
01-18-2011 06:56 AM
Hi, Wayne.
I got it. '\'Codes display rather than '/'Codes display. 🙂
Thx!
01-18-2011 06:58 AM - edited 01-18-2011 06:58 AM
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.

01-18-2011 07:54 AM
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??
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
scanspeed.vi:
goto.vi
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
01-18-2011 09:05 AM
upstairs is me~!!!! TriStrone...
I didn't notice that I logged in another account....
01-18-2011 09:09 AM
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.