Netduino home hardware projects downloads community

Jump to content


The Netduino forums have been replaced by new forums at community.wildernesslabs.co. This site has been preserved for archival purposes only and the ability to make new accounts or posts has been turned off.
Photo

Project finished


  • Please log in to reply
8 replies to this topic

#1 Gorf

Gorf

    Advanced Member

  • Members
  • PipPipPip
  • 96 posts

Posted 10 April 2012 - 12:41 PM

Well, my initial reason for getting involved with Netduino is pretty much finished. I've put a video online so the customer can see how it works and make any changes before I box it up and take it over for install.

My boss wants to start selling these, so I'm probably going to use the Netduino Go when it gets ethernet and SD. I've not been comfortable with C#, so VB compatibility out-of-the-box is a big attraction for the Go.

#2 Nevyn

Nevyn

    Advanced Member

  • Members
  • PipPipPip
  • 1072 posts
  • LocationNorth Yorkshire, UK

Posted 10 April 2012 - 01:12 PM

Well, my initial reason for getting involved with Netduino is pretty much finished. I've put a video online so the customer can see how it works and make any changes before I box it up and take it over for install.


Nice work.

To be or not to be = 0xFF

 

Blogging about Netduino, .NET, STM8S and STM32 and generally waffling on about life

Follow @nevynuk on Twitter


#3 Paul Newton

Paul Newton

    Advanced Member

  • Members
  • PipPipPip
  • 724 posts
  • LocationBerkshire, UK

Posted 10 April 2012 - 01:21 PM

Looks Good.

#4 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 10 April 2012 - 07:39 PM

Hi Gorf, Very cool indeed. I love big displays :) Can you share more details on the end-user usage scenario? Chris

#5 piwi

piwi

    Advanced Member

  • Members
  • PipPipPip
  • 114 posts
  • LocationGermany

Posted 10 April 2012 - 09:49 PM

Hi Mr. Gorf,

can you share some code or ways how you got this working ?

I've seen your u-tube movie but that does not reveal much detail, at leat to me. Maybe you can elaborate a bit.

My logger connected to my inverters (same brand as you have, two solar max 4200) has departed from me and now I wrote a 'little' c# program for the full framework. The PC in use is directly attached to the inverters via ethernet, logging most info avail to an SQL DB. The protocoll is something to get used to but is not that hard only time consuming. I never thought an ND+ could do the job as well and write (indirectly) to an SQL DB. So I opt for a low energy consuming PC of appx 6 Watts with no moving parts if an SSD drive is used (Fit-PC2) running MS home server. This is running since a year or so and seems to be quit stable.

Posted Image

Posted Image

So I'd gladly like to know how you got it working using an ND+

Thx in advance

Cheers,

Peter.

#6 Gorf

Gorf

    Advanced Member

  • Members
  • PipPipPip
  • 96 posts

Posted 10 April 2012 - 10:54 PM

Can you share more details on the end-user usage scenario?

A school purchased a solar system from our company with the stipulation that the live* generation data be displayed for the students. Another request was that the data be made available for later analysis, graphing etc. There are off-the-shelf solutions for logging the data, but nothing (affordable) that does both.

It would have been possible to write a program for PC that logs the data and transmits it to a screen, but it rather defeats the object of having a solar panel generating renewable energy if 10% of it is used to power a PC showing how much you're generating!

The ND+ can interrogate the inverter using its ethernet port, send the data to the sign using one of its COM ports (via the appropriate shield) and write the data to microSD.

* No pun intended


can you share some code or ways how you got this working ?

It's midnight here - I'll check with my boss if I can release the code, tomorrow. Technically, I don't own the copyright as it was written while working for his company. I don't think he'll have a problem with it as I've used a lot of sample code from the internet.

#7 Gorf

Gorf

    Advanced Member

  • Members
  • PipPipPip
  • 96 posts

Posted 19 April 2012 - 04:23 PM

There's a new video showing the ND+ working with two inverters -



Hi Mr. Gorf,

can you share some code or ways how you got this working ?

I've seen your u-tube movie but that does not reveal much detail, at leat to me. Maybe you can elaborate a bit.


It's midnight here - I'll check with my boss if I can release the code, tomorrow. Technically, I don't own the copyright as it was written while working for his company. I don't think he'll have a problem with it as I've used a lot of sample code from the internet.

It took a while to convince him...

The hardware setup is an RS232 shield and ND+ inside a project box as per the attached pic. The program reads in an INI file from the microSD card and sets up a whole bunch of parameters including startup delay, polling interval and logging interval. The poll interval is the number of seconds between requesting power generation data from the inverters. The logging interval is the number of polls that elapse between each record written to microSD.

The program is written using a single infinite loop with a sleep timer set to poll interval * 1000 - Within that loop there is another that interrogates the inverter(s) - once for the time/date as below, and again to pick up the power generation stats
Socket socket = new Socket(AddressFamily.Unspecified, SocketType.Stream, ProtocolType.Tcp);
IPHostEntry entry = Dns.GetHostEntry(Inverter_IP);
IPAddress address = entry.AddressList[0];
IPEndPoint endpoint = new IPEndPoint(address, Inverter_Port);
Inverter_Device = int.Parse(InverterDev);
// Read inverter time
strTemp = "FB;0" + InverterDev + ";1C|64:DATE;TIME|";

// Set up the transmit/receive byte arrays
byte[] TransmitData = Encoding.UTF8.GetBytes("{" + strTemp + HexClass.CheckSum(strTemp) + "}");
try
{
   socket.Connect(endpoint);
}
catch (SocketException WhatWentWrong)
{
    // Timeout - inverter must be off - reboot
    PowerState.RebootDevice(true);
}
byte[] RetVal = new byte[256];
string RetVal1 = "";
try
{
    // Blocks until send returns.
    int i = socket.Send(TransmitData);
    
    // Get reply from the server.
    socket.ReceiveTimeout = 10000;
    i = socket.Receive(RetVal);
    for (int j = 0; j < i; j++)
    {
        RetVal1 += (char)RetVal[j];
    }
}
catch (SocketException WhatWentWrong)
{
    // Timeout - inverter must be off - reboot
    PowerState.RebootDevice(true);
}

This is the bit that writes data to the SD card - a rolling counter is maintained, and when it equals logging interval, the counter is zeroed and the text record written. It's done in tab format so that it can be imported to a spreadsheet.

if (CurPollCount >= LogPollCount)
{

    //Check to see if we need a new file
    if (LogFileName != PrevLogFile)
    {
        if (!File.Exists(LogFileName))
        {
            using (StreamWriter writer = new StreamWriter(LogFileName, true))
            {
                writer.WriteLine("Time\tInverter\tTotal today (kWh)\tTotal this month (kWh)\tTotal since install (kWh)\tTotal this year (kWh)\tOutput now (W)");
            }
        }
        PrevLogFile = LogFileName;
    }

    // Log it
    strTemp = DateTime.Now.TimeOfDay.ToString();
    strTemp = strTemp.Substring(0, strTemp.IndexOf("."));

    using (StreamWriter writer = new StreamWriter(LogFileName, true))
    {
        writer.WriteLine(strTemp + "\t" + InverterDev + "\t" + KDY + "\t" + KMT + "\t" + KT0 + "\t" + KYR + "\t" + PAC);
    }
}

The serial port has already been set up outside of the main loop
// Set up LED sign
byte[] byteData = Encoding.UTF8.GetBytes("<D*>");
SerialPort serial = new SerialPort(SerialPorts.COM1, 9600, Parity.None, 8, StopBits.One);
serial.Handshake = Handshake.None;
serial.Open();
serial.Write(byteData, 0, byteData.Length);
and the last thing that happens in the main loop is the sign gets its update
byteData = Encoding.UTF8.GetBytes(strTemp);
xorValue = 0;
for (intTemp = 0; intTemp < byteData.Length; intTemp++)
    xorValue ^= byteData[intTemp]++;
byteData = Encoding.UTF8.GetBytes("<ID00>" + strTemp + xorValue.ToString("X2") + "<E>");
serial.Write(byteData, 0, byteData.Length);

Attached Files



#8 BanksySan

BanksySan

    Member

  • Members
  • PipPip
  • 28 posts
  • LocationBristol, United Kingdom

Posted 19 April 2012 - 04:34 PM

It took a while to convince him...


Kudos to you for convincing his, kudos to him for being convinced. Allot of bosses are secretive about code and it can be hard to convince them that you will get back more than you share.

I've suggested to my boss that we start sharing some of our in house achievements too, I think it makes the company look good and will help generate a good "fan base".

#9 Gorf

Gorf

    Advanced Member

  • Members
  • PipPipPip
  • 96 posts

Posted 19 April 2012 - 10:31 PM

Kudos to you for convincing his, kudos to him for being convinced. Allot of bosses are secretive about code and it can be hard to convince them that you will get back more than you share...

In my case, I just pointed out that the project would not have been finished in such a short time without help and pointers from the community, and the use of other people's code published on the net. Giving something back, however small*, is the only fair thing to do. He's a decent bloke - it wasn't hard for me to win him over, he's just really busy.

* There are many parts of the code that I'm sure can be written more elegantly, optimising speed or memory use. I don't think I'll be winning any prizes for good coding...




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

home    hardware    projects    downloads    community    where to buy    contact Copyright © 2016 Wilderness Labs Inc.  |  Legal   |   CC BY-SA
This webpage is licensed under a Creative Commons Attribution-ShareAlike License.