CMS2000 inverter RS232 Serial Port Hack. (CMS 2000 RS232)..

The latest and greatest cells. New technologies, anything on the forefront of solar tech.

Re: CMS2000 inverter RS232 Serial Port Hack. (CMS 2000 RS232

Postby slampt » Wed Mar 23, 2011 8:59 pm

Hey All,

I have been playing around with the script and RRD, I think I have made some progress, so I have attached the scripts I have made and the original perl script with some of my changes. They are fairly dodgy as I am not a programmer by any stretch!

Here is what I did;

1) Create the RRD (See ./createrrd.sh) - props to Jinba for the help with the RRD!!!
2) started up screen and ran this : while :; do ./inverter_phoenixtec.pl.txt.pl; done (this just keeps it looping when the inverter goes to sleep for the night :P not the best solution but it is fine while I am testing)

Not only will it still push info into the CSV but it should also push it into the rrdfile. (See the attached scripts)

On another note if you wish to import your CSV into an rrd you can look at my import.sh script. To use it do the following;
tail -n+2 <csvfile>.csv | ./import.sh

No Guarantees with this though :P Goodluck!!
Attachments
inverter_phoenixtec.pl.txt
(36.95 KiB) Downloaded 482 times
createrrd.sh.txt
(611 Bytes) Downloaded 413 times
import.sh.txt
(1.24 KiB) Downloaded 456 times
slampt
 
Posts: 6
Joined: Mon Mar 21, 2011 8:20 pm

Re: CMS2000 inverter RS232 Serial Port Hack. (CMS 2000 RS232

Postby slampt » Wed Mar 23, 2011 9:18 pm

Just another quick update on this,
my values in the RRD file seem to be wrong for MODE and ETODAY...
When I generate a graph for either of these using

rrdtool graph mode.png --start 1300774440 --end `date +%s` DEF:mode=inverter.rrd:MODE:AVERAGE AREA:mode#0000FF
or
rrdtool graph etoday.png --start 1300774440 --end `date +%s` DEF:etoday=inverter.rrd:ETODAY:AVERAGE AREA:etoday#0000FF

my ETODAY is consistently 1 (which leads me to think that the values for mode and etoday are swapped) however the graph for MODE is consistently 0

anyone have any ideas why?

Cheers
Slampt
slampt
 
Posts: 6
Joined: Mon Mar 21, 2011 8:20 pm

Re: CMS2000 inverter RS232 Serial Port Hack. (CMS 2000 RS232

Postby slampt » Wed Mar 23, 2011 11:24 pm

Ok, I found it I was missing a value in my createrrd :P

*New one attached*
Attachments
createrrd.sh.txt
(638 Bytes) Downloaded 415 times
slampt
 
Posts: 6
Joined: Mon Mar 21, 2011 8:20 pm

Re: CMS2000 inverter RS232 Serial Port Hack. (CMS 2000 RS232

Postby slampt » Thu Mar 24, 2011 8:21 pm

Just a quick update I have managed to get Cacti to render some graphs based on my RRD (which the perl script is updating freely atm).

Please see attached.

Thoughts?

Cheers
Slampt
Attachments
Screen shot 2011-03-24 at 5.19.17 PM.png
slampt
 
Posts: 6
Joined: Mon Mar 21, 2011 8:20 pm

Re: CMS2000 inverter RS232 Serial Port Hack. (CMS 2000 RS232

Postby shell_l_d » Sat Apr 02, 2011 11:33 am

Here's the latest with slampt's rrd code in it too :)

# + editions by shell_l_d:
# + added USE_RRDTOOL, RRDTOOL_FILE, RRDFILE_PREFIX_WIN, RRDFILE_PREFIX_OTH, RRDTOOL_EXE_WIN, RRDTOOL_EXE_OTH
# + edited REINIT_DEFAULT & writeReadBuffer()

REINIT_DEFAULT => 5, # -1 = infinite num of times (ie dont die)

# + editions by slampt:
# + uncommented & edited rrdtool (graphing) code in writeToFile() with help from JinbaIttai

P.S. Still waiting on CMS to give the latest CMS2000 (parameter fix) firmware with ETODAY in it, they sent me a file late yesterday but couldn't install it... per http://forums.whirlpool.net.au/forum-re ... #r28649524
Attachments
create_rrd.pl.txt
As at 27Mar2011
(2.02 KiB) Downloaded 416 times
inverter_phoenixtec.pl.txt
As at 27Mar2011 for Phoenixtec manufactured inverters, eg: CMS / SunEzy / Orion / Eaton.
THIS IS THE PRIMARY ONE - others are based off this one.
Note: you also need pvoutput.pl (in same directory) see post 7 on page 7 dated 08Mar2011 12:43am.
(38.88 KiB) Downloaded 423 times
Regards
Shell :)
shell_l_d
 
Posts: 102
Joined: Fri Jan 28, 2011 9:02 am

Re: CMS2000 inverter RS232 Serial Port Hack. (CMS 2000 RS232

Postby shell_l_d » Sat Apr 02, 2011 6:32 pm

Just got the latest CMS2000 parameter fix firmware which HAS ETODAY yay... have it back again.
Regards
Shell :)
shell_l_d
 
Posts: 102
Joined: Fri Jan 28, 2011 9:02 am

Re: CMS2000 inverter RS232 Serial Port Hack. (CMS 2000 RS232

Postby grahamrob » Thu Apr 07, 2011 2:17 pm

I have found a programme that will put your pc into sleep mode and also wake it up at a predetermined time --very useful for monitoring solar installations and not wasting power. WakeupOnStandBy WOSB.EXE.www.dennisbabkin.com
DESCRIPTION:
================
Have you ever thought about how much energy your computers use up at night or when they're not in use? Have you ever wondered if it's possible to wake up your system from a Sleep mode (or Hibernation) using a resident program?

The answer is yes, it is possible! This simple utility will let you do it. Besides that it can also send your system back into a Sleep mode (hibernate it, power it off, or log-off a user). Moreover, you can also use this utility as a scheduler to run programs without involving a Sleep mode. Our latest feedback shows that this utility could be used for an in-car PC to optimize booting time and to save battery life.

Our carbon footprint grows out of control with each day.

Start small. Let's Save Energy!

I have tried it and it works great the only problem is that you need to shut down "Procontroll" at night and have the programme restart it in the morning ather then that GREAT.
grahamrob
 
Posts: 1
Joined: Thu Apr 07, 2011 2:08 pm

Re: CMS2000 inverter RS232 Serial Port Hack. (CMS 2000 RS232

Postby philcolbourn » Sat Apr 30, 2011 7:20 pm

Thanks Shell for your code and for all those that contributed.

I set it up today on my CMS-2000 A1.00 inverter and had it working and uploading to pvoutput.org in no time.

I did have to do two things:

1. Perl warned me about an operator precedence problem on line 823.

perl inverter_phoenixtec.pl
Possible precedence problem on bitwise & operator at inverter_phoenixtec.pl line 823.
Starting up at 30/04/2011 16:05:47 running on linux ...

I added () around the two comparisons either side of the ampersand like this:

if ((REINIT_DEFAULT >= 0) & ($reinit > REINIT_DEFAULT)) {

Hopefully that is the correct logic.

2. I had to install the SerialPort module:

sudo apt-get install libdevice-serialport-perl

Initialise Serial Port... Can't locate object method "new" via package "Device::SerialPort" (perhaps you forgot to load "Device::SerialPort"?) at inverter_phoenixtec.pl line 677.

Apart from a broken wire in a serial cable, it went well.

Thanks again.
philcolbourn
 
Posts: 16
Joined: Sat Apr 30, 2011 7:09 pm

Re: CMS2000 inverter RS232 Serial Port Hack. (CMS 2000 RS232

Postby shell_l_d » Sat Apr 30, 2011 10:27 pm

No prob Phil... I just added to JinbaIttai's existing code :)

Yeah that bitwise problem is due to not having && but only having &, I fixed it up but never got around to posting the fix, so here it is :)

# AS AT 25Apr2011
# + editions by shell_l_d:
# + added warning to closeSerialPort() & edited REINIT_DEFAULT line in writeReadBuffer()
# + added ERRFILE_PREFIX_WIN & ERRFILE_PREFIX_OTH, getDate_YYYYMM(), getErrFileName().
# + edited parseData().
Attachments
inverter_phoenixtec.pl.txt
As at 25Apr2011 for Phoenixtec manufactured inverters, eg: CMS / SunEzy / Orion / Eaton.
THIS IS THE PRIMARY ONE - others are based off this one.
Note: you also need these in same dir:
* pvoutput.pl - post 7, page 7, 08Mar2011 12:43am.
* create_rrd.pl - post 5, page 8, 02Apr2011 11:33am.
(40.9 KiB) Downloaded 430 times
Regards
Shell :)
shell_l_d
 
Posts: 102
Joined: Fri Jan 28, 2011 9:02 am

Re: CMS2000 inverter RS232 Serial Port Hack. (CMS 2000 RS232

Postby philcolbourn » Sun May 01, 2011 12:36 am

Thanks to JinbaIttai as well.

And thank you for the prompt correction.

Do you use a crontab entry? If so, have you posted it?
philcolbourn
 
Posts: 16
Joined: Sat Apr 30, 2011 7:09 pm

Re: CMS2000 inverter RS232 Serial Port Hack. (CMS 2000 RS232

Postby philcolbourn » Sun May 01, 2011 10:48 am

Here is my crontab.

Code: Select all
*/5 6-19 * * * if [ `ps -C inverter_phoenixtec.pl | wc -l` = "1" ] ; then cd ~/Downloads/solar; ./inverter_phoenixtec.pl >> inverter_phoenixtec.pl.cronout 2>&1; fi
philcolbourn
 
Posts: 16
Joined: Sat Apr 30, 2011 7:09 pm

Re: CMS2000 inverter RS232 Serial Port Hack. (CMS 2000 RS232

Postby shell_l_d » Sun May 01, 2011 11:44 am

No I dont use a crontab as I'm using Windows instead :)

Instead I use a DOS batch file in the Startup Programs so it fires up whenever I turn my computer on. :)

MonitorInverter.bat
Code: Select all
cd c:\perlstuff
perl inverter_phoenixtec.pl


Start > All Programs> right-click 'Startup' > Open (or 'Open All Users') > copy batch file into the opened folder.
Will now be listed here: Start > Run > msconfig > Startup
Regards
Shell :)
shell_l_d
 
Posts: 102
Joined: Fri Jan 28, 2011 9:02 am

Re: CMS2000 inverter RS232 Serial Port Hack. (CMS 2000 RS232

Postby philcolbourn » Sun May 01, 2011 9:16 pm

Expanded crontab to make graphs.


*/5 6-19 * * * if [ `ps -C inverter_phoenixtec.pl | wc -l` = "1" ] ; then cd ~/Downloads/solar; ./inverter_phoenixtec.pl >> inverter_phoenixtec.pl.cronout 2>&1; fi
*/5 6-19 * * * cd ~/Downloads/solar; rrdtool graph etoday.png DEF:etoday=/tmp/inverter_1011BO0396.rrd:ETODAY:AVERAGE AREA:etoday#0000FF
*/5 6-19 * * * cd ~/Downloads/solar; rrdtool graph mode.png DEF:mode=/tmp/inverter_1011BO0396.rrd:MODE:AVERAGE AREA:mode#0000FF
*/5 6-19 * * * cd ~/Downloads/solar; rrdtool graph etotal.png DEF:etotal=/tmp/inverter_1011BO0396.rrd:ETOTAL:AVERAGE AREA:etotal#0000FF
*/5 6-19 * * * cd ~/Downloads/solar; rrdtool graph temp.png DEF:temp=/tmp/inverter_1011BO0396.rrd:TEMP:AVERAGE AREA:temp#0000FF
philcolbourn
 
Posts: 16
Joined: Sat Apr 30, 2011 7:09 pm

Re: CMS2000 inverter RS232 Serial Port Hack. (CMS 2000 RS232

Postby shell_l_d » Wed May 04, 2011 12:17 pm

Here's the latest with one inverter.pl file & a choice of 3 configuration files (phoenixtec, klne, samilpower) & some installation instructions :)

# + editions by shell_l_d:
# + implemented AppConfig & a configuration file (config.ini).

As at 4May2011 for:
* Phoenixtec manufactured inverters, eg: CMS / SunEzy / Orion / Eaton.
* KLNE manufactured inverters, eg: SunTeams.
* SamilPower manufactured inverters, eg: Solar River.


ETA... added Phoenixtec_Inverter_Protocols.xls.txt from page 6 post at 15Feb2011 05:44pm:

Page 2 extracts...
Ingmar wrote:I was also working on reverse engineering the protocol when I stumbled upon this forum.
I have a Schneider SunEzy 600E (in Europe), which seems to be based on the PhoenixTec/Sunville 4600.
...
This is what (I think) I have figured out:
The protocol is probably designed for multi-drop RS-485 (one controller, multiple inverters in daisy chain)
By analysing the sequence attached (see attachment SunEzy.xls),
...
Obviously I'm not sure about the whole thing, as verifying this requires protocol readings from a system that has multiple inverters installed, but my guess is that I'm not far off.
...
Can anyone confirm or correct?
Attachments
Phoenixtec_Inverter_Protocols.xls.txt
As at 15Feb2011:
* Phoenixtec Inverter Protocols Spreadsheet with strings for CMS2000 & SE2800 too (where different)
(86 KiB) Downloaded 642 times
inverter_monitor_110504.zip
As at 4May2011 for:
* Phoenixtec manufactured inverters, eg: CMS / SunEzy / Orion / Eaton.
* KLNE manufactured inverters, eg: SunTeams.
* SamilPower manufactured inverters, eg: Solar River.
(21.3 KiB) Downloaded 629 times
README.txt
Installation instructions.
(2.17 KiB) Downloaded 559 times
Last edited by shell_l_d on Sun May 15, 2011 3:43 pm, edited 2 times in total.
Regards
Shell :)
shell_l_d
 
Posts: 102
Joined: Fri Jan 28, 2011 9:02 am

Re: CMS2000 inverter RS232 Serial Port Hack. (CMS 2000 RS232

Postby philcolbourn » Thu May 05, 2011 11:50 pm

The output of the CSM2000 inverter is in 10Wh resolution (0.01 kWh).

When sampling at 5 minute intervals this results in a 'bumpy' average power graph on pvoutput.org where the values are quantised on about 120Wh levels.

I am working on a simple exponential averaging formula to smooth the ETotal kWh value without significantly affecting the daily total.

http://en.wikipedia.org/wiki/Exponential_smoothing

The idea is to take p% of the current value and add (1-p%) of the previous value.

I tried p=90% today and I will try p=50% tomorrow.

I suspect that p=50% will work well.

Here are my changes - the lines begin with >>>

Code: Select all
# MAIN
...
my $nextPvoutputTime = 0;
>>> my $pcExpETotal = 0;
...
# Export data to http://pvoutput.org
  #
  if (USE_PVOUTPUT) {
    $nextPvoutputTime = $lastPvoutputTime + PVOUTPUT_FREQ_SECS;
    if ( $lastPvoutputTime == 0 || $nextPvoutputTime <= time ) {
      my $date = getDate_YYYYMMDD(time);
      my $time = getTime_HHMM(time);
>>>      $pcExpETotal = 0.5*($HoH{ETODAY}{VALUE} * 1000) + 0.5*$pcExpETotal;
      print "PVOUTPUT as at " . getDateTime(time) . " ...\n";
>>>      print "  ran: " . PVOUTPUT_SCRIPT . " " . $pcExpETotal . " $HoH{PAC}{VALUE} $date $time $HASH{SERIAL}\n";
>>>      system (PVOUTPUT_SCRIPT . " " . $pcExpETotal . " $HoH{PAC}{VALUE} $date $time $HASH{SERIAL}" );
      $lastPvoutputTime = time;
    }
  }
philcolbourn
 
Posts: 16
Joined: Sat Apr 30, 2011 7:09 pm

Re: CMS2000 inverter RS232 Serial Port Hack. (CMS 2000 RS232

Postby philcolbourn » Fri May 06, 2011 6:49 pm

I have notice that I 'lag' other systems. Is this due to the EToday value not resetting in the morning?

http://pvoutput.org/comparelive.jsp?sid=1394&sid1=161&dt=20110506&t=0
philcolbourn
 
Posts: 16
Joined: Sat Apr 30, 2011 7:09 pm

Re: CMS2000 inverter RS232 Serial Port Hack. (CMS 2000 RS232

Postby philcolbourn » Sat May 07, 2011 12:43 am

Thanks again to all that worked-out how to interface these inverters.

The remaining little issues seem to be:

1. that some inverters don't reset the eToday kWh total in the morning and a work-around has been developed;
2. when the inverter does zero eToday, we have lost a little from the daily total;
3. this minor loss makes the pvoutput.org graph appear to lag other systems;
4. the lack of resolution for both eTotal and eToday make the instantaneous graphs appear bumpy;
5. the loss of a single reading causes the instantaneous graph to dip;

Possible fixes:

1. bjf noted that pvoutput.org can take cumulative energy values and from these it can derive sample averages. This also works-around the non-resetting eToday problem albeit the resolution is 100Wh not 10Wh. Another approach is to derive a eToday figures from the eTotal figures for this non-resetting period or to use differential eToday values to adjust eTotal to regain 10Wh resolution. To do this means that the program has to maintain state so turning-it-off-and-on-again will break the process without a saved state.

2. The small loss at the start of the day is an annoyance as the graph looks odd. Materially it should normally be insignificant.

3. The minor loss does, however, makes comparisons on pvoutput.org problematic. I would argue that this should be 'fixed'. The use of the cumulative eTotal value instead of the eToday value would seem to be a better value to upload to pvoutput.org. The cost is resolution unless more work is done to retain resolution.

4. If the system does not generate enough energy in the 5 or 10 minute period, the pvoutput.org graphs look odd. One thing that would help is to change to 10 minute samples. This should make the graph quantisation (if using eToday) 60Wh instead of 120Wh. But if eTotal is used the system needs to generate 600W on average to stop the graphs looking bumpy. Resolution problems could be reduced by an exponential smoothing function on either eTotal or eToday.

5. By sending 2 values each sample period may (not tested) help reduce missing data points. Likewise switching to 10 minutes on pvoutput.org and uploading every 5 minutes achieves the same result.


My thoughts:

Use eTotal. Exponentially smooth it to introduce higher resolution (1Wh). Set pvoutput.org to 10 minute samples. Send in at least 2 samples per 10 minutes.
philcolbourn
 
Posts: 16
Joined: Sat Apr 30, 2011 7:09 pm

Re: CMS2000 inverter RS232 Serial Port Hack. (CMS 2000 RS232

Postby ozsolar » Sun May 08, 2011 2:40 pm

Hi,

Anybody could share the cacti template? :D

cheers,
ozsolar
 
Posts: 2
Joined: Sun May 08, 2011 2:37 pm

Re: CMS2000 inverter RS232 Serial Port Hack. (CMS 2000 RS232

Postby ozsolar » Sun May 08, 2011 2:45 pm

slampt wrote:Just a quick update I have managed to get Cacti to render some graphs based on my RRD (which the perl script is updating freely atm).

Please see attached.

Thoughts?

Cheers
Slampt


Hi Slampt,

Nice graphs.... I just had my panel installed...Excited to see the output...

Could you please provide Cacti Templates?

cheers,
ozsolar
 
Posts: 2
Joined: Sun May 08, 2011 2:37 pm

Re: CMS2000 inverter RS232 Serial Port Hack. (CMS 2000 RS232

Postby philcolbourn » Sun May 22, 2011 1:05 am

I have been experimenting with improving pvoutput graphs.

I can now generate 1Wh values that are reasonably accurate and never greater than eToday value + 10Wh. This makes pvoutput graphs very smooth.

see http://pvoutput.org/intraday.jsp?id=1849&sid=1394&dt=20110517&m=1

My 'lag' is simply a tree shading my panels in winter mornings.

I have also modified poll timing to ensure they are either 5 min or 10 min intervals. On my slow debian Eeepc 701 used to monitor my inverter, I get this effect:

http://pvoutput.org/intraday.jsp?id=1849&sid=1394&dt=20110514&m=1

I'll post my code changes once I have tidied it up.

I am also working on getting it running on OS-X (Snow Leopard). This is a challenge since perl is not in a good shape on SL these days.

I am also thinking about an android app to wake my Eeepc each morning so I don't have to. This way, I can keep my running costs of the monitor to a minimum by making it sleep at night and 'automatically' wake each morning.
philcolbourn
 
Posts: 16
Joined: Sat Apr 30, 2011 7:09 pm

PreviousNext

Return to Tech Talk.

Who is online

Users browsing this forum: No registered users and 1 guest