NI Labs Discussions

cancel
Showing results for 
Search instead for 
Did you mean: 

NI LabVIEW Modbus API Discussion

The AcquiSuite Data Server collects all the data from the sensors via ModbusRTU, it takes some time for this to happen (the return trip costs about 150 ms per device, and there's 20 of them).

My issue was that I was sampling every 5 seconds, but I was looping through the devices and reading them without any delay between them. After every read from the gateway I'm waiting about 300 millseconds before the next read, and now it's in stable condition.

0 Kudos
Message 351 of 501
(476 Views)

This is about serial 'Break Length'

I succesfully used the Modbus TCP API to read and write values over the network to/from a eurotherm EPack controller.

However, when I try to use the Modbus Serial RTU API to write the setpoint to a Eurotherm 2416 PID controller, I get the 56 error (timeout) and the value is not written.

Eurotherm also provides a LabVIEW library for this 24xx series controller, and it works well.

Looking for differences with the NI Modbus API, I noticed that the the eurotherm library sets the Break Length (property node) to 20 when initializing the serial port.

Is this important, should I set this property also when using the NI Modbus API?

0 Kudos
Message 352 of 501
(476 Views)

Unless I'm mistaken, their use of that property does nothing. That is only used if you manually send a break signal with a length of -1 (use default) or if you configure the ASRL end out mode to send a break after every write.

If the setpt isn't written, it sounds like the command never gets to the controller. In your screenshot you're only doing an ID check. Have you tried just running that exact same command using the modbus library? Also, please be sure to verify that you're using 'read multiple' holding registers. It looks like the eurotherm doesn't support individual reads just based on that screenshot. Probably the same thing with writes.

0 Kudos
Message 353 of 501
(475 Views)

smithd wrote:

Unless I'm mistaken, their use of that property does nothing. That is only used if you manually send a break signal with a length of -1 (use default) or if you configure the ASRL end out mode to send a break after every write.

If the setpt isn't written, it sounds like the command never gets to the controller. In your screenshot you're only doing an ID check. Have you tried just running that exact same command using the modbus library? Also, please be sure to verify that you're using 'read multiple' holding registers. It looks like the eurotherm doesn't support individual reads just based on that screenshot. Probably the same thing with writes.

Thanks for your response!

I am not that familiar with low level Modbus communication, that's why I asked for the importance of the Break Length.

So it seems not necessary to set it if you just want to write values to some registers.

About the setpoint: I am pretty sure it was not written to the instrument (I can check the instruments display and/or the eurotherm configuration software). At this moment I cannot check it (again) because it is in use.

The screenshot was only meant to show you the initialization part where the Break Length is set.

I did not do an ID check, I just wrote a single float value to several registers (using word munipulation). Indeed, the eurotherm does some special addressing to allow for higher precision writing and reading (two words can be converted to a single float and vica versa).

Please find the attached screenshots where details of the eurotherm write vi is shown and one of a small vi I made that uses the NI Modbus library.

It is similar to the vi I made for another type of eurotherm instrument, using NI Modbus TCP, and that one works!

Am I missing something here? Could you please comment?

PS: As mentioned before, I can succesfully write/read to/from the instrument using the eurotherm library. So hardware wiring/cabling and serial port settings are ok.

It's just that I also would like to be able to use the NI Modbus library.

Message was edited by: donkdonk

Greetings from the Netherlands

0 Kudos
Message 354 of 501
(475 Views)

Oh, I see, it looks like the serial settings are wrong.

In your first picture, its set to parity=none, stop bits=1

This conflicts with the modbus spec and is not allowed by the modbus library (pg 12/44   http://www.modbus.org/docs/Modbus_over_serial_line_V1.pdf)

"Even parity is required, other modes ( odd parity, no parity ) may also be used. In order to ensure a maximum compatibility with other products, it is recommended to support also No parity mode. The default parity mode must be even parity. Remark : the use of no parity requires 2 stop bits."

Its easy enough to bypass this, however. Basically you just use a visa property node to set the stop bits after you call the init function. So the sequence is: <New Serial Master> then a property node for "COM1", then the register write.

Not sure if this is the entire issue, but its at least part of it.

Message 355 of 501
(475 Views)

Thanks a lot for the clarification!

It made me double check the initilization parameters and you know what?? The parity in the vi I used to test the equipement was set to 'even', where eurotherm requires this to be 'none'.

Really stupid as I was pretty convinced I checked this over several times (I work quite a lot with serial equipment, so I know the importance).

I just changed it to 'none' and now it works!!

(see attachment).

Makes me wonder why the non-supported parity='none' does work?

Any suggestions?

Message was edited by: donkdonk

0 Kudos
Message 356 of 501
(475 Views)

Its not that none isn't supported by modbus, what I thought was going on is that modbus defines a number of stop bits as part of the protocol. If parity is enabled, 1 stop bit, if parity is none, 2 stop bits. It looked like your example from eurotherm had none parity but only 1 stop bit, which I thought might be the problem.  It may be that the eurotherm just happens to be flexible enough to ignore the extra stop bit...the wiki says:

  • The number of stop bits sent must be chosen (the number sent must be at least what the receiver needs)

So that must be it, the library is sending more stop bits than eurotherm needs.

If it were the problem, you would simply re-adjust the visa settings after the library changed them. Anyway, sounds like it works now so good luck.

Message 357 of 501
(475 Views)

Thanks again for your reply.

It still really makes me feel stupid as if someone tells me I forgot to plug in the power cord .

To my defense I can only say that at the time the equipement was not available for testing.

But I am happy it is solved now.

But for me it was a useful conversation, otherwise I would have kept wondering what the Break Length is needed for.

Another topic: my first impression is that NI modbus it is way faster than the eurotherm library.

But I'll have to do some more thorough testing first before jumping to conclusions  .

Message 358 of 501
(476 Views)

Hi Daniel

Thanks again for this excellent library. It has been a while since I used it and I can see that I am a few releases behind now.

I am about to create a development GUI externalising data from a low power embedded device. This uses a custom Modbus implementation - the transmission protocol is RTU, but the checksum is the LRC (from the ASCII protocol). I can see that you these are wrapped in their respective transmission units. Would it be possible to generate this functionality using your library? I'm guessing I'd need to create a new type of transmission unit.

Thanks

Ray

0 Kudos
Message 359 of 501
(476 Views)

I also want to give my thanks for developing this useful library. I'm developing an application now where I'm using it to talk to two SureServo drives from Automation Direct with Modbus ASCII, and in the case of writing one particular parameter in the drive, the Modbus Master.lvclass:Write Single Holding Register.vi is returning error 538189 with the source showing as "<APPEND>Function 6" (which is the "write one register" function). Delving into that vi, it looks like the source is the Master Function Definition.lvclass:Write Single Register Response.vi, which returns the error along with zeroes for "Address" and "Number of coils". I'm taking this to mean that the drive's response to the register write is incorrect, but can you tell anything more from the error code 538189? I'm writing other parameters using the same function without problems. I'm going to try using some other software to write that register and see if I have any better luck.

Thank you,

Aaron T.

0 Kudos
Message 360 of 501
(476 Views)