Author Topic: Ethernet Modbus port for KID  (Read 1304 times)

dgd

  • Hero Member
  • *****
  • Posts: 1673
    • Lorylink
Ethernet Modbus port for KID
« on: November 11, 2015, 02:47:39 PM »
Have started new thread for this little project,  as its separate from the simple webserver for the KID.

The webserver extracts serial port data from KID and using AJAX serves it to a a connecting web client using various html5
pages for display. This happens in almost real time with refreshing just under a second for  web displayed data.

KAP - Kid Access Port  8)
This KAP project gets serial data every fraction of a second from the KID and stores it in series of memory locations that will be mapped to modbus register addresses so that an ethernet connecting modbus master can see this as a slave device and retreive the requested register values.

It appears that almost everything necessary for this, especially all the modbus protocol/timing management, already exists in the SimpleModbusSlave library for the Arduino.
The storing of serial data into a memory array and then mapping modbus register addresses to array index entries also looks fairly striaghforward although it may be necessary to link an address parser routine to the modbus lib to ensure a valid register address or range is specified.
This IMO would be preferable to lengthy (relative) delays while the slave times out due to invalid register requests.

I'm thinking of using identical register addresses as the Classic (eg 4114 for battery voltage etc..) although the extent of this will be limited by the serial data types that the KID provides.

The arduino processor will also store, eeprom, static info about the KID, such as version, serial number although these would probably need to be done in the c++ sketch code and map these into the relevant modbus registers 4101+
Including an RTC with the arduino is also straighforward. so date and time stamping of data is possible.
Because of limited memory I have not yet considered any type of log file but the possibility is there.

Anyone any design contributions, ideas, thoughts or comments on this?

dgd
« Last Edit: November 11, 2015, 03:36:20 PM by dgd »
Classic 250, 150,  20 140w, 6 250w PVs, 2Kw turbine, MN ac Clipper, Epanel/MNdc, Trace SW3024E (1997), Century 1050Ah 24V FLA (1999). Arduino power monitoring and web server.  Off grid since 4/2000
West Auckland, New Zealand

dgd

  • Hero Member
  • *****
  • Posts: 1673
    • Lorylink
Re: Ethernet Modbus port for KID
« Reply #1 on: November 11, 2015, 05:00:34 PM »
This is the hardware I want to use in this project, all nice and tiny to fit underneath the KID in the support bracket void.
The only external connector is the ethernet port, a short rj11 cable goes to the Kid's serial port.
The max232 tiny pcb is soldered to end of cable. The arduino is a small footprint version of the Nano without the integral USB port. Instead it has ttl serial port connections and for programming uses an external usb to ttl board. When connected to the Kid this is replaced by the max232 (rs232 to ttl) serial converter.
Shown in centre without interface pins installed yet.
The RTC and eeprom card is shown, flat battery receptacle underneath, also has connector pins installed
Also a tiny 12v fan is shown and an MN hole cover to give idea of size of everything.

Not shown is the Wiznet 550io tiny ethernet board as the one  I have is in use so waiting on more to arrive
Here is info on interfacing it to Nano
http://www.instructables.com/id/Arduino-Nano-with-WIZ550io-Easy-Internet/

Hardware all up cost about USD25
The plan is to power all of this from the KID but I need to investigate if any 5v power is avaiable from a TP or whatever otherwise its a small its a small power unit connecting to battery terminals.

dgd
Classic 250, 150,  20 140w, 6 250w PVs, 2Kw turbine, MN ac Clipper, Epanel/MNdc, Trace SW3024E (1997), Century 1050Ah 24V FLA (1999). Arduino power monitoring and web server.  Off grid since 4/2000
West Auckland, New Zealand

Westbranch

  • Hero Member
  • *****
  • Posts: 2409
  • Building System (sort of) 1 weekend at a time
Re: Ethernet Modbus port for KID
« Reply #2 on: November 11, 2015, 05:14:06 PM »
DGD said:
Not shown is the Wiznet 550io tiny ethernet board as the one  I have is in use so waiting on more to arrive

sure looks like the unit here   http://www.shopwiznet.com/wiz550io

The plan is to power all of this from the KID but I need to investigate if any 5v power is available from a TP or whatever otherwise its a small its a small power unit connecting to battery terminals.

Wouldn't the load circuit power supply give you 12 V that you could step down from?
CL647 asleep
KID 51(B) FW1811 560W C&D 24V 900Ah AGM
CL 29032 FW V.2126-NW2097-GP2133 175A E-Panel WBjr, 3Px4s 140W > 24V 900Ah AGM,
2 x Cisco WRT54GLi/c DD-WRT Rtr &Brg, NetGr DS104Hub, 
Hughes 1100 Modem
Cotek ST1500 Inv OmniCharge 3024  Eu1/2/3000i Gens
West Chilcotin BC 1680W to come

Graham

  • Full Member
  • ***
  • Posts: 191
    • SkyeTracker
Re: Ethernet Modbus port for KID
« Reply #3 on: November 11, 2015, 05:24:44 PM »
I'm doing the same using a raspberry pi using the https://github.com/stephane/libmodbus c++ library.
I initialized the modbus data to match a classic so I could access it using the local or my android app.
Still very much a work in progress since I'm simulating a kid on a pc. I wasn't able to make sense of the sample kid data found on another post in this forum.
Let me know if I can help with the code...


Graham.
Off-Grid Island cottage, Lac Simon QC
370 Ahrs @ 24V (4 8L16 batteries)
4 x 250watt panels on dual axis trackers http://tinyurl.com/hfpkgr5
Classic 150, Whizbang Jr.
Android Monitor: http://tinyurl.com/lomzq3s

dgd

  • Hero Member
  • *****
  • Posts: 1673
    • Lorylink
Re: Ethernet Modbus port for KID
« Reply #4 on: November 11, 2015, 05:58:44 PM »
Graham,

I wrote a Classic modbus simulator for an UNO to connect to my DUE web server system so basically all I had to do was sort out some modbus register map addressing and get that serial port interface to the KID working.
The Arduino SimpleModbus libs had it all, at least all I needed
It sure would be nice to have some clearer documentation about getting data from the KID as it was interesting trying to understand Mario's explanation {ok going out on a limb here but I got the distinct impression English is not Mario's first language  :) }
Maybe someone else at MN could assist with a nicely documented description ?

Also looks like the MN localApp will talk but its doubtful the MyMN system would be interested as I remembered it has
some dubious encryption in its comms.
Anyway good to see your progress, I will get back to you later about C code

dgd
« Last Edit: November 11, 2015, 06:07:31 PM by dgd »
Classic 250, 150,  20 140w, 6 250w PVs, 2Kw turbine, MN ac Clipper, Epanel/MNdc, Trace SW3024E (1997), Century 1050Ah 24V FLA (1999). Arduino power monitoring and web server.  Off grid since 4/2000
West Auckland, New Zealand

dgd

  • Hero Member
  • *****
  • Posts: 1673
    • Lorylink
Re: Ethernet Modbus port for KID
« Reply #5 on: November 11, 2015, 06:05:04 PM »
Wouldn't the load circuit power supply give you 12 V that you could step down from?

Yes, it probably would but being a lazy type I want to find a 5v supply from the KID as its already generating this for its ttl logic devices (I don't think its 3.3v).
I sort of have this plan, maybe unrealistic, to have this little cpu and bits closely integrated into the KID mounting rather than an external box.

dgd
Classic 250, 150,  20 140w, 6 250w PVs, 2Kw turbine, MN ac Clipper, Epanel/MNdc, Trace SW3024E (1997), Century 1050Ah 24V FLA (1999). Arduino power monitoring and web server.  Off grid since 4/2000
West Auckland, New Zealand

dgd

  • Hero Member
  • *****
  • Posts: 1673
    • Lorylink
Re: Ethernet Modbus port for KID
« Reply #6 on: November 11, 2015, 08:48:58 PM »
Just been thinking about this concept and widening its application (with the assistance of some single malt nectar).
The idea of an access port for the KID could easily be widened  to be an ethernet modbus port for the Classic and especially the Classic SL.
With the ongoing strife concerning the Classic ethernet port reliabiity AND its broken (IMHO) stack that permits only one tcp connection at any time PLUS the horrors (again IMHO) of an encrypted data link from the Classic owners LAN to some anonymous remote server , I'm coming to the conclusion that a Classic access port that would allow multiple tcp connections to a modbus stack in the access port device is the way to go.

This would allow the Classics ethernet port to be abandoned and serial data from Classic to port device where a suitable modbus stack is maintained.

Perhaps the main issue here might be the maximum serial port throughput although some tuning of serial ring buffer sizes can significantly improve throughput timing.
Maybe the Classic's usb port could be useful here for higher throughput although I'm not sure if its version 1 or 2  as its unlikely to be version 3. Even vers 1 with 12Mbit throughput would be nice if the Classic's cpu could handle it.

Now this would be the more worthwhile project IMO and the Cubie would fit quite nicely.  :o

dgd
Classic 250, 150,  20 140w, 6 250w PVs, 2Kw turbine, MN ac Clipper, Epanel/MNdc, Trace SW3024E (1997), Century 1050Ah 24V FLA (1999). Arduino power monitoring and web server.  Off grid since 4/2000
West Auckland, New Zealand

Graham

  • Full Member
  • ***
  • Posts: 191
    • SkyeTracker
Re: Ethernet Modbus port for KID
« Reply #7 on: November 12, 2015, 01:29:55 PM »
This is the hardware I want to use in this project, all nice and tiny to fit underneath the KID in the support bracket void.
The only external connector is the ethernet port, a short rj11 cable goes to the Kid's serial port.
The max232 tiny pcb is soldered to end of cable. The arduino is a small footprint version of the Nano without the integral USB port. Instead it has ttl serial port connections and for programming uses an external usb to ttl board. When connected to the Kid this is replaced by the max232 (rs232 to ttl) serial converter.
Shown in centre without interface pins installed yet.
The RTC and eeprom card is shown, flat battery receptacle underneath, also has connector pins installed
Also a tiny 12v fan is shown and an MN hole cover to give idea of size of everything.

Not shown is the Wiznet 550io tiny ethernet board as the one  I have is in use so waiting on more to arrive
Here is info on interfacing it to Nano
http://www.instructables.com/id/Arduino-Nano-with-WIZ550io-Easy-Internet/

Hardware all up cost about USD25
The plan is to power all of this from the KID but I need to investigate if any 5v power is avaiable from a TP or whatever otherwise its a small its a small power unit connecting to battery terminals.

dgd

Another interesting hardware option is the NodeMCU http://nodemcu.com/index_en.html#fr_54747661d775ef1a3600009e.
It's based on the esp8266 so it has built in wifi that can be both a station and an endpoint.
If the kid is in a motor home or boat, you wouldn't need a router, just wifi connect directly
It's only $2 http://www.ebay.ca/itm/171907430053?_trksid=p2060353.m2749.l2649&ssPageName=STRK%3AMEBIDX%3AIT
or $12 for the dev kit http://www.seeedstudio.com/depot/NodeMCU-v2-Lua-based-ESP8266-development-kit-p-2415.html
all you need to add is a 3v regulator and an rs232 interface.


Graham.
Off-Grid Island cottage, Lac Simon QC
370 Ahrs @ 24V (4 8L16 batteries)
4 x 250watt panels on dual axis trackers http://tinyurl.com/hfpkgr5
Classic 150, Whizbang Jr.
Android Monitor: http://tinyurl.com/lomzq3s

dgd

  • Hero Member
  • *****
  • Posts: 1673
    • Lorylink
Re: Ethernet Modbus port for KID
« Reply #8 on: November 12, 2015, 06:29:15 PM »
I see the ESP8266 is now supported in a recent release of the Arduino IDE. I have ordered a few of them to play with.
Low cost serial to Wifi would fit nicely into the sort of adaptor port I'm thinking of.

The DUE web server I use with my two Classics (and soon MX60/) uses a Dragino WIFI shield to connect to my WIFI Lan.
A second DUE server dealing with a MS MPPT30 and KID also has a WIFI shield, this time a CC3300, still doing some development with this one but as its a very low cost chinese shield its worth the effort.

dgd
Classic 250, 150,  20 140w, 6 250w PVs, 2Kw turbine, MN ac Clipper, Epanel/MNdc, Trace SW3024E (1997), Century 1050Ah 24V FLA (1999). Arduino power monitoring and web server.  Off grid since 4/2000
West Auckland, New Zealand

Graham

  • Full Member
  • ***
  • Posts: 191
    • SkyeTracker
Re: Ethernet Modbus port for KID
« Reply #9 on: February 28, 2016, 11:01:00 AM »
I see the ESP8266 is now supported in a recent release of the Arduino IDE. I have ordered a few of them to play with.
Low cost serial to Wifi would fit nicely into the sort of adaptor port I'm thinking of.

The DUE web server I use with my two Classics (and soon MX60/) uses a Dragino WIFI shield to connect to my WIFI Lan.
A second DUE server dealing with a MS MPPT30 and KID also has a WIFI shield, this time a CC3300, still doing some development with this one but as its a very low cost chinese shield its worth the effort.

dgd

I've been playing with the ESP12e for a few weekends, I have a couple of projects on my github page.
The ModbusAdapter project uses a esp12e along with a rs232/ttl adapter to convert a modbus RTU slave to a Modbus TCP slave over wifi. I tested it using the classics serial port and was able to connect using the local app over tcp/wifi.
It currently implements Holding Register read (0x03).
The implementation in TCPSlave.h/cpp could be replaced with the code that communicates with the kid over serial to add modbus TCP/Wifi access to the kid.


https://github.com/graham22/ModbusAdapter

other NodeMCU/ESP8266 project that uses webSockets to broadcast wind speed to a web page:
https://github.com/graham22/Anemometer


Graham.
Off-Grid Island cottage, Lac Simon QC
370 Ahrs @ 24V (4 8L16 batteries)
4 x 250watt panels on dual axis trackers http://tinyurl.com/hfpkgr5
Classic 150, Whizbang Jr.
Android Monitor: http://tinyurl.com/lomzq3s

dgd

  • Hero Member
  • *****
  • Posts: 1673
    • Lorylink
Re: Ethernet Modbus port for KID
« Reply #10 on: February 28, 2016, 02:44:40 PM »
Thanks for the info Graham.
I dont see any issues with the KID adaptor, its just a matter of waiting on the next FW release to get some more useful data from the KID serial port. I have tested using the modbusSlave lib and making data available is not too difficult. Eventually I can see the KID talking to the local app and with some little effort to MyMN.

dgd
Classic 250, 150,  20 140w, 6 250w PVs, 2Kw turbine, MN ac Clipper, Epanel/MNdc, Trace SW3024E (1997), Century 1050Ah 24V FLA (1999). Arduino power monitoring and web server.  Off grid since 4/2000
West Auckland, New Zealand

jeremy450

  • Newby
  • *
  • Posts: 1
Re: Ethernet Modbus port for KID
« Reply #11 on: May 03, 2017, 01:03:50 PM »
hi dgd

just wondering how you been going with the Ethernet Modbus port for KID for the arduino.

regards
Jeremy

ClassicCrazy

  • Hero Member
  • *****
  • Posts: 1201
Re: Ethernet Modbus port for KID
« Reply #12 on: May 03, 2017, 03:17:18 PM »
I see the ESP8266 is now supported in a recent release of the Arduino IDE. I have ordered a few of them to play with.
Low cost serial to Wifi would fit nicely into the sort of adaptor port I'm thinking of.

The DUE web server I use with my two Classics (and soon MX60/) uses a Dragino WIFI shield to connect to my WIFI Lan.
A second DUE server dealing with a MS MPPT30 and KID also has a WIFI shield, this time a CC3300, still doing some development with this one but as its a very low cost chinese shield its worth the effort.

dgd

I've been playing with the ESP12e for a few weekends, I have a couple of projects on my github page.
The ModbusAdapter project uses a esp12e along with a rs232/ttl adapter to convert a modbus RTU slave to a Modbus TCP slave over wifi. I tested it using the classics serial port and was able to connect using the local app over tcp/wifi.
It currently implements Holding Register read (0x03).
The implementation in TCPSlave.h/cpp could be replaced with the code that communicates with the kid over serial to add modbus TCP/Wifi access to the kid.


https://github.com/graham22/ModbusAdapter

other NodeMCU/ESP8266 project that uses webSockets to broadcast wind speed to a web page:
https://github.com/graham22/Anemometer


Graham.

Graham - guess I missed this post last year.
What do you use to compile and load your code into the ESP8266 ? I am a bit new to this - can I just use the .ino file you have listed and use the Arduino IDE ? 

I looked briefly at your wind speed project too. Adafruit is out of those anemometers . Most anemometers I have seen use magnet reed switch to count like this one . https://www.argentdata.com/catalog/product_info.php?products_id=175
 The Adafruit  one sends a voltage.

Thanks for sharing your code and projects.
I will give them a try sometime.

For the ESP 's I have been using EspEasy - have you played around with that ?
This is the new beta Mega software they have been working on
https://www.letscontrolit.com/forum/viewtopic.php?f=18&t=2257&sid=f70442693672093478ae37861eb89f3d

Larry
 
system one
Classic 150 , 20 Kyocera 135watt , 12s Soneil 2v 540amp lead crystal for 24v pack , Outback 3524 inverter
system two
Classic 150 ,5s 135 watt Kyocero , 16s Calb 100AH LiFePO4 , Outback VFX 3648 inverter
system three
Midnite KID MPPT 24 DC in to  12 volt AGM batterie

Graham

  • Full Member
  • ***
  • Posts: 191
    • SkyeTracker
Re: Ethernet Modbus port for KID
« Reply #13 on: May 06, 2017, 08:16:44 AM »


Graham - guess I missed this post last year.
What do you use to compile and load your code into the ESP8266 ? I am a bit new to this - can I just use the .ino file you have listed and use the Arduino IDE ? 

I looked briefly at your wind speed project too. Adafruit is out of those anemometers . Most anemometers I have seen use magnet reed switch to count like this one . https://www.argentdata.com/catalog/product_info.php?products_id=175
 The Adafruit  one sends a voltage.

Thanks for sharing your code and projects.
I will give them a try sometime.

Larry

Hi Larry,

You can use the arduino IDE if you add the https://github.com/esp8266/Arduino using the board manager. I use Visual Studio with the Visual Micro extension, it allows me to code in C++ to create libraries etc.  http://www.visualmicro.com/page/Arduino-Visual-Studio-Downloads.aspx.


For the ESP 's I have been using EspEasy - have you played around with that ?
This is the new beta Mega software they have been working on
https://www.letscontrolit.com/forum/viewtopic.php?f=18&t=2257&sid=f70442693672093478ae37861eb89f3d

Larry

Interesting project, are you going to have an android app as the UI   :)


Graham.
Off-Grid Island cottage, Lac Simon QC
370 Ahrs @ 24V (4 8L16 batteries)
4 x 250watt panels on dual axis trackers http://tinyurl.com/hfpkgr5
Classic 150, Whizbang Jr.
Android Monitor: http://tinyurl.com/lomzq3s

ClassicCrazy

  • Hero Member
  • *****
  • Posts: 1201
Re: Ethernet Modbus port for KID
« Reply #14 on: May 07, 2017, 12:53:23 AM »
Graham  - I do have the esp boards set up in Arduino - just could never figure out how to add different sensor plug ins and get them to compile in the EspEasy and show up  on their list of sensors when I tried it. I am a novice at this kind of thing .  I have SHT30 temperature humidity sensors and someone wrote plug in for it but never got it compiled. But someone else wrote an ESP webpage for SHT30 sensor the continuously updates and that works great.
https://www.youtube.com/watch?v=xs2Y30LhO1A&t=6s

So I just use EspEasy as is - load it into Esp Wemos Pro mini using the FlashESP8266.exe  program that is included in the EspEasy downloads with their bin files.  Then I can just go to the built in ESPEasy webpage via whatever network address the device takes on the network.

Have to wait for a pro like you to make it work better !

Would be a great add on to be able to make a plug in wifi via ESP to Classic especially if it pulls the power off of the Classic . 

Larry
« Last Edit: May 07, 2017, 12:59:08 AM by ClassicCrazy »
system one
Classic 150 , 20 Kyocera 135watt , 12s Soneil 2v 540amp lead crystal for 24v pack , Outback 3524 inverter
system two
Classic 150 ,5s 135 watt Kyocero , 16s Calb 100AH LiFePO4 , Outback VFX 3648 inverter
system three
Midnite KID MPPT 24 DC in to  12 volt AGM batterie