Beginners guide to hooking Classic to Arduino for serial

Started by ClassicCrazy, May 03, 2018, 04:56:06 PM

Previous topic - Next topic

ClassicCrazy

I am going to document my adventures in trying wire Classic to get serial output for Arduino.

While I had the Classic open I connected wires on AUX 1 jack - was really difficult to get the stranded wire to slide in without bending strands so I gave up and uses pieces of solid wire and connected my stranded wires on those.




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

ClassicCrazy

#1
I used an ohm meter to check the pins on the jack and label the ends of the wires.  Good to verify and label to save headaches later !

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

WizBandit

When I get some time I will post some pictures of a working RJ11 to DB9 to RS232-USB cable I built.
Also you might want to read up on MODBUS commands, the CLassic supports fc-03 and fc-06 very well.
http://www.simplymodbus.ca/FC03.htm
http://www.simplymodbus.ca/FC06.htm

Use the middle jack.

You will want to grab this:
https://sourceforge.net/projects/qmodmaster/

And use it to test your cable.  It supports Serial RTU and TCPIP and I was able to read my Classic using both.
Caution on writing, you can let the smoke out writing to the wrong registers.
I would test using the Classic Name registers, 8 bytes starting at address 4209 (registers 4210-4213)

They contain the word "CLASSIC" and it will read like this "LC" "SA" "IS" "00C" because of LSB/MSB
Oh, and in HEX not ASCII.  The Name registers use "0" for BLANK

“CLASSIC” = 0x4C43, 0x5341, 0x4953, 0x0043

WillEert

I guess I cheated when I started trying to get serial communications to happen between the Arduino nd the Classic. I used a DFRobot rs232 shield so I did not have to worry about if the signal conversion was actually happening or not. I went to a mega after a while as that way I could put the Classic on one serial port and the usb on another. Much better.

https://www.robotshop.com/ca/en/rs232-shield-arduino.html?gclid=Cj0KCQjwibDXBRCyARIsAFHp4fqmwtlGP2GvnkljR7VFFxp5redEg_OpV8qam-EOhc_QPClSXmyEr-kaArlJEALw_wcB

I used this device

https://www.ebay.ca/itm/DB9-Male-RJ11-Adapter-23752-/391046835242?hash=item5b0c352c2a&_uhb=1

to go between the DB9 and RJ11 connection. By changing which pins went in which hole I could get the pinout needed.

Will

(1)24 ET 185 mono, Classic 150,8x Surrette 6CS25p, 4x Magnum 4448, homecooked diversion system;(2)15 Heliene 330 mono,Classic 150;(3)2X6 Hansol345mono, 2 stand alone Hotspot ACDC12C Minisplit heat pumps.(4)15 Hanwha Q cell 400 1/2 cell, Classic 200: (5)1X6 HanwhaQcell 400 1 Hotspot minisplit ACDC18C

WillEert

Hi Larry,

There are many libraries you could use for modbus. My sketches use the same one DGD used - SimpleModbusMasterV12. This library can be hard to locate so I have zipped up the one I have and attached it. The folder for this library needs to be renamed SimpleModbusMasterV12 when you put it into your Arduino library folder. I am not that familiar to the zipping process so hopefully this works.

Will
(1)24 ET 185 mono, Classic 150,8x Surrette 6CS25p, 4x Magnum 4448, homecooked diversion system;(2)15 Heliene 330 mono,Classic 150;(3)2X6 Hansol345mono, 2 stand alone Hotspot ACDC12C Minisplit heat pumps.(4)15 Hanwha Q cell 400 1/2 cell, Classic 200: (5)1X6 HanwhaQcell 400 1 Hotspot minisplit ACDC18C

WillEert

Hi Larry,

I spent hours getting my system to work. When it does you will feel very good. Here are my pinouts. Please be aware that in the Midnite document Midnite Solar MODBUS Network Spec Rev B.3 May 28, 2013 the pinout for the lower RJ11 port is NOT correct.

I use the lower RJ 11 jack as I have a remote MNGP connectted to the middle.

Lower RJ11 port

GND is pin 2, RX is pin 3 and TX is pin 4.    Midnite data shows TX pin 3 and RX pin 4.

Remember: Arduino is master, Classic is slave.
Master TXD connects to Slave RXD
Master RXD connects to Slave TXD


The colors are common to my wires. The logic does show how I followed my pinout through the system.

                 Classic      RJ11        Rs 232 BOB       Shield
Slave gnd:  pin 2       red 2         yellow 2            pin 5 Master Gnd
Slave TXD:  pin3       brown 3     green 3             Pin 3 Master RXD
Slave RXD:  pin4       green 4      red 4                Pin2 Master TXD

BOB Male DB9 pins order which connect to Shield female sockets. Lower row of the five pins in the DB9 connector shown

Lower row of pins: Left to right - Yellow (2) . empty, Red (4), Green (3), empty


Middle RJ 11 port

            Classic                     BOB                        Shield
RXD:     Pin 3                       Pin 3                       Pin2     TXD
TXD:     Pin 4                       Pin 4                       Pin3      RXD
Gnd:     Pin 5                       Pin 5                       Pin 5     Gnd

A common error is to connect RXD to RXD and TXD to TXD instead of RXD to TXD and TXD to RXD.

Hope this helps. I think you are not to far away from being successful.

Will


(1)24 ET 185 mono, Classic 150,8x Surrette 6CS25p, 4x Magnum 4448, homecooked diversion system;(2)15 Heliene 330 mono,Classic 150;(3)2X6 Hansol345mono, 2 stand alone Hotspot ACDC12C Minisplit heat pumps.(4)15 Hanwha Q cell 400 1/2 cell, Classic 200: (5)1X6 HanwhaQcell 400 1 Hotspot minisplit ACDC18C

WillEert

Hi Larry,

My cable is quite long. Even TTL voltage levels should go 25' I think and this is RS232 voltage.

I don't think your Classic is different than others.

I have only used the RS232 shield so I am not much help with the other hardware. When I was starting out I bought a few chips but I could not figure out the data sheets so went with the shields. I know DGD uses chips however so he could likely offer very good advice on this question.

Here is a picture of the Uno with shield and 4X20 LCD. The pinout changes in the BOB using the needed three wires only.
(1)24 ET 185 mono, Classic 150,8x Surrette 6CS25p, 4x Magnum 4448, homecooked diversion system;(2)15 Heliene 330 mono,Classic 150;(3)2X6 Hansol345mono, 2 stand alone Hotspot ACDC12C Minisplit heat pumps.(4)15 Hanwha Q cell 400 1/2 cell, Classic 200: (5)1X6 HanwhaQcell 400 1 Hotspot minisplit ACDC18C

WillEert

A possibility is that the RJ12 cable you have might not be a data cable (straight through) but a cable that crosses over. I can't tell by reading if you have tested for that or not. I have a RJ12 cable that I had to buck into and resolder the wires to get it to go straight through......Not pretty but it works.

Will
(1)24 ET 185 mono, Classic 150,8x Surrette 6CS25p, 4x Magnum 4448, homecooked diversion system;(2)15 Heliene 330 mono,Classic 150;(3)2X6 Hansol345mono, 2 stand alone Hotspot ACDC12C Minisplit heat pumps.(4)15 Hanwha Q cell 400 1/2 cell, Classic 200: (5)1X6 HanwhaQcell 400 1 Hotspot minisplit ACDC18C

ClassicCrazy

#8
I finally got it working !!!
I deleted all my old posts where nothing was working the way I was doing it previously .
I ran a piece of Cat 6 cable that I had here - about 22 feet or so I think.
I put an RJ 11 connector on the Classic end - it only had 4 contacts instead of 6 but it plugs in and works because pins 1 and 6 are not used for the modbus anyway .
It is plugged into the lowest bottom jack of the Classic ( labeled Master In on Classic)
Classic End
Pin 1 - no connection
Pin 2 - ground    ( I used the white/orange wire of cat 6)  this goes to  pin 5 ground of Male DB9 connector
Pin 3 -  TX output  ( I used solid blue of cat 6) this goes to pin Pin 2 of the DB9 which is Receive  Data
Pin 4 -  RX input  ( I used white/blue of cat 6)   this goes to Pin 3 of DB9 which is Transmit  Data
Pin 5  - not used ( though I had connected solid orange of Cat 6 to it )
Pin 6 - no connection
Reference for above pinouts
Page 44 of Midnite Classic Modbus register document http://www.midnitesolar.com/pdfs/classic_register_map_Rev-C5-December-8-2013.pdf
DB9 pinouts https://www.lammertbies.nl/comm/cable/RS-232.html
I used Arduino Uno clone like this
https://www.ebay.com/itm/UNO-R3-ATmega328P-CH340-USB-Board-for-Compatible-Arduino-DIY/321871945148?hash=item4af1101dbc:g:2usAAOSwWnFV~-Ir
But I also have a Mega for future projects
https://www.ebay.com/itm/USA-SHIP-MEGA-2560-R3-Board-ATmega2560-16AU-CH340G-USB-Cable-for-Arduino/222252152478?hash=item33bf42b69e:g:oUMAAOSwzaJX3BV-
The RS232 board was my biggest source of frustration earlier  - I was trying to use the $2 RS232 to converters and nothing would work - spent way too many hours messing with it.
So I took Will's advice and bought an RS-232 shield - not the exact DFRobot one he has but one like it that has RS232 but also RS485 option . About same price - this is the one I bought
https://www.amazon.com/gp/product/B00N4MKVFK/ref=oh_aui_detailpage_o00_s00?ie=UTF8&psc=1
I have the small toggle switches in RS232 position and the other one in UART position ( note you may have to put it in Soft Serial position to load code into Arduino or unplug shield first ( I had it unplugged when I loaded code)
I am using an LCD Keypad shield for now and that is plugged into RS232 shield
This is keypad shield I am using
https://www.ebay.com/itm/1602-Serial-Blue-Backlight-LCD-Display-Keypad-4-Arduino-Uno-R3-Mega-2560-Shield/232356694187?hash=item361989c8ab:g:DxgAAOSwAPVZMD9f
If you shop around on ebay or Aliexpress you can get all the above parts for maybe half the cost if you don't mind waiting weeks to a month to get them. The USA suppliers ship them right out and get them in a few days .

So I have piggy backed Arduino Uno on bottom , then RS232 Shield , then LCD shield. Had to jiggle them to get all pins seated well to make everything work - and careful because it is possible to push bottom pcb board onto RS232 jack and short it .
I am using DGD's sample code for now but am planning on modifying it to scroll through different Classic readouts so I won't have to push the buttons on Keypad shield like with his code.   I will also modify code to get different readouts from Classic  than DGD has in his sample code.
http://midniteftp.com/forum/index.php?topic=2328.msg22014#msg22014

Thank you  Will for taking time to help me get over the hump on this ! And thanks to DGD for figuring out the Arduino code to make it work.

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

Vic

Hi Larry,

Thanks for the play-by-play on this.

Great work!   73,   Vic
Off Grid - Sys 1: 2ea SW+ 5548, Surrette 4KS25 1280 AH, 5.25 KW PV, Classic 150,WB, Beta Barcelona, Beta KID
Sys 2: SW+ 5548s, 4KS25s, 5.88 KW PV, 2 ea. Classic 150, WB, HB CC-needs remote Monitoring/Control, site=remote.
 MN Bkrs/Bxs/Combiners. Thanks MN for Great Products/Svc/Support&This Forum!!

ClassicCrazy

Quote from: Vic on May 27, 2018, 02:35:22 PM
Hi Larry,

Thanks for the play-by-play on this.

Great work!   73,   Vic
Hard to get all the info on one place - so trying to make it a lot easier for everyone else - especially the pin outs and wire connections !

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

WillEert

Congratulations Larry. I know when, after hours of trying, when suddenly (after I had lost faith but was too stubborn to stop) the lcd lit up with data I had this great feeling of accomplishment. Yay!!!. Likely you had a similar feeling. I am also very grateful to DGD as I know without his code example of how to read from the Classic I would not ever have started.

Possibly a "kit" composed of all of the equipment required and a pre-programmed Arduino would be a product that interested people would buy. Once you can read from the Classic then you can now configure your own control system. Very satisfying and empowering.

A great book for me, starting as complete coding beginner was "Beginning C for Arduino". I ended up with a library of Arduino books to help me learn. Three others I commonly use are Arduino Programming in 24 Hours (R Blum), Arduino Sketches (Langbridge) and Exploring Arduino (J Blum). With these four books how to do almost anything can be figured out.

Cheers and congratulations again.

Will
(1)24 ET 185 mono, Classic 150,8x Surrette 6CS25p, 4x Magnum 4448, homecooked diversion system;(2)15 Heliene 330 mono,Classic 150;(3)2X6 Hansol345mono, 2 stand alone Hotspot ACDC12C Minisplit heat pumps.(4)15 Hanwha Q cell 400 1/2 cell, Classic 200: (5)1X6 HanwhaQcell 400 1 Hotspot minisplit ACDC18C

ClassicCrazy

I have started looking at some of the Arduino code that you posted Will. It will take me awhile to understand the structure of all of it and then reuse the parts that I want to.
The first thing I tried to do was just change the Celsius temps to F
I tried plugging in a couple different formulas to the line
pcb_temp /=10;
with this
pcb_temp /=10*1.8+32;
or this
pcb_temp /=10 * 9 / 5 + 32
so far no success but it is fun trying and I am learning along the way .

Also I think somewhere earlier you had said that the pinout in the Midnite modbus document for the bottom jack was not accurate but I found it to be correct .

Thanks again for the help  - so many other projects going on now I just put a bit of time into this here and there. You certainly learned a lot quickly and absorbed all those Arduino books so now you can float - ha ha !
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

WillEert

Hi Larry,

I was using a slightly older version of the Midnite Modbus document so maybe your newer one had the pinout corrected.

I have never been that successful coding a large mathematical formula. I usually take it one step at a time.
Consider:

pcb temp /=10;
pcb temp *= (1.8) + 32;

//-------------------------------------

or
pcb temp /= 10;
pcb temp *= 1.8;
pcb temp += 32;

Will
(1)24 ET 185 mono, Classic 150,8x Surrette 6CS25p, 4x Magnum 4448, homecooked diversion system;(2)15 Heliene 330 mono,Classic 150;(3)2X6 Hansol345mono, 2 stand alone Hotspot ACDC12C Minisplit heat pumps.(4)15 Hanwha Q cell 400 1/2 cell, Classic 200: (5)1X6 HanwhaQcell 400 1 Hotspot minisplit ACDC18C

dgd

Good job Larry and Will
Over the last 2 years I had quite a few enquiries from people interested in using an Arduino to display modbus data from a Classic. By far the most difficult issue for many was figuring out the serial cable.
Your articles here (faq) do that. Thanks

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