Firmware Revision 1791 Solar

Started by Mario, April 07, 2015, 04:45:46 PM

Previous topic - Next topic

ClassicCrazy

Quote from: Mario on April 22, 2015, 12:47:20 PM
I will try to do a quick write up to poll some data from the kid serial port, but if you want to see the data out of the kid hook it up to the master jack on the kid and set the mode to Sync that will periodically spit data,
Every packet is 4 bytes long.

Mario

What is the baud rate of the data ?  And what is the pinout for serial connections ?
Thanks
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

Mario

Master Jack Pinout:
P3= TX
P4= RX
P5= GND

UART_BAUD       57600

Mario

xsnrg

3x 250w Renogy RNG-250D
1x MidNite KID w/WBjr and MNBTS
1x 12v 100Ah el cheapo deep cycle
1x 300w PST-300-12 Samlex pure sine
http://www.howardweb.org/weather/solar/index.html

caribou

Very Happy :)

Yesterday, I try connection between the raspberry pi and KID, using a python script.  Put the KID communication mode at SYNC.

I used a PL2303 Serial Port, usb to serial port.

This is the output of what the raspberry pi receive every 10 seconds, 9 packets of 4 bytes (don't know what they means...)

9a:bf:22:00
f3:f7:fb:00
9b:d9:7f:36
fb:00:cd:cd
3f:34:9b:ff
00:33:e7:f9
00:9d:f7:7f
35:0f:f9:00
99:0f:f9:00

I join the python script.

Jean-Francois

xsnrg

I haven't had the chance to hook the port up yet unfortunately, but would be curious if you could upload a large section of data, say a 10 minute file or such?

Thanks
Jim
3x 250w Renogy RNG-250D
1x MidNite KID w/WBjr and MNBTS
1x 12v 100Ah el cheapo deep cycle
1x 300w PST-300-12 Samlex pure sine
http://www.howardweb.org/weather/solar/index.html

CDN-VT

#35
Quote from: ClassicCrazy on April 10, 2015, 11:52:36 PM
Geez - doesn't seem fair - USA  about the only country in the world that uses Fahrenheit temperatures  and Kid is made in USA and darn - only Centigrade temps on the scroll !  Yeah I know don't want to confuse the rest of the world . 
Time to understand you're BEHIND the curve , catch up !!

Edit : Bad spelling , Thanks for the reminder XS
Canadian Solar 350W 37.6 VOC  30.6 VMP 8.22 ISC 7.87 IMP ,-15 c +30c max  4 strings in 2 in Series for 24v Classic 150 -1020 Ah  Freezers & fridges ~~~ Second Array same panels of 3sx3 parallel for 24 V Classic 150 -440 Ah Outback Barns & out blds.
48Vdc almost done,11Strings up of 3s11P same panels

xsnrg

"you're", but I agree actually.  ;)

The metric system makes the math so much easier.. so much so that you can do nearly anything in your head.  I grew up on the old system as well.  They tried to teach us both, but when you needed it a wrench, it was always 9/16"  I am acclimating to the metric system by forcing myself to use it more.  F to C is probably the hardest transition though.  Dammit, water freezes at 32.  Sigh.

I'd rather have the bits and cpu cycles of the KID give me more info on the serial port than convert C to F   Once we get the data off, we can covert to Joules, degrees K, HP, and such.  I have about 1 HP of panels :)

Jim
3x 250w Renogy RNG-250D
1x MidNite KID w/WBjr and MNBTS
1x 12v 100Ah el cheapo deep cycle
1x 300w PST-300-12 Samlex pure sine
http://www.howardweb.org/weather/solar/index.html

caribou

Hello!  I reformat the output of the script to be more readable and add time.  The interval is not 10 seconds but 12!

Here is the new script and an output file.

Jean-Francois

dgd

Mario,
It's been a month since you released 1791 so just a gentle reminder about the documentation for the serial port data. I can see the data dump as others have detailed but it's not obvious how it's encoded
Just some clues posted here would be a really good start.
Web server for KID ready to go  :P

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

dgd

Quote from: caribou on April 24, 2015, 10:32:25 AM
9a:bf:22:00
f3:f7:fb:00
9b:d9:7f:36
fb:00:cd:cd
3f:34:9b:ff
00:33:e7:f9
00:9d:f7:7f
35:0f:f9:00
99:0f:f9:00

Mario,

I have manipulated this data, done binary analysis, bit shifted in all directions, anded and ored with all sorts of bit patterns AND still have not managed to extract what looks likes meaningful data items from it.
Is it really just gibberish?
If not please please please just explain what it is.
All I would like is some way to get the battery voltage, wbjr amps and the usual useful data items from the KID.
Can you help?

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

Mario

Hello here is a quick and dirty explanation on what that data means;

-Every package is and must be consisted of 4 bytes.
-the first 2 bits tell the package type, so there are 4 possible package types
     -#define PK_TYPE_Restricted      0X00   /// 00 we should never get this in the first 2 bits....
     -#define PK_TYPE_Restricted      0X01   /// 01 Restricted
     -#define PK_TYPE_SET         0X02   /// 10 This type comes from the kid as a reply to the PC or to the master Kid
     -#define PK_TYPE_GET         0X03   /// 11 Master Kid or PC is asking for a Variable

----- Here is how the Package gets structured:

                         Type SET:   Set is used mostly by the slave to respond to the master or PC to be able to respond to a GET PK.
                  there is an enum with a list of variables it can get send there are 6 bits on the 4 byte pk that will be used to
                  define only the variables to send and receive.
                  
                                                Structure of a Set Pack
                        PK Type   What2Set         Data (Required)               XOR
                         10     000000       00000000      00000000      00000010
                     
                                  PK Type:     This is the global pk type only 4 variations.
                   What2Set:  Variable from the enum to be able to interpret the data
                   Data:          Actual data 16 bits
                        
   
                    Type GET:       Get is mostly used by the Master or PC to ask the slave for a variable.
                                                 Any Get pk will be responded by a set PK.
                   Every Pk has to consist on the following:
   
                            PK Type   What2Get         Data (Optional)                        XOR
                     11     000000       00000000      00000000      00000010
                     
                     PK Type:       This is the global pk type only 4 variations.
                          What2Get:    Variable from the enum to be able to interpret the data
And here is the Enum:
/*  the SET list*/
typedef enum{ // there are 6 bits for this list.
   null = 0,                  /// Not Used
   special_key = 3,            /// Special key for different Comm modes.
   COMM_MODE = 5,      /// Not for PC Comm Mode for internal use
   COMM_status,       /// Not for PC. Comm Status
   COMM_RAWiBATT,       /// Not for PC. to be able to get the offset of the slave unit
   COMM_iBATT ,                /// Not for PC
   COMM_vPV,                    /// PV Voltage displayed on the kid
   COMM_vBATT,                /// Battery voltage displayed on the kid
   COMM_fetTEMP,             /// Internal FET temperature
   COMM_loadSTATE,         /// Load state On, off, iddle, overcurrent
   COMM_KWH,                  /// displayed KWH daily
   COMM_PWMERROR,       /// Not for PC Twin mode Only
   COMM_wimpf,         /// Not for PC Twin mode Only
   COMM_batteryStage,    /// Battery charge stage Absorb, Bulk, Float, EQ
   COMM_batt_setpoint,   /// for test Do not use, invalid parameter
   COMM_absorbV,      /// Absorb battery voltage setpoint value
   COMM_floatV,              /// Float  battery voltage setpoint value
   COMM_eqV,         /// Eq  battery voltage setpoint value
   COMM_absorbT,             /// Absorb battery time setpoint in minutes
   COMM_batteryTemp,      /// Battery Temperature as read from the BTS
   COMM_TempCompV,      /// Battery temperature compensation setpoint in mV
   Comm_SystemSet,      /// For Twin mode. set the other unit system
   Comm_BattNominal,   /// battery nominal 12, 24, 36,48 v
   Comm_EqT,         /// Eq battery time setpoint in minutes

}comm_var;

More Variables could be added to the list if required. Let me know so I can update the list of variables supported.

Now for the data you are seeing. The data you are seeing is of a SET type: here is what the Master is sending:

switch(master_var_send){
   
      handle_set_send(COMM_batteryTemp, dispavg_batt_temp);
      
      handle_set_send(COMM_batteryStage, BattChargeStage);
      
      handle_set_send(COMM_absorbV, absorbV);
      
      handle_set_send(COMM_floatV, floatV);
   
      handle_set_send(COMM_eqV, eqV);
      
      handle_set_send(COMM_TempCompV, BattTempCompOrigValue);
   
      handle_set_send(Comm_BattNominal, battery_nominal);
      
      handle_set_send(COMM_vBATT, dispavgVbatt);
   
      handle_set_send(COMM_absorbT, absorbT);
      
      handle_set_send(Comm_EqT, eqT);
      
The first variable in the function is from the Enum and the second one is the actual data.

I hope this helps a little, Maybe this needs to go in a new tread.


Mario Rodriguez


dgd

#41
Thanks Mario.
Some WBjr data would be nice when you get time
WBjr amps, remote temp, SOC%, AH net, used and remaining, ending amps  and anything else you can think of
Also KID serial #, software release, KID name(if it exists)
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

caribou

Hello Mario!

Thanks for the informations!

I'll try to match the data that I receive from the kid with what I suppose to receive...

The first byte received should begin with 0x96 that correspond to COMM_batteryTemp (10 01 0110) the first 2 bits should represent the PK_TYPE_SET.
Here, I receive 0x9A and the rest of byte received do not follow the pattern of bytes that should be send...

The communication setup is BAUDRATE = 57600, CharacterSize = 8 bits, Parity= none, stop bit = 1.

The other thing, I receive 37 bytes whe I should receive 40 bytes...
And finally, the forth byte is it corresponding to a form of checksum?

Thanks,

Jean-François Ng

Quote from: Mario on June 05, 2015, 06:24:33 PM
Hello here is a quick and dirty explanation on what that data means;

-Every package is and must be consisted of 4 bytes.
-the first 2 bits tell the package type, so there are 4 possible package types
     -#define PK_TYPE_Restricted      0X00   /// 00 we should never get this in the first 2 bits....
     -#define PK_TYPE_Restricted      0X01   /// 01 Restricted
     -#define PK_TYPE_SET         0X02   /// 10 This type comes from the kid as a reply to the PC or to the master Kid
     -#define PK_TYPE_GET         0X03   /// 11 Master Kid or PC is asking for a Variable

----- Here is how the Package gets structured:

                         Type SET:   Set is used mostly by the slave to respond to the master or PC to be able to respond to a GET PK.
                  there is an enum with a list of variables it can get send there are 6 bits on the 4 byte pk that will be used to
                  define only the variables to send and receive.
                  
                                                Structure of a Set Pack
                        PK Type   What2Set         Data (Required)               XOR
                         10     000000       00000000      00000000      00000010
                     
                                  PK Type:     This is the global pk type only 4 variations.
                   What2Set:  Variable from the enum to be able to interpret the data
                   Data:          Actual data 16 bits
                        
   
                    Type GET:       Get is mostly used by the Master or PC to ask the slave for a variable.
                                                 Any Get pk will be responded by a set PK.
                   Every Pk has to consist on the following:
   
                            PK Type   What2Get         Data (Optional)                        XOR
                     11     000000       00000000      00000000      00000010
                     
                     PK Type:       This is the global pk type only 4 variations.
                          What2Get:    Variable from the enum to be able to interpret the data
And here is the Enum:
/*  the SET list*/
typedef enum{ // there are 6 bits for this list.
   null = 0,                  /// Not Used
   special_key = 3,            /// Special key for different Comm modes.
   COMM_MODE = 5,      /// Not for PC Comm Mode for internal use
   COMM_status,       /// Not for PC. Comm Status
   COMM_RAWiBATT,       /// Not for PC. to be able to get the offset of the slave unit
   COMM_iBATT ,                /// Not for PC
   COMM_vPV,                    /// PV Voltage displayed on the kid
   COMM_vBATT,                /// Battery voltage displayed on the kid
   COMM_fetTEMP,             /// Internal FET temperature
   COMM_loadSTATE,         /// Load state On, off, iddle, overcurrent
   COMM_KWH,                  /// displayed KWH daily
   COMM_PWMERROR,       /// Not for PC Twin mode Only
   COMM_wimpf,         /// Not for PC Twin mode Only
   COMM_batteryStage,    /// Battery charge stage Absorb, Bulk, Float, EQ
   COMM_batt_setpoint,   /// for test Do not use, invalid parameter
   COMM_absorbV,      /// Absorb battery voltage setpoint value
   COMM_floatV,              /// Float  battery voltage setpoint value
   COMM_eqV,         /// Eq  battery voltage setpoint value
   COMM_absorbT,             /// Absorb battery time setpoint in minutes
   COMM_batteryTemp,      /// Battery Temperature as read from the BTS
   COMM_TempCompV,      /// Battery temperature compensation setpoint in mV
   Comm_SystemSet,      /// For Twin mode. set the other unit system
   Comm_BattNominal,   /// battery nominal 12, 24, 36,48 v
   Comm_EqT,         /// Eq battery time setpoint in minutes

}comm_var;

More Variables could be added to the list if required. Let me know so I can update the list of variables supported.

Now for the data you are seeing. The data you are seeing is of a SET type: here is what the Master is sending:

switch(master_var_send){
   
      handle_set_send(COMM_batteryTemp, dispavg_batt_temp);
      
      handle_set_send(COMM_batteryStage, BattChargeStage);
      
      handle_set_send(COMM_absorbV, absorbV);
      
      handle_set_send(COMM_floatV, floatV);
   
      handle_set_send(COMM_eqV, eqV);
      
      handle_set_send(COMM_TempCompV, BattTempCompOrigValue);
   
      handle_set_send(Comm_BattNominal, battery_nominal);
      
      handle_set_send(COMM_vBATT, dispavgVbatt);
   
      handle_set_send(COMM_absorbT, absorbT);
      
      handle_set_send(Comm_EqT, eqT);
      
The first variable in the function is from the Enum and the second one is the actual data.

I hope this helps a little, Maybe this needs to go in a new tread.


Mario Rodriguez

caribou

Ok, everything is ok!  It was my serial to usb adapter that was not working properly.

Now, I receive correctly every packets.

:-)

Jean-Francois

Quote from: caribou on June 07, 2015, 10:05:48 PM
Hello Mario!

Thanks for the informations!

I'll try to match the data that I receive from the kid with what I suppose to receive...

The first byte received should begin with 0x96 that correspond to COMM_batteryTemp (10 01 0110) the first 2 bits should represent the PK_TYPE_SET.
Here, I receive 0x9A and the rest of byte received do not follow the pattern of bytes that should be send...

The communication setup is BAUDRATE = 57600, CharacterSize = 8 bits, Parity= none, stop bit = 1.

The other thing, I receive 37 bytes whe I should receive 40 bytes...
And finally, the forth byte is it corresponding to a form of checksum?

Thanks,

Jean-François Ng

Quote from: Mario on June 05, 2015, 06:24:33 PM
Hello here is a quick and dirty explanation on what that data means;

-Every package is and must be consisted of 4 bytes.
-the first 2 bits tell the package type, so there are 4 possible package types
     -#define PK_TYPE_Restricted      0X00   /// 00 we should never get this in the first 2 bits....
     -#define PK_TYPE_Restricted      0X01   /// 01 Restricted
     -#define PK_TYPE_SET         0X02   /// 10 This type comes from the kid as a reply to the PC or to the master Kid
     -#define PK_TYPE_GET         0X03   /// 11 Master Kid or PC is asking for a Variable

----- Here is how the Package gets structured:

                         Type SET:   Set is used mostly by the slave to respond to the master or PC to be able to respond to a GET PK.
                  there is an enum with a list of variables it can get send there are 6 bits on the 4 byte pk that will be used to
                  define only the variables to send and receive.
                  
                                                Structure of a Set Pack
                        PK Type   What2Set         Data (Required)               XOR
                         10     000000       00000000      00000000      00000010
                     
                                  PK Type:     This is the global pk type only 4 variations.
                   What2Set:  Variable from the enum to be able to interpret the data
                   Data:          Actual data 16 bits
                        
   
                    Type GET:       Get is mostly used by the Master or PC to ask the slave for a variable.
                                                 Any Get pk will be responded by a set PK.
                   Every Pk has to consist on the following:
   
                            PK Type   What2Get         Data (Optional)                        XOR
                     11     000000       00000000      00000000      00000010
                     
                     PK Type:       This is the global pk type only 4 variations.
                          What2Get:    Variable from the enum to be able to interpret the data
And here is the Enum:
/*  the SET list*/
typedef enum{ // there are 6 bits for this list.
   null = 0,                  /// Not Used
   special_key = 3,            /// Special key for different Comm modes.
   COMM_MODE = 5,      /// Not for PC Comm Mode for internal use
   COMM_status,       /// Not for PC. Comm Status
   COMM_RAWiBATT,       /// Not for PC. to be able to get the offset of the slave unit
   COMM_iBATT ,                /// Not for PC
   COMM_vPV,                    /// PV Voltage displayed on the kid
   COMM_vBATT,                /// Battery voltage displayed on the kid
   COMM_fetTEMP,             /// Internal FET temperature
   COMM_loadSTATE,         /// Load state On, off, iddle, overcurrent
   COMM_KWH,                  /// displayed KWH daily
   COMM_PWMERROR,       /// Not for PC Twin mode Only
   COMM_wimpf,         /// Not for PC Twin mode Only
   COMM_batteryStage,    /// Battery charge stage Absorb, Bulk, Float, EQ
   COMM_batt_setpoint,   /// for test Do not use, invalid parameter
   COMM_absorbV,      /// Absorb battery voltage setpoint value
   COMM_floatV,              /// Float  battery voltage setpoint value
   COMM_eqV,         /// Eq  battery voltage setpoint value
   COMM_absorbT,             /// Absorb battery time setpoint in minutes
   COMM_batteryTemp,      /// Battery Temperature as read from the BTS
   COMM_TempCompV,      /// Battery temperature compensation setpoint in mV
   Comm_SystemSet,      /// For Twin mode. set the other unit system
   Comm_BattNominal,   /// battery nominal 12, 24, 36,48 v
   Comm_EqT,         /// Eq battery time setpoint in minutes

}comm_var;

More Variables could be added to the list if required. Let me know so I can update the list of variables supported.

Now for the data you are seeing. The data you are seeing is of a SET type: here is what the Master is sending:

switch(master_var_send){
   
      handle_set_send(COMM_batteryTemp, dispavg_batt_temp);
      
      handle_set_send(COMM_batteryStage, BattChargeStage);
      
      handle_set_send(COMM_absorbV, absorbV);
      
      handle_set_send(COMM_floatV, floatV);
   
      handle_set_send(COMM_eqV, eqV);
      
      handle_set_send(COMM_TempCompV, BattTempCompOrigValue);
   
      handle_set_send(Comm_BattNominal, battery_nominal);
      
      handle_set_send(COMM_vBATT, dispavgVbatt);
   
      handle_set_send(COMM_absorbT, absorbT);
      
      handle_set_send(Comm_EqT, eqT);
      
The first variable in the function is from the Enum and the second one is the actual data.

I hope this helps a little, Maybe this needs to go in a new tread.


Mario Rodriguez

dgd

#44
Quote
And here is the Enum:
/*  the SET list*/
typedef enum{ // there are 6 bits for this list.
   null = 0,                  /// Not Used
   special_key = 3,            /// Special key for different Comm modes.
   COMM_MODE = 5,      /// Not for PC Comm Mode for internal use
   COMM_status,       /// Not for PC. Comm Status
   COMM_RAWiBATT,       /// Not for PC. to be able to get the offset of the slave unit
   COMM_iBATT ,                /// Not for PC
   COMM_vPV,                    /// PV Voltage displayed on the kid
   COMM_vBATT,                /// Battery voltage displayed on the kid
   COMM_fetTEMP,             /// Internal FET temperature
   COMM_loadSTATE,         /// Load state On, off, iddle, overcurrent
   COMM_KWH,                  /// displayed KWH daily
   COMM_PWMERROR,       /// Not for PC Twin mode Only
   COMM_wimpf,         /// Not for PC Twin mode Only
   COMM_batteryStage,    /// Battery charge stage Absorb, Bulk, Float, EQ
   COMM_batt_setpoint,   /// for test Do not use, invalid parameter
   COMM_absorbV,      /// Absorb battery voltage setpoint value
   COMM_floatV,              /// Float  battery voltage setpoint value
   COMM_eqV,         /// Eq  battery voltage setpoint value
   COMM_absorbT,             /// Absorb battery time setpoint in minutes
   COMM_batteryTemp,      /// Battery Temperature as read from the BTS
   COMM_TempCompV,      /// Battery temperature compensation setpoint in mV
   Comm_SystemSet,      /// For Twin mode. set the other unit system
   Comm_BattNominal,   /// battery nominal 12, 24, 36,48 v
   Comm_EqT,         /// Eq battery time setpoint in minutes

}comm_var;

More Variables could be added to the list if required. Let me know so I can update the list of variables supported.

Mario,

Have you extended this enum list yet?
I assume iBATT is battery current and the 'not for PC' part is wrong  :)

I would like to see the following added

   COMM_watts                  ///  watts power being output
   COMM_wbjrA,                 /// WBjr amps, in one tenth amps as signed int, divide by 10 to get amps
(and do the same with other amp readings such as iBATT and loadamps)
   COMM_soc,                    /// battery SOC% (in one byte, maybe use other for charge efficiency)
   COMM_absTimeleft          // absorb time down counter
   COMM_floatTime             // total float time up counter
   COMM_remoteTemp,       /// WBjr remote temperature
   COMM_Battahrem,         /// Battery Amp Hours remaining
   COMM_Battahnet,          /// Battery Amp hours nett
   COMM_Battahcapacity    // battery capacity
   COMM_Battefficiency      // battery charge efficiency
   COMM_Kidserialno,        ///  Kid serial number
   COMM_KidFWvers           ///  Kid firmware version



   COMM_Kidname1           ///  user defined name for KID, first 2 chars
   COMM_Kidname2           ///  User defined name for KID, second 2 chars
   COMM_Kidname3           ///  user defined name for KID, third 2  chars
   COMM_Kidname4           ///  User defined name for KID, fourth 2 chars

   COMM_Loadamps           ///  Load current output

and more that you have already probably added.

Since there is no RTC in the KID but there appears to be a timer then some way to set this with data from computer would be nice/interesting. Is there any timer info available?

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