SunSaver Duo Example Web Page Display and Command Line Tools

April 6, 2014

The SunSaver Duo controller MODBUS specifications are very similar to the SunSaver MPPT’s. I don’t have a SunSaver Duo to test these on. The software compiles, but I cannot test them. They are my best guess as to where to start. Good luck and enjoy!

Download The Code

This software is an example of reading information from a Morningstar SunSaver Duo and then displaying the information on a web page. This example requires the libmodbus library as well as gd2 (on Debian: apt-get install libgd2-noxpm-dev).

To extract the archive after you have downloaded the file to an appropriate location, type: tar xvfz ssduowebpageexample.tar.gz to extract the files. Then change directories to powersystem/src and type “make” to compile all of the files.

Read the README file and other included documentation for information on setting up this software.

ssduowebpageexample.tar.gz

This software also includes command line tools that read and print all the RAM and EEPROM registers on a Moringstar SunSaver Duo. The individual source files for each of these tools follow each of the values in the SunSaver Duo MODBUS specification document.

Advertisements

SunSaver MPPT Example Web Page Display and Command Line Tools

April 2, 2014

This is an example of a full web page display of the data from a Morningstar SunSaver MPPT. This software also includes command line tools that read and print all the RAM, EEPROM, and log registers on a SunSaver MPPT. There is also a command line tool to copy all the values in the log registers (up to 32 days) and write them to a log file when you are first setting up the web page software. The individual source files for each of these tools follow each of the values in the SunSaver MPPT MODBUS specification document.

Download The Code

This software is an example of reading information from a Morningstar SunSaver MPPT and then displaying the information on a web page. This example requires the libmodbus library as well as gd2 (on Debian: apt-get install libgd2-noxpm-dev).

To extract the archive after you have downloaded the file to an appropriate location, type: tar xvfz ssmpptwebpageexample.tar.gz.

Read the README file and other included documentation for information on setting up this software.

ssmpptwebpageexample.tar.gz

TriStar PWM Example Web Page Display and Command Line Tools

April 1, 2014

The TriStar PWM controller MODBUS specifications are very similar to the SunSaver MPPT’s. I don’t have a TriStar PWM to test these on, but I have received reports that the basic example tristarRAM.c works. The software compiles, but I cannot test them. They are my best guess as to where to start. Good luck and enjoy!

Download The Code

This software is an example of reading information from a Morningstar TriStar PWM and then displaying the information on a web page. This example requires the libmodbus library as well as gd2 (on Debian: apt-get install libgd2-noxpm-dev).

To extract the archive after you have downloaded the file to an appropriate location, type: tar xvfz tristarwebpageexample.tar.gz to extract the files. Then change directories to powersystem/src and type “make” to compile all of the files.

Read the README file and other included documentation for information on setting up this software.

tristarwebpageexample.tar.gz

This software also includes command line tools that read and print all the RAM, EEPROM, Calibration Values, and log registers on a Moringstar TriStar PWM. The individual source files for each of these tools follow each of the values in the TriStar MODBUS specification document.

Basic Examples For All Morningstar Devices That Support MODBUS

March 26, 2013

The Morningstar Relay Driver, SunSaver Duo, SunSaver MPPT, SureSine-300, TriStar MPPTs, and TriStar PWMs all support MODBUS communication. I’ve put together examples that read the first five RAM registers of each device and prints out the results. These are the “Hello, World” programs for communicating with these devices. If you can make these work, you should be able to read and write to the devices using MODBUS.

Please note, I only have a SunSaver MPPT and a SureSine-300. The respective examples have been tested with my devices. The others all compile, but have not been tested with their respective devices. They are my best guess as to where to start. Good luck and enjoy!

Download The Code

Each example requires the libmodbus library to be installed (see the post on this).

To extract the archive after you have downloaded the file to an appropriate location, type: tar xvfz basicexamples.tar.gz.

Read the README file for more information on this software.

basicexamples.tar.gz

Linux (and Mac OS X) Software to Read Data from Morningstar Products that Support the MODBUS Protocol

March 26, 2010

It is relatively easy to write software to read data from a Morningstar product that supports the MODBUS protocol. I have tested the software below with a SunSaver MPPT and a SureSine-300 using their MODBUS connections, a phone line splitter, and a Meterbus to Serial Converter (MSC). The programming principles in the software below should also work with the SunSaver Duo, the TriStar PWM, the TriStar MPPT, and the Relay Driver.

Example Hardware Required:

  • Morningstar SunSaver MPPT with Switch 4 ON (MODBUS Protocol)
  • Morningstar Meterbus to Serial Converter (MSC)
  • Computer running Linux or Mac OS X
  • Serial port (either built-in or via USB-Serial adaptor)

Software Required:

  • Software development environment: Linux – install build-essential and pkg-config, Mac OS X – install X Code
  • Modbus library for Linux and OSX – libmodbus (http://www.libmodbus.org/)
    *** note: The examples have been updated to use the stable version 3.0.5.

I have an off-the-grid solar power system with a Morningstar SunSaver MPPT, a Kyocera KD205GX-LP 205 watt photovoltaic (PV) panel, and a Morningstar SureSine-300 Inverter for AC loads. When I installed the system originally, I built a serial port-attached digital voltmeter to track the charge status of the batteries. This device was attached to a solar-powered Linksys NSLU2 running Debian Lenny. While this setup worked fine, the only information it could provide was the voltage of the batteries. I wanted to be able to also track the array voltage and charging current and the load voltage and current. The SunSaver MPPT provides this information via its MODBUS connection, so I bought a Morningstar Meterbus to Serial Converter (MSC) and started looking for examples of Linux software to communicate with the SunSaver MPPT. There is not much out there. The only information I could find of someone successfully using the MODBUS connection with Linux was at http://osaether.wordpress.com/. At least it could be done. I also found libmodbus – a MODBUS library for Linux and Mac OS X. It compiles and works well on both my Mac and my Linux computers and has some example software that helped point me in the right direction. I also replaced my Linksys NSLU2 with a much faster Sheevaplug (rewired to run from a DC source) running Debian Squeeze.

Setup libmodbus

wget http://libmodbus.org/site_media/build/libmodbus-3.0.5.tar.gz
tar zxvf libmodbus-3.0.5.tar.gz
cd libmodbus-3.0.5
./configure
make
su
	make install
exit

Simple Software to Read Data from the SunSaver MPPT

/*
 *  sunsavertest.c
 *  
 
 Copyright 2012 Tom Rinehart.
 
 This program is free software: you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
 the Free Software Foundation, either version 3 of the License, or
 (at your option) any later version.
 
 This program is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.
 
 You should have received a copy of the GNU General Public License
 along with this program.  If not, see http://www.gnu.org/licenses/.

*/

/* Compile with: cc `pkg-config --cflags --libs libmodbus` sunsavertest.c -o sunsavertest */

#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <modbus.h>

#define SUNSAVERMPPT    0x01	/* Default address of the SunSaver MPPT */

int main(void)
{
	modbus_t *ctx;
	int rc;
	float adc_vb_f,adc_va_f,adc_vl_f,adc_ic_f,adc_il_f;
	uint16_t data[10];

	/* Set up a new MODBUS context */
	ctx = modbus_new_rtu("/dev/ttyUSB0", 9600, 'N', 8, 2);
	if (ctx == NULL) {
		fprintf(stderr, "Unable to create the libmodbus context\n");
		return -1;
	}
	
	/* Set the slave id to the SunSaver MPPT MODBUS id */
	modbus_set_slave(ctx, SUNSAVERMPPT);
	
	/* Open the MODBUS connection to the SunSaver MPPT */
	if (modbus_connect(ctx) == -1) {
		fprintf(stderr, "Connection failed: %s\n", modbus_strerror(errno));
		modbus_free(ctx);
		return -1;
	}
		
	/* Read the first five RAM Registers */
	rc = modbus_read_registers(ctx, 0x0008, 5, data);
	if (rc == -1) {
		fprintf(stderr, "%s\n", modbus_strerror(errno));
		return -1;
	}

	/* Convert the results to their proper floating point values */
	adc_vb_f=data[0]*100.0/32768.0;
	printf("adc_vb_f=%.2f\n",adc_vb_f);

	adc_va_f=data[1]*100.0/32768.0;
	printf("adc_va_f=%.2f\n",adc_va_f);

	adc_vl_f=data[2]*100.0/32768.0;
	printf("adc_vl_f=%.2f\n",adc_vl_f);

	adc_ic_f=data[3]*79.16/32768.0;
	printf("adc_ic_f=%.2f\n",adc_ic_f);

	adc_il_f=data[4]*79.16/32768.0;
	printf("adc_il_f=%.2f\n",adc_il_f);

	/* Close the MODBUS connection */
	modbus_close(ctx);
	modbus_free(ctx);
        
	return(0);
}

Complete Examples of Accessing All of the RAM, EEPROM, and Log Registers in a Morningstar SunSaver MPPT

Building from the basic example above, the programs in the following archive read and process all of the RAM, EEPROM, and Log Registers and print out the results.

Download The Code

sunsaver.tar.gz

A Complete Example of Accessing All of the RAM and EEPROM Registers in a Morningstar SureSine-300

The program in the following archive reads and processes all of the RAM and EEPROM Log Registers and print out the results.

Download The Code

suresine.tar.gz