LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Monochromator interfacing and programming

Hi,

 

I am trying to interface a monochromator and write a program. The monochromator is from a local company. They provided initialization parameters and code to communicate. The communication was done through RS232 via a USB converter. I find the interfacing was successful (see a.png). I tried to write a program based on the code provided.

----------------------------------------------------------------------------------------------------------------------------------

Code:

Initialization Parameters for Serial Communication

 

Baud Rate: 19200 bps

Byte Size: 8

Parity: None

Stop Bits: 1

 

Selecting a wavelength

 

  1. Send 5 to controller and wait for the acknowledgement 5.
  2. Send 10; ack 10.
  3. Send WNByte1; ack WNByte1
  4. Send WNByte0; ack WNByte0.
  5. Wait for 20.  The monochromator will send this code after the specified wave number is set.  If you want to stop the process before receiving this code, send 100.  Also, if you are receiving any other code here instead of 20, it means an error condition.

WNByte1 = Integer value of (Wave Number / 256).

WNByte0 = Remainder of (Wave Number / 256).

----------------------------------------------------------------------------------------------------------------------------------

However, I did not receive an acknowledgment from the instrument while using LabVIEW program (see b.png). Even in VISA test panel, I did not receive any acknowledgment. I am using LabVIEW 2010 on a Windows 10 run laptop. Could anyone please help me find the issue?

 

Thank you.

Pradeep.

Download All
0 Kudos
Message 1 of 5
(2,345 Views)

Hi pclab,

 

don't use BytesAtPort, it's wrong 99.9% of all time…

Best regards,
GerdW


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

@GerdW wrote:

Hi pclab,

 

don't use BytesAtPort, it's wrong 99.9% of all time…


And in the off chance that the instrument does not have a termination character you should put some wait between your write and your bytes at port. Your bytes at port is likely getting 0, so you're reading 0 bytes.

 

Another thing that you need to verify is whether your protocol requires you to send a termination character. Since you said that it doesn't work in the test panel I suspect that the instrument may be sitting there waiting for a termination character.

0 Kudos
Message 3 of 5
(2,298 Views)

Hi,

 


@johntrich1971 wrote:

@GerdW wrote:

Hi pclab,

 

don't use BytesAtPort, it's wrong 99.9% of all time…


And in the off chance that the instrument does not have a termination character you should put some wait between your write and your bytes at port. Your bytes at port is likely getting 0, so you're reading 0 bytes.

Also in this case get rid of BytesAtPort and simply wire a "1" to have VISARead wait for 1 byte. No need for another wait function…

 


They provided initialization parameters and code to communicate.

Mind to attach that code? Most often things like termchars are recognizable…

Best regards,
GerdW


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

@GerdW wrote:

Hi,

 


@johntrich1971 wrote:

@GerdW wrote:

Hi pclab,

 

don't use BytesAtPort, it's wrong 99.9% of all time…


And in the off chance that the instrument does not have a termination character you should put some wait between your write and your bytes at port. Your bytes at port is likely getting 0, so you're reading 0 bytes.

Also in this case get rid of BytesAtPort and simply wire a "1" to have VISARead wait for 1 byte. No need for another wait function…

 



As usual you are correct GerdW (at least for the cases that we're given - if there are other cases where the ACK might be different then this would not work). It's been a while since I've worked without a termination character - and when I did I often had responses of varying length (though I could and would usually calculate the expected response).


 


They provided initialization parameters and code to communicate.

Mind to attach that code? Most often things like termchars are recognizable…


Also, if they provided code to communicate why are you trying to reinvent the wheel? Why not use the provided code?

0 Kudos
Message 5 of 5
(2,276 Views)