Unable to connect using Modbus in Java

Post Reply
jkerr336
Forum Member
Posts: 9
Joined: Tue Nov 20, 2012 12:51 pm
My RE system: Astronergy 290 watt panels, Outback FlexMax 80 Charge Controller, Magnum MS4448PAE Power Center, AIR X 48V 400 watts Wind Turbine, Surrette S-530 Batteries, AXS Port, MagWeb - Ethernet Web Monitoring Kit (ME-MW-E)
Location: Laramie, WY

Unable to connect using Modbus in Java

Post by jkerr336 » Thu Nov 29, 2012 4:23 pm

I am writing a JAVA Modbus Master application to communicate with the AXS. My application tests well against a slave simulator, but I am unable to connect to the AXS. I get a general connection failure when I use TCPMasterConnection to connect, this happens before I try to grab any registers. The device seems to be either mute or deaf.

In response to TallGirl in the other thread, I am using TCPMasterConnection as part of the j2mod library. Is there another class you'd recommend?

User avatar
tallgirl
Forum Emperor
Posts: 4334
Joined: Wed Sep 26, 2007 9:59 am
My RE system: 16 Kyocera KC175GT (2,800 watts DC), MX-60, 2 OutBack GVFX3648, 8 GC2 batteries (6v @ 215AH),
Location: Austin, TX

Re: Unable to connect using Modbus in Java

Post by tallgirl » Fri Nov 30, 2012 6:09 am

Nope, the TCPMasterConnection class should be the correct one.

There are some "unit test" classes in the com.ghgande.j2mod.modbus.cmd class that can be used to test the Modbus slave (AXS Port). You should be able to browse the source on SourceForge if you're looking for source code examples.

And sorry -- I don't have an AXS Port. I've been meaning to buy one, but I've also been meaning to do a lot of things :sad:
Julie in Texas

I ride bicycles. A lot.

jkerr336
Forum Member
Posts: 9
Joined: Tue Nov 20, 2012 12:51 pm
My RE system: Astronergy 290 watt panels, Outback FlexMax 80 Charge Controller, Magnum MS4448PAE Power Center, AIR X 48V 400 watts Wind Turbine, Surrette S-530 Batteries, AXS Port, MagWeb - Ethernet Web Monitoring Kit (ME-MW-E)
Location: Laramie, WY

Re: Unable to connect using Modbus in Java

Post by jkerr336 » Sat Dec 01, 2012 10:33 pm

I found the issue. I thought that one of the new IP addresses on my router's DHCP client list was the AXS. I didn't read the small print on the actual device (not in the documentation) which said that the factory default IP setting was 192.168.0.64. After reconfiguring my router to use that subnet, I was able to connect to the device with TCPMasterConnection.

If any Outback people read this, it would be REALLY nice if instead of assigning an arbitrary IP address to the device (which may or may not match a previously configured network), turn on DHCP by default. Since your device is DHCP capable, it seems like the smarter default configuration. Also, this configuration should be in the documentation instead of only on the device.

jkerr336
Forum Member
Posts: 9
Joined: Tue Nov 20, 2012 12:51 pm
My RE system: Astronergy 290 watt panels, Outback FlexMax 80 Charge Controller, Magnum MS4448PAE Power Center, AIR X 48V 400 watts Wind Turbine, Surrette S-530 Batteries, AXS Port, MagWeb - Ethernet Web Monitoring Kit (ME-MW-E)
Location: Laramie, WY

Re: Unable to connect using Modbus in Java

Post by jkerr336 » Sun Dec 02, 2012 2:22 am

Although I have connected, I am trying to read the registers. When I use "ReadInputRegistersRequest" with a ref of 40069 and a count of 1, I get "com.ghgande.j2mod.modbus.ModbusSlaveException: Illegal Data Address" when I perform the execute() method in the "ModbusTCPTransaction" class. Does the "ReadInputRegistersRequest" class use an alternate scheme for referencing register offset? Thanks.

User avatar
fatheadl
Forum Whiz
Posts: 40
Joined: Wed Dec 13, 2006 7:16 am
My RE system: 8 KC130TM, FM60, RTS, Samlex S1500-124, AXS Port, FN-DC, 8 NSB170FT Blue AGM
Location: Knigston, Jamaica

Re: Unable to connect using Modbus in Java

Post by fatheadl » Sun Dec 02, 2012 1:57 pm

The default settings is on page 17 of the manual. I agree that dhcp should be the default.
8 KC130TM, FM60, RTS, Samlex S1500-124, Mate3, FN-DC, 8 NSB170FT Blue AGM

jkerr336
Forum Member
Posts: 9
Joined: Tue Nov 20, 2012 12:51 pm
My RE system: Astronergy 290 watt panels, Outback FlexMax 80 Charge Controller, Magnum MS4448PAE Power Center, AIR X 48V 400 watts Wind Turbine, Surrette S-530 Batteries, AXS Port, MagWeb - Ethernet Web Monitoring Kit (ME-MW-E)
Location: Laramie, WY

Re: Unable to connect using Modbus in Java

Post by jkerr336 » Mon Dec 03, 2012 11:12 am

Excellent, I see it now. Another good place to put this information would be in the installation section.

jkerr336
Forum Member
Posts: 9
Joined: Tue Nov 20, 2012 12:51 pm
My RE system: Astronergy 290 watt panels, Outback FlexMax 80 Charge Controller, Magnum MS4448PAE Power Center, AIR X 48V 400 watts Wind Turbine, Surrette S-530 Batteries, AXS Port, MagWeb - Ethernet Web Monitoring Kit (ME-MW-E)
Location: Laramie, WY

Re: Unable to connect using Modbus in Java

Post by jkerr336 » Wed Dec 05, 2012 9:38 am

It ended up that the "ReadInputRegistersRequest" (Function Code 4) wouldn't work to request the register data. I switched to the "ReadMultipleRegistersRequest" (Function Code 3) method and things are working perfectly. It was probably a rookie mistake by an amateur, but I figure I'd pass along the information for the next rookie.

User avatar
fatheadl
Forum Whiz
Posts: 40
Joined: Wed Dec 13, 2006 7:16 am
My RE system: 8 KC130TM, FM60, RTS, Samlex S1500-124, AXS Port, FN-DC, 8 NSB170FT Blue AGM
Location: Knigston, Jamaica

Re: Unable to connect using Modbus in Java

Post by fatheadl » Wed Dec 05, 2012 12:59 pm

Have you upgraded to the latest firmware?
8 KC130TM, FM60, RTS, Samlex S1500-124, Mate3, FN-DC, 8 NSB170FT Blue AGM

jkerr336
Forum Member
Posts: 9
Joined: Tue Nov 20, 2012 12:51 pm
My RE system: Astronergy 290 watt panels, Outback FlexMax 80 Charge Controller, Magnum MS4448PAE Power Center, AIR X 48V 400 watts Wind Turbine, Surrette S-530 Batteries, AXS Port, MagWeb - Ethernet Web Monitoring Kit (ME-MW-E)
Location: Laramie, WY

Re: Unable to connect using Modbus in Java

Post by jkerr336 » Wed Dec 12, 2012 3:41 pm

I will update the firmware and see if that makes a difference; however, the "ReadMultipleRegistersRequest" class is working very well. Using the j2mod library, I have been able to communicate with the AXS (thanks to whoever wrote that.. I'm looking your way tallgirl) . I have integrated the real-time data into my website and am adding storage for historical data and forms for writing parameters. Thanks for all of the help with my beginner questions.

For anyone interested, I am happy to share my java classes for communicating with the AXS.

User avatar
tallgirl
Forum Emperor
Posts: 4334
Joined: Wed Sep 26, 2007 9:59 am
My RE system: 16 Kyocera KC175GT (2,800 watts DC), MX-60, 2 OutBack GVFX3648, 8 GC2 batteries (6v @ 215AH),
Location: Austin, TX

Re: Unable to connect using Modbus in Java

Post by tallgirl » Tue Mar 12, 2013 9:44 pm

It's not uncommon for Modbus device firmware writers to only implement one of "READ INPUT" versus "READ HOLDING" functions. They are technically two different addresses spaces -- 64K "input" registers and 64K "holding" registers -- and they work differently.

I may take you up on the AXS port classes one of these days. I'm working on adding SunSpec =server= support to greenMonitor so I can present all the kit attached to a greenMonitor install as a SunSpec client. I have SunSpec =client= support for inverter model devices in 3.01, though I'm not sure it will ship with the initial release.
Julie in Texas

I ride bicycles. A lot.

Post Reply