Sign in to follow this  
HPELUKAT

MODBUS RTU problems!?

Recommended Posts

Hi,

I'm trying to connect to a device (Circutor power analyzer) that uses the Modbus RTU protocol through a serial port (I'm using a RS232 to USB converter). The data I'm reading is of Unsigned Long Reverse Words type - in modbus scanner, where it always works without a problem!!!

First of all I have a sequence that seemed to work before i formatted the PC in question. The sequence is:

delay(3)
while (1) 
   delay(3)
   Var.test = Device.ModbusRTU.ReadHoldingRegistersUWSLI(1,60,1)
   var.test2 = Device.ModbusRTU.ReadHoldingRegistersUWSLI(1,30,1)
   V.DnevnaMoc = var.test[0] / 1000
   V.trenmoc = var.test2[0] / 1000
   delay(3)
endwhile

the problem is that it does not work anymore.. It seemed to work fine before.

The only way it starts to work with the sequence above, is when I start another instance of DAQFactory(I still have the trial version installed so I can modify the settings without the hardware key).

I made a new *.ctl file containing only two channels reading from ModbusRTU device. The data type is of course invalid (Read Holding Registers Unsigned 32-bit), but the data is read without a problem. When this file was open and both channels active, I opened the original file with the sequence above (immediatelly an error occured in the newly open file - the port is in use by another app...). So I closed the test *.ctl file, started the sequence and VOILA it magically started to work....

and now every time I want to start the readout from the device I have to do the procedure described above.

Please help!

Thanks

Share this post


Link to post
Share on other sites

The ModbusRTU device is from release 5.40 and is not used anymore (unless you happen to create a device called ModbusRTU using the new techniques). In the new DAQFactory, and this is how QuickMod works, you create your own device, which combines a port and a protocol. This allows you to run multiple protocols on a port, and to run any protocol on any port.

Please switch to the new method and ignore the ModbusRTU that appears in the device configuration. This must be left over from an old installation.

Share this post


Link to post
Share on other sites

OK, then how do I create this modbus device?

I mean do I start by adding a new device, configure the port and name the device? But then I still need to select the modbus RTU protocol and then I need the correct *.dll-s in order for the modbus protocol to work (I have them from the older version)..

What do you think would be the best way to do this? Is the code shown above any good or should I improve it somehow? Please help!

Thank you for your time and anwser!

Share this post


Link to post
Share on other sites

1) Go to Quick - Device Configuration, then select New Serial / Ethernet Device

2) Create a new serial port and configure it, select it, then select ModbusRTU (the DLL is installed with any 5.7+ release). Give the device a name (other than ModbusRTU) and click ok.

3) Now you can create channels with this new device. You can also create script, but looking at your script, I don't know why you wouldn't just create channels.

Also, in the latest release, there is the new QuickMod Pro which will get you started with Modbus quickly, and may, depending on the extent of your application, be all that you need. There is a nice manual that shows how to expand it too.

Share this post


Link to post
Share on other sites

Thank you and sorry for the bother! After I posted the previous post I tried it the same way you now described and it started to work! We didn't know that you can do it this way...thank you very much!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this