12-13-2019 06:21 AM
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
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.
12-13-2019 06:59 AM
12-13-2019 07:13 AM - edited 12-13-2019 07:13 AM
@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.
12-13-2019 07:14 AM - edited 12-13-2019 07:15 AM
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…
12-13-2019 07:24 AM - edited 12-13-2019 07:24 AM
@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?