Ethernet Modbus port for KID

Started by dgd, November 11, 2015, 02:47:39 PM

Previous topic - Next topic

dgd

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
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

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

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?
KID FW1811 560W >C&D 24V 900Ah AGM
CL150 29032 FW V.2126-NW2097-GP2133 175A E-Panel WBjr, 3Px4s 140W > 24V 900Ah AGM,
2 Cisco WRT54GL i/c DD-WRT Rtr, NetGr DS104Hub
Cotek ST1500 Inv  want a 24V  ROSIE Inverter
OmniCharge3024  Eu1/2/3000iGens
West Chilcotin 1680+W to come

Graham

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 Canada
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

#4
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
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

Quote from: Westbranch on November 11, 2015, 05:14:06 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

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

Quote from: dgd 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

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 Canada
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

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

Quote from: dgd 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

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 Canada
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

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

hi dgd

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

regards
Jeremy

ClassicCrazy

Quote from: Graham on February 28, 2016, 11:01:00 AM
Quote from: dgd 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

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 1
Classic 150 , 5s3p  Kyocera 135watt , 12s Soneil 2v 540amp lead crystal for 24v pack , Outback 3524 inverter
system 2
 5s 135w Kyocero , 3s3p 270w Kyocera  to Classic 150 ,   8s Kyocera 225w to Hawkes Bay Jakiper 48v 15kwh LiFePO4 , Outback VFX 3648 inverter
system 3
KID / Brat portable

Graham

Quote from: ClassicCrazy on May 03, 2017, 03:17:18 PM


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.

Quote from: ClassicCrazy on May 03, 2017, 03:17:18 PM

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 Canada
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

#14
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
system 1
Classic 150 , 5s3p  Kyocera 135watt , 12s Soneil 2v 540amp lead crystal for 24v pack , Outback 3524 inverter
system 2
 5s 135w Kyocero , 3s3p 270w Kyocera  to Classic 150 ,   8s Kyocera 225w to Hawkes Bay Jakiper 48v 15kwh LiFePO4 , Outback VFX 3648 inverter
system 3
KID / Brat portable