Our full technical support staff does not monitor this forum. If you need assistance from a member of our staff, please submit your question from the Ask a Question page.


Log in or register to post/reply in the forum.

Configuring CR1000 as ModbusTCP Slave, with Holding Registers


LoggerMan Sep 12, 2010 12:45 AM

I have spent 10 hours unsuccessfully trying to get this integration to work. Please help!

System Overview:
- Eschelon i.Lon SmartServer Modbus Gateway - this device is successfully talking to an SMA solar inverter, and the i.Lon must act as the Modbus TCP Master to the CR100. It cannot be a slave.
- CR1000 with NL115, located on the same subnet as the i.Lon. The CR1000 needs to record the Modbus data from the i.Lon. The CR1000 is to be configured as the Modbus TCP Slave, with holding registers where the i.Lon will write data into the CR1000.

The i.Lon appears to be properly configured with the IP address of the CR1000 as its slave device. One of the Modbus registers it is supposed to write to is register 40005 (VoltsAB).

What I'm attempting to do is to define Modbus Holding Register 40006 (including an offset for 40005), which will serve as the target where the i.Lon can write the latest values to the CR1000.

Here is the code sample:

Public VoltsAB As Float
Public Inv1_1 As Boolean

BeginProg
ModBusSlave(502,-9600,6,VoltsAB,Inv1_1)
EndProg


In addition to setting up holding register 6, I've tried register 5 in case there is no offset, and registers 9 and 11 in case each data point takes up 2 registers.


I also tried for a while to open a socket, but I don't think that I need to do that if I'm a TCP slave. I've tried it both ways, and still nothing. Here's the code that is currently commented out:
'Public Socket1
'Socket1=TCPOpen ("IP Address of i.Lon Master",502,1000)


Thanks very much for any assistance.


IslandMan Sep 13, 2010 10:59 AM

I worked on a project like this once where the CR1000 was master and slave at the same time. I had to poll a series of ION Inverters on a solar project and the logger had to act as a gateway to multiple modbus servers polling it for all the data.
I'm a little confused as to the object of the project. It seems you want the SMA solar inverter data in the CR1000 but want to "push" it from the I.Lon to the CR1000?


LoggerMan Sep 13, 2010 02:11 PM

My CR1000 is also both master and slave. It is the master for a number of Moxa MGate ModbusTCP devices (used to measure DC current), and a slave to the i.Lon.

Ideally, the SMA inverter would have a Modbus gateway device that could be set up as a slave to the CR1000, and I would poll the inverter data exactly the same way I'm successfully polling the DC current data. But, SMA uses a proprietary data protocol that can only be accessed through the i.Lon SmartServer. (The SmartServer was configured and tested by SMA themselves.) And for some reason, the i.Lon can only act as a Modbus Master.

The net result is that instead of using the CR1000 as a master to poll the SMA inverter data, instead I need to use the CR1000 as a slave with holding registers that correspond to the target registers that the i.Lon is expecting to write to.


IslandMan Sep 13, 2010 02:39 PM

According to the Modbus Master help in CRBasic, command 16 allows you to write multiple registers into a ModBus slave. If you have two loggers, perhaps you can set one up as Master and the other as slave and get that working, then attempt to write to the logger with the i.Lon.
I'd give it a shot here but I'm tied up for the next day or two.


MattPerry Sep 13, 2010 03:00 PM

Does the iLon give some sort of result code indicating result of communication attempt. What do the iLon's comm logs look like, do you see any indication that the iLon is seeing the CR1000?

ModBusSlave(502,-9600,6,VoltsAB,Inv1_1)
This line sets up the datalogger for Modbus TCP/IP with a Modbus address of 6, starting register of 40001 or 30001.

Is the iLon looking for Modbus address 6 at the IP address you configured the CR1000 to be? How did you set the IP address of the datalogger?

The parameter, ModBusAddr in the ModbuSlave instruction, currently set to 6, can be used to specify an offset for the starting register. "Enter Starting Register * 1000 + the address. (i.e., the most significant digits specify the offset and the last three digits specify the ModBus address). For instance, for a starting register of 1500 and an address of 3, enter 1500003."


LoggerMan Sep 13, 2010 03:44 PM

I'm investigating whether or not I can access the i.Lon's logs.

More importantly, you've highlighted my incorrect use of the ModBusAddr parameter.

The i.Lon is looking for Modbus device #1 (although that doesn't matter for TCP, does it?), and starting register 40006. What is the value of the parameter that I should use? 40006001?


MattPerry Sep 13, 2010 03:50 PM

The Modbus device # (slave ID) is important for TCP/IP. You could have multiple slave id's per IP address.

For a starting register of 40006 and slave ID 1, set the ModBusAddr equal to 6001.


LoggerMan Sep 13, 2010 05:47 PM

OK, now we're getting somewhere! Matt, you're the man!

It turns out that my first register is actually 40004, so this syntax works perfectly:

ModBusSlave(502,-9600,4001,Inv1Data(1),Inv1_1)

The reason I've replaced "VoltsAB" with an array is because there are actually 21 registers, beginning at 40004, that I'm reading. I defined the array "Public Inv1Data(21) As Float" and the above code returns the first 21 registers, beginning with 40004.

The last hurdle is that there is actually a second inverter connected to the same i.Lon. The second inverter has the same data points, except they start at 40104 instead of 40004.

So we added another line of code, as follows:

ModBusSlave(502,-9600,4001,Inv1Data(1),Inv1_1)
ModBusSlave(502,-9600,104001,Inv2Data(1),Inv2_1)


When we run the new code, the data for Inverter#2 (beginning at 40104) works perfectly, but all of the data for Inverter#1 stops reporting. In effect, it looks like the second ModBusSlave command trumps the first one.

I suppose I could work around the issue by reading in 71 continuous registers instead of two sets of 21 registers, but I would rather not read all of those extraneous data points.

Any suggestions?

Log in or register to post/reply in the forum.