LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Problem connecting RS232 devices

Hello everyone,

-I am trying to control a Jasco pump PU-2080 via RS232 port.

-My laptop has no RS232 port, so I used a RS232/USB adaptor cable with COM retention (reference ICUSB2322F).I assume that the cable works since when I plug the pump to the cable, the VISA resource name controller displays a small icon next to the port (COM4). (see figure attached)

-I found in the labview help that when the driver of the device is not available it is possible to control it via I/O.

-I proceeded like that. I found the communication protocol from the pump and obtained the required values (Baud rate: 4800; Data bits: 8; Stop bits 2; Parity: None; Flow control: Xon/Xoff control; Termination character: (0x0d)) (find attached the communucation protocol of the pump).

-My purpose was to set or get any parameter from the pump (e.g. the flow rate), then I tried two alternatives:

1) I created a small vi in which I set these values and I try to get a response (see attachment). It did not work

2) I tried to set these values via NI MAX in the VISA test pannel and it also did not work.

 

-The error message was "BFFF0015 Timeout expired before operation completed". I found in this forum that one alternative could be increase the waiting time and try to read a very small amoun of bits, however it didn't work. However, I realized that the error was emerging before waiting the time I set.

 

-By clicking on "Read Status Byte" on the VISA test pannel I found a different error: "0xBFFF003A Unable to start operation because setup is invalid (due to attributes being set to an inconsistent state)." I am not sure what is not working here.

 

Could you please help me on this issue?

 

Many thanks

 

Daniel

 

 

 

 

0 Kudos
Message 1 of 26
(6,332 Views)

A couple of things that I see:

  • You might need a wait period in between the write and read commands to allow the instrument enough time to respond.
  • You have set the read byte count to 0.  Set it to something larger than what you expect so that your termination character doesn't get cut off.  This setting will cause the port to be read until N bytes are read or a termination character is encountered.  Make sure that the termination character is encountered first. 
  • Are you sure that the brackets are required in your send command?  I didn't read anything about the instrument to know this myself.
aputman
0 Kudos
Message 2 of 26
(6,321 Views)

Use MAX to "explore" your device.  Plug everything together, then start MAX.  Look for the Serial Port (COM4?), and open a Test Panel.  There you will be able to set the Baud Rate and other Serial Parameters (note that you may want to "experiment" as manuals are not always 100% accurate).

Your Device probably has a series of commands and responses.  Send a Command (I trust you can figure out how to do this) and read the response.  You should see something, and if it looks like gibberish, you have a Communication (Baud or Parity, usually) problem.

 

Once you figure out how to communicate with your device with MAX, "by hand", write LabVIEW code using VISA functions to do the same thing.

 

Let us know how it goes.

 

Bob Schor

0 Kudos
Message 3 of 26
(6,310 Views)

Thanks aputman for your answer.

 

-I tried the same vi with a waiting time up to 2 min (120000 ms) and the problem was the same. When I use the VI to do that, the error appears after waiting the pre defined time. When I increase the waiting time in the NI MAX interface, the error emerges just some seconds after running the test.

-You are right, the bit count is set to 0. When it is zero, I have no error. Then, I increase the bit count to 1 and the error emerges. After some tests I realized that by setting the bit count to 0, I can get "no error" even when the pump is not pluged to the cable.

-About the brackets, I am not sure. I am just following the communication protocol of the machine, however I have no experience on this. I will try without the brackets and I will let you know!

 

Many thanks!

 

Daniel

 

0 Kudos
Message 4 of 26
(6,252 Views)

Thanks Bob Schor,

 

I have already tryied to send commands by using the NI MAX interface, however I get the same error. As I could understand from your response, should I try different values of the baud rate etc.. values in the NI MAX interface? In that case, any suggestion of values to try?

 

I followed the communication protocol (attached in my first post) and it is, for example, as follows:

{1.000 flowrate set}

 

When I write this command in the NI MAX interface it is automatically changed to:

{1.000\sflowrate\sset}

(I don't know if this could be a source of error)

 

The problem is that when I use the NI MAX, I am not able to get any response to read. Could this mean that the machine is not connected to my computer?

Is there any way to check if there is a communication between the machine and the computer?

 

Many thanks!

 

Daniel

 

 

0 Kudos
Message 5 of 26
(6,248 Views)

Are you sure that the Enable Terminsation Character is activated in the VISA test Panel

If yes, you don't need to specify the "\n" at the end of your command

Paolo_P
Certified TestStand Architect
Certified LabVIEW Architect
National Instruments France

0 Kudos
Message 6 of 26
(6,231 Views)

I very rarely use RS232 so I am definitely no expert.  But I believe that if you have termination character enabled, you have to include the character in your command so that the VISA session knows that the command is complete.  If VISA doesn't see the character, it will just sit there until the timeout period has expired.  

 

Try right clicking your command string and changing it to '\' codes display and then add a '\r' (0xD) on the end of your command.  And then set your byte count to a large number (e.g. 100).  This may or may not be large enough to include all possible responses.  If it's not, you will likely get timeout errors.  The read command is going to read the buffer until it encounters a termination character or it has read 100 bytes.  

aputman
0 Kudos
Message 7 of 26
(6,220 Views)

Thanks Paolo_P for your answer,

In the communication protocol of the device says that each command is terminated with a CR (0x0d). For this reason, in the NI MAX settings I select Termination Character  Carriage Return -\r value D. I assume this is correct.

Regarding the "tick" of enable termination character, I have tried with and without it.

However, I am  not sure I am doing it correctly.

Do you have any suggestion?

Many thanks,

 

Daniel

 

0 Kudos
Message 8 of 26
(6,217 Views)

Dear aputman,

Thanks for this comment. I think that my problem should be mainly that. The JASCO communication protocol (attached in my first post) gives the following example.

Set the flow rate to 1.000 mL/min

value  command

{1.000 flowrate set}

and then it says "Note: Communucation command is terminated with CR (0x0d). Any LF (0x0a) code included in a seris of the commands are ignored. Data (value and command) is delimited by space (0x20)."

And then it gives the following example:

[1][.][0][0][0][0x20][f][l][o][r][r][a][t][e][0x20][s][e][t][0x0d]

 

However, I think that the command that I introduce in the NI MAX (1.000 flowrate set), is "translated" by the NI MAX to 1.000\sflowrate\sset.

I wonder if the space (\s) that NI MAX sets into my command is equivalent to [0x20], and I also wonder if I should include the [0x0d] at the end (which I assume is \r), or if by selecting any of the ticks and options of the configuration/ IO settings of the NI MAX is not necesary.

Do you know how can I send a proper command compatible with my particular communication protocol?

 

Thanks a lot!

0 Kudos
Message 9 of 26
(6,209 Views)

Did you try what I suggested?  

The example command shows the 0xD or '\r' in it.  '\s' is the code display for a space.  If you do what I suggested, you will see the same thing in the string constant.  

Untitled.png

 


@Daniel_CB wrote:

 

and then it says "Note: Communucation command is terminated with CR (0x0d). Any LF (0x0a) code included in a seris of the commands are ignored. Data (value and command) is delimited by space (0x20)."

And then it gives the following example:

[1][.][0][0][0][0x20][f][l][o][r][r][a][t][e][0x20][s][e][t][0x0d]

 


 

aputman
0 Kudos
Message 10 of 26
(6,200 Views)