Author Topic: MCP60x/serial management software im writing.  (Read 3329 times)

0 Members and 1 Guest are viewing this topic.

Rainwulf

  • Newbie
  • *
  • Posts: 20
  • Country: au
MCP60x/serial management software im writing.
« on: February 05, 2018, 03:30:03 AM »
Hello, i have a small offgrid system under my house thats seperated from my on grid system. I have a 3kw set of panels running through 2 MCP60x MPPT controllers into a 24 bank made out of of 8 12 volt DC12V200 exide deep cycle batteries.

The software that came with the controllers is horrific though. Made in java and just a pain in the butt to use. So thanks to the developers, they sent me the serial command protocol sheet so i could read from the serial ports directly.

Then, it was up to me to write my own software.



This is "meter"
Written in freebasic (haha)

It reads from the two serial ports that run the mppt controllers, plus a software serial port through an arduino nano that is reading an ACS 758 current sensor. The arduino is a kind of "remote IO" board. (i can write in both freebasic and arduino languages)

I also spent some significant time developing an SoC meter that relies on the battery voltage and requires the ability to read the load current, so it gives you a fairly accurate SoC for my bank. Its tuned for lead-antimony deep cycle batteries.

So far its fairly universal with respect to the lead acid bank but its been tuned specifically towards the solar panel configuration i have, 3kw of ex-grid tie panels, in 2 groups of 3 for a normal open circuit voltage of around 93 volts.

I am also spending some time trying to make a "State" machine report what state the batteries are in, as my aim is to have the arduino outputs control a relay/inverter to run a main load that will be on the solar/bank until 50 percent SoC, plus a secondary "opportunistic" output that will only be enabled when the battery bank is fully charged, and there is excess power from the MPPT controllers.

The data is logged, and requires the ability to measure the output current. As i write more and more of it, the software will have the ability to do basic data analysis, measure AH in and out, basically a form of coloumb counting, plus other abilities like trending voltage points. 
I also intend to have a weather monitoring point to allow me to record when its raining, and cloud cover/sunlight.

So yea, hope this is interesting to someone, i can give more info if required.

If you can get a serial port interface for your controller/inverter/charger i could program in a reader for it.




SparWeb

  • Global Moderator
  • Super Hero Member Plus
  • *****
  • Posts: 5452
  • Country: ca
    • Wind Turbine Project Field Notes
Re: MCP60x/serial management software im writing.
« Reply #1 on: February 06, 2018, 10:25:57 PM »
Very nice!
I've made an Arduino talk to a program written in "JustBasic" before, and it's a challenge but not impossible.
I'm working on something similar with an Arduino Mega, but have only been focused on interfacing it and getting good data, not so much on processing the serial data stream.

Is the ASC sensor temperature calibrated?  One of my obstacles has been using current sensors that drift - A LOT - with temperature.  Since my Arduino interface is outdoors, the temp swings between -20C and +20C cause the measured current to swing +/- 0.5Amps.

Quote
...plus a secondary "opportunistic" output that will only be enabled when the battery bank is fully charged, and there is excess power from the MPPT controllers.

Can the charge controllers manage a diversion load on their own?  I can't find the datasheet for them right now...  I've experimented with different configurations of diversion load, so if you tell me more about your setup I'd be happy to suggest ways to make one work for you.
No one believes the theory except the one who developed it. Everyone believes the experiment except the one who ran it.
System spec: 135w BP multicrystalline panels, Xantrex C40, DIY 10ft (3m) diameter wind turbine, Tri-Star TS60, 800AH x 24V AGM Battery, Xantrex SW4024
www.sparweb.ca

Rainwulf

  • Newbie
  • *
  • Posts: 20
  • Country: au
Re: MCP60x/serial management software im writing.
« Reply #2 on: February 08, 2018, 06:18:50 AM »
The ACS current sensor can be temperature compensated, but i haven't done so, as my system is under the house. They do have temperature compensation graphs in their datasheets, but you will need to measure your arduino enviroment temperature, probably using something accurate like a DS18b20.

And yes, they arent all "that" accurate, but for my purposes, where current swings between 0 and 40 on discharge side, and 0 to 60 on each charge controller, its a good rough guide. I have tried to calibrate it against a proper shunt meter, but then i have no idea how good THAT one is either. I prefer galvanically isolated current sensors though, it saves earth loops, and you can throw a sensor anywhere you want without worrying about current sharing/loops.



Talking between basic and an arduino is actually really simple. Just a simple loop on both sides of the serial cable assembling bytes as they come in. Assign a "start" byte so you know where your data starts, and an end byte, i use CR, decimal 13, that terminates the string. If you use ascii transfer, you are actually transferring the asci represenations of the numbers, so you dont end up confusing the number 13 with the terminator byte. Loop over and over again and assemble the string into an array, and when you hit 13, process the array, then clear it, and start again from scratch.

Also, implement a basic checksum. Even just add up all the bytes you are sending, and then mod it with 255, and add that to the end, that will allow you to simply "authenticate" the data.



The charge controllers cant do diversion or anything special, they are pure MPPT charge controllers, thats it. Its the reason they are so cheap. They do one job and do a great one at that. Because of that, im creating my own diversion system from scratch that will switch 240 ac outlets between the mains and the inverter depending on certain conditions.

1 will be whenever the battery is above 50 percent SOC, and ONLY after float mode was achieved during the day. (this stops the problem of never getting a full charge on cloudy days)
2 will be whenever the state machine figures out the batteries are in absorb or float mode for diversion opportunities. ( things like the bar fridge, work bench, soldering iron etc)
3 will be only be on if the sun is out above a certain level (i will be implementing a brightness sensor, this is aimed at aquarium pumps, the water cooler, etc)
4 will be when its above 80 percent SOC for other loads around the house in the evening (this is aimed at the flat screen TV and media center primarily )

The primary load is 280 watts consisting of
1 4 drive NAS
1 ESXI virtualization server with 6 hard drives
1 16 drive file server
1 16 port network switch
2 8 port network switches
1 wireless access point

The aim is to get that load running 24/7 365days a year, while never getting into destructive loop of being able to to get only 70-80 percent charge during the day. No outputs will be enabled if the battery bank hits bottom SOC (50%) during the night, every output will stay off until the bank gets back to absorb mode.
When its in this isolation mode the inverter is going to be turned off and NOTHING gets power until i can get to float mode for 30 minutes.

During this time, the normally idle opportunistic 105ah 12 volt bank which just provides LED lighting and gets charged ONLY during mode 3 will be used to provide class 4 power so at least, if the main bank is in "oh $#|+" mode and hasn't had a full charge due to a really cloudy or rainy day, the normally fully charged 12 volt system with its 800 watt inverter will still take a chunk of the evening load and then get recharged the next day when mode 3 is active.

This sounds incredibly complicated, but will all be implemented with arduino controller relay banks, and arduino monitored voltage and current sensors that feed back serial data.





SparWeb

  • Global Moderator
  • Super Hero Member Plus
  • *****
  • Posts: 5452
  • Country: ca
    • Wind Turbine Project Field Notes
Re: MCP60x/serial management software im writing.
« Reply #3 on: February 08, 2018, 10:49:05 PM »
Quote
...probably using something accurate like a DS18b20...
...Assign a "start" byte so you know where your data starts, and an end byte...
...I have tried to calibrate it against a proper shunt...

Oh yeah, and I've gone through much the same process.
Why can't it be like the perfectly calibrated kilogram in France, but for electricity - so you could just order a bottle containing 1.00000 Ampere of electrons, and pour it through your shunt.  Then all our calibration issues would be simpler.   :P

Here's a link to my datalogger project:  https://www.fieldlines.com/index.php/topic,149346.0.html

Quote
galvanically isolated current sensors
I had to look that one up.  Thanks.

As for switching diversion loads, or as I call them "auxiliary" loads because they are optional, I've experimented with this in the past, but not through a microcontroller.  It was controlled purely by a LM555 chip that was triggered by one input and held "on" for a 2-minute period so that a relay could be closed.  I implemented it 2 ways: One was with a relay that worked purely ON/OFF so that the auxiliary load would stop when the 2-minute period ended, and another way used a 2-way relay so that it would switch between two different power sources: grid or inverter.  Since I'm equipped with wind and solar, the simplest trigger was a wire to the wind diversion resistors.  Those resistors didn't get hot very often because I used the auxiliary load most of the time (long story).  I'm not using it since I moved my battery bank and buried power lines, but didn't provide wires to run my auxiliary controller (another long story).

No one believes the theory except the one who developed it. Everyone believes the experiment except the one who ran it.
System spec: 135w BP multicrystalline panels, Xantrex C40, DIY 10ft (3m) diameter wind turbine, Tri-Star TS60, 800AH x 24V AGM Battery, Xantrex SW4024
www.sparweb.ca

Rainwulf

  • Newbie
  • *
  • Posts: 20
  • Country: au
Re: MCP60x/serial management software im writing.
« Reply #4 on: February 10, 2018, 03:38:13 AM »
My 240 transfer switch is complete with Revision 1 firmware!!



Its UDP controlled, so the software itself is just reading network messages and controlling relays, the software i posted in my first post is doing the actual control.

tinyt

  • Newbie
  • *
  • Posts: 6
  • Country: us
Re: MCP60x/serial management software im writing.
« Reply #5 on: February 10, 2018, 09:00:42 AM »
... the software i posted in my first post is doing the actual control.
Hi Rainwulf, I want to learn, but can't seem to find the software in the first post. Thanks.
« Last Edit: February 10, 2018, 09:19:25 AM by tinyt »

Rainwulf

  • Newbie
  • *
  • Posts: 20
  • Country: au
Re: MCP60x/serial management software im writing.
« Reply #6 on: February 10, 2018, 05:13:32 PM »
... the software i posted in my first post is doing the actual control.
Hi Rainwulf, I want to learn, but can't seem to find the software in the first post. Thanks.

The software is in alpha at the moment and there are 3 total components in the unit so far.

1 is a small celeron PC running of 12 volts, running the freebasic software.
2 is a small arduino nano connected via USB that does current reading, and will soon do voltage detection, and fan speed control for the controllers.
3 is the ATS i just posted, which is another arduino with its own software that does the reading of data over network.