Sunday, July 20, 2014

Configuring for your system - editing the SERC_config.h file

There are perhaps 150 different configuration parameters for the Integrated Engine controller and Alternator Regulator, far too many to so via the LCD screen.  Options to select modules to include (ala, Water maker, engine co-gen mode, etc).  Options defining some board specific changes (TLE5206 vs TLE5205).  Battery profiles, engine capabilities, alternator size.  Break-in mode, and even how long you want the LCD to remain back-lite and your name..

Almost all these options are defined via the SERC_config.h file.  There are a few options contained in the main source code, ala to enable Debug or Testing mode.  But by and large, once you edit the .h file you can maintain your configuration decisions with newer updates to the source code.  This Blog post will cover how to configure a system, and is done using source v0.1.6 - and a final note:  Though examples are shown here, often the formatting is off, or odd.  The actual source code and .h file can be a bit easier to follow, and also include many additional comments on how to set these parameters and what they mean.


Step 1:  Gather information:

We need to know details about your battery, alternator, and engine.  Specifically find the following details:
  • Battery capacity and charge profiles.  Check the 'resources' tab above for a collection of specs from different manufactures (and send me new ones if you have them).  We want to know recharge profiles, limits and exit criteria:  Volts, Amps as well as adjustments and charging limits due to temperature.
  • Engine Capabilities:  Speed / HP table being most critical.  
  • Alternator capacity - You can specify a lower number of Amps then the 'label' if you are concerned about burning out a small alternator by overloading it.
  • Drive ratio and Alternator polls:  Side of engine and alternator pulley as well as # of poles in the alternator (Used to calibrate RPM measurement) 
  • Addresses for your DS18B20 temperature probes.  (Click on the Installation tab above and scroll down to the 'Temperature Sensing' section)

For this example, we have a system as follows:
  • Kubota EA-300 engine driving an xxx alternator
  • Engine is new, we need to break it in.
  • Will at some time include a Watermaker
  • Batteries consist of 3x Daka 8A8D (245Ah) AGM batteries in parallel
  • Pulley ratios are:  7.0"  and 2.6", alternator has 14 poles.

And from the Deka Tech bulletin found in the reference section I find the following guidance:
Bulk = Max 30% of c/20 rate  (73.5A per battery -> 220A the 3 battery system)

    Max Volts = Absorption

Absorption = 2.35-2.40 vpc (14.10 - 14.40v)
    Max time:  12hr
    Exit Amps:   <0.10A change over 1hr period.

Float = 2.24 -  2.26vpc (13.44 - 13.56v)

Equalization:    2.40 - 2.43vpc  (14.40 - 14.60v)
    Max time 12hr
    Exit Amps < 0.10A per Ah

Temp Co = -3mv/cell/C (-10mV/f for 12v)  - centered on 25c/77f nominal
    Cap limit adder at 35c(95f) and 15c(59f)







Step 2:  Edit 'SERC_config.h' file:

The configuration file is grouped...

Modules to Include and Hardware Options

#defines will control switches in the source to code to include and exclude different modules.  Care should be taken here as some modules re-purpose controller ports, ala the Watermaker, Co-Gen and Engine Temperature Control modules all can make use to the W-Mkr port on the controller board.

Remove the '//' in front of the modules you wish to include (commenting them), adding // to modules you do not wish.  (This same method is used in the main source to enable/disable debug and testing modes)

//#define INC_WM                //------- Define this to enable Water Maker mode of operation.
//#define INC_CG                //------- Define this to enable Co-generation (waste heat) mode (Note, CG, WM, and ET mode can NOT be combined w//o hardware change)
//#define INC_ET                //------- Define this to enable Engine Temperature control.  (Note, will use CG/Wm FET driver if those other uses are not enabled.  Else will use expansion port)
//#define INC_OC                //------- Define this to enable OverCharge mode - often used for AGM batteries.
//#define INC_AG                //------- Define this to enable Generator Auto Start (Called: AutoGen _AG, not AutoStart A_) mode


  #define CHK_OP_SENDER                //------- Define this to enable Oil Pressure Sender check.  Only do this if oil sender is attached.
//#define CHK_WF_SENDER                //------- Define this to enable Water Flow Sender check.  Only do this if Water Flow is attached.
                        //      The above two checks will cause a fault if the engine status is stopped, but Oil Pressure and/or Water Flow is still
                        //      being indicated by the externals senders (e.g, they did not ground their respective pins when the engine is off.)
                        //      If that is true, you might have an open wire or broken sender . . . . 
                        //      Also, if these senders are not installed, or are not stable,  comment out the #define.
//#define CHK_WM_SENDERS            //------  Define this to enable checking of Water Maker Pressure Senders, looking to see if pressures are out of range..




#define BREAKIN_ENGINE                //-----   Define this to enable break-in modes, currently:  Run alternator at 1/2 of load, and disable Alternator during watermaking.

#define SYSTEM_NAME "Your Name Here - DC Gen"    // Change this string to something about YOUR system, it will be printed out at startup on the Debug screen. 
                        // This way you can dbl check to make sure you are using the include file which has been customized for YOUR system, as opposed to default one..
 
Review and select which modules to include

I de-selected all options at this time, except the Oil pressure sender checking.  We can add the watermaker at a later time.



Next make sure the hardware selections match the revision and configuration of your boards.  There are only a few common options, and the source code has some more details (like resister divider ratios if you change them from the recommended values)

#define TLE5206_2                // A better H-Bridge, can use pull down resister R60/R61 to assure throttle motor is not enabled when controller is powered down.
#define INA_226                    // Improved version of INA_226.  Can natively support 12 & 24v systems, and allows for better resister divider support.

//#define TLE5205_2                // Old H-Bridge, has potential to leave drive motor engaged when controller is powered down.
//#define INA_220                // Origional Volts / Amps sampling chip.  Has limitations impacting systems greater then 12v, see Blog.



#define  PCB_0_3_x                // PCBs v0.3.x and above have some slight differances, chiefly:  FET driver charge pump, and inverting schmit trigger in Stator line, and
                        // an extra internal A/D ports which can be used for Watermaker pressure
Review and select hardware options matching your controller board.

 No changes here as this is for the latest board design.




Critical Faults and Limits

Many ports in your system can be monitored.  Temperatures (engine, Battery, Alt, cooling water), voltages, amps to name a few.  Often actions are taken to adjust the running the the generator based on these values, for example - battery target voltages are often adjusted based on the battery temperature.  But if things really get out of hand we just want to stop everything.  That is what this section is for.  it defines critical values and limits that if exceeded will shut things down.  These checks are done in a dedicated function, independent of the normal runtime code.

You might want to adjust some of these parameters after the system has ran a while.


                // -----   Critical fault values: exceeding these causes system fault and fault handler.
                //
#define FAULT_EGT_TEMP           1.05 * EGT_SETPOINT        // Above this, fault out.  (All Temps are in F)  5% over EGT.
#define FAULT_ENGINE_TEMP                    220            // Fault if above this
#define FAULT_STARTER_AMPS                   275            // If starter draws more than this, we assume it is frozen and faulted.
#define FAULT_EXT_TEMP_DELTA                  20            // If we see the Exhaust mixer 20f above the sea water temp, fault
#define FAULT_EXT_TEMP                       100            // If we see the Exhaust mixer above this temperature (150f), fault
#define FAULT_SWP_TEMP                       150            // If the Sea Water Pump is above this temp, Fault.
#define FAULT_BAT_VOLTS                       14.9          // This is where we will fault.  Make sure you have sufficient headroom for Over Charge voltage (if being used)
                                                            // Note this limit is NOT adjusted for battery temperature, it is an abs limit.  (14.9 for AGM batteries)
#define FAULT_BAT_VOLTS_LOW                7.0              // Anything below this means battery is damaged, or sensing wire is missing / failing.
#define FAULT_BAT_VOLTS_DELTA       0.2 * FAULT_BAT_VOLTS   // If battery voltage measured by the raw (Amtel) and the ina-22x's disagree by more than 20% of expected, fault.
#define FAULT_BAT_TEMP                       140            //  in degrees-F
#define FAULT_ALT_AMPS          1.2 * ALTERNATOR_SIZE       //  If over alternator's rating by 20%
#define FAULT_ALT_TEMP          1.2 *    ALT_TEMP_SETPOINT  //  in degrees-F 
#define FAULT_ALT_WATTS         FAULT_ALT_AMPS * FAULT_BAT_VOLTS
#define FAULT_ENGINE_RPMS      1.2 *    ENGINE_MAX_RPM      // Fault if 20% over speed.
#define FAULT_ENGINE_LUGGING                0.15            // Fault out if we are not able to reach within 15% of demonstrated Max RPMs while at Full Throttle.
#define FAULT_STARTER_STUCK_AMPS             -30            // If Amps measured less then this value while the engine is running, we can assume the starter is stuck ON...
#define FAULT_ENGINE_HOLDOFF               10000            // Do not check for engine faults until it has been running for 10 seconds, give it time to stabilize temps and Amp draws, oil-pressure, etc.  after starting.


                //-----    Watermaker monitoring is interesting.  Becasue it is manualy adjusted, the controller has no real idea the actualy operating state of the
                //    watermaker.  However, we do want to watch for conditions that can cause damage.   So, for the Fault testing we will check to see if
                //    either of the pressures goes above a specific limit.  And when we think the system is 'operating' we will watch the pre-filter pressures
                //    to make sure they do not go below a specific limit (we do not want the pre-filters to go into a vacumn state either!)  We will use the
                //    measured PSI on the HP side to decide if the water maker is 'active' or not.
#define  FAULT_WM_HP_MAX             1200    // Fault out if the Watermaker HP pump pressure goes above 1200 PSI
#define  FAULT_WM_PFP_MAX              45    // Fault out if the Watermaker pre-filter pressure goes above 45 PSI . .
#define  FAULT_WM_PFP_MIN              10    //  .. or below 10psi
#define  CHECK_WM_PFP_ABOVE           200    //  (And check for this min PFP value if the HP pressure is above 200psi)

#define WM_PFP_FULL_SCALE_PSI          50    // Calibration for the Watermaker Pre-Filter pressure sender.  At Full Scale, what is its PSI
#define WM_HP_FULL_SCALE_PSI         2000    // Calibration for the Watermaker High-Pressue pressure sender.  At Full Scale, what is its PSI
                        // If using v0.3.x of PCB or higher, connect Pre-Filter pressure sender to A6, and HP pressure sender to A7 on the main board expansion port.
                        // If using a prior PCB, add an external PCF8591 I2C A/D at address 0x48 (All address pins grounded on the PCF8591), and
                        // connect Pre-Filter pressure sender to Channel-0 (Pin 1), and HP pressure sender to Channel-1 (Pin2) on the PCF8591
Review and adjust critical  limits if desired.

Here I only changed the Fault_bat_volts from 16.8 to 14.9v.  Because AGM batteries are being used.  I calculated the 14.9v based on the max allowable change for temperature compensation around the max 'equalize' voltage allowed.  Remember, this value it to catch things that have gone very very wrong - meaning the core code has failed.  The fault voltage will be checked against both the INA226 measurement, as well as an additional raw Atmel A/D reading as a dbl check.

If the system does not use sea water cooling, I do not need to worry about the checks for Sea Water Pump, or Exhaust Mixer, as if no temperature sender is installed those checks will by bypassed.





System Tuning Parameters

The next section likely will not need to be changed.  It defined timings used to manage the engine, example:  How long should we 'jab' the throttle control motor each time we want to make a speed adjustment, and how long should we wait to see the results of that 'jab'.  Other timings like how long we stay at idle before starting to ramp up RPMs after starting, how long to crank the starter and how many times to try it... 

#define ENGINE_PRE_START_WARNING       500             // When being asked to start, sound the buzzer for 1/2 a second 1st to give people notice.
                                                       // This is also used to cycle the throttle 1 second up, and 1 second down.
#define ENGINE_PRE_START_WARNING2      3000            // And then wait 3 seconds before doing anything. (Be careful not to make this too long, else Watchdog will trigger)
                                                       //      (Set these two = 0 to disable startup warning buzzer)
#define ENGINE_PRE_START_CRANK            0            // Give engine a short shot to make sure raw water pump is loosened up. (150 is a good number, Set = 0 to disable)
#define ENGINE_PRE_START_REST          2000            // And rest 2 seconds after this short shot.
#define THROTTLE_TO_IDLE_DELAY         1300            // This is the amount of time needed to move the throttle cable from Full Stop to the presumed
                                                       // idle (starting) position.  It is used in start_engine() to initially position the throttle cable during start up.
                                                       // You will need to experiment some to get this number dialed in for your system.
#define START_THROTTLE_BUMP_WIDTH       100            // Between start attempt cycles, we will advance the throttle this much more.
                                                       //    (Set this to 0 if you do not want the throttle to advance between start attempts. )

#define ENGINE_GLOW_PLUG_DELAY         5000            // 5s for Glow Plug before starting to crank                MUST BE > STARTING_CHECK_RATE
#define ENGINE_START_CRANK             5000            // Crank for no more than 5 seconds per cycle . .            MUST BE > STARTING_CHECK_RATE
#define ENGINE_START_REST              4000            //     . . . rest 4 seconds                        MUST BE > STARTING_CHECK_RATE
#define ENGINE_MAX_START_TRY              4            // And try starting 4 times before giving up.
#define STARTING_CHECK_RATE             100            // Check the engine every 100mS to see if it has started (via AMPs or RPMs)...
#define ENGINE_POST_START_HOLD           40            // Keep the starter engaged for 40mS seconds after started, just to be sure....

#define ENGINE_WARMUP_DURATION        60000            // Once started, let the engine warm up 60 seconds before placing a load on it.
                                                       //   The throttle will also be advanced over this time to Full On in anticipation of having to do something..
#define WARMUP_IDLE_DURATION          10000            // And let 10 of those seconds be for just idling.
#define WARMUP_RAMP_RATE                900            // This controls how quickly the throttle is increased during Warm-up.
                                                       //  It is the amount of delay between ;THROTTLE_PULSE_WIDTH Throttle-up shots.
                                                       //  Adjust it so that the throttle advances in the time remaining in the warm-up period after the idle delay.
                                                       //  to allow the engine to reach full throttle before the warm-up period ends.  





                    //----- This is how we can decide of the engine has started.  Either by looking for a large drop in Starter AMPs draw, or via RPMs picking up.

#define STARTED_AMPS_THRESH           0.50            // When we see the Starter amp draw drop to 50% of full load, we will assume the engine has picked up.
                                //   Note:  In order for this feature to function, the alternator AND the Starter must share a COMMON
                                //    AMP shunt.  Even if they are different voltages.  Using a common GROUND shunt will often meet
                                //    this.  However be careful of unwanted currents from a 2nd charging source (e.g. starter's battery)
                                //    that can cause errors in the main alternators current reading.  See the Blog for more details.
                                //     If this method is selected, it is suggested to disable the Started by RPMs method below.
                                //    Set this variable = 0 to disable started determination by Starter amp draw.

#define STARTED_RPM_THRESH          0            // This is the number of RPMs that must be achieved in order for the controller to recognize that the engine has
                                //   started.  In order for this method to function, the FIELD_PWM_MIN variable must be configured to allow for
                                //   RPM measurements via the alternator even if it is not charging.  Note, this can cause issues with excessive
                                //   starter current draw as well as potential battery overcharging.  See Blog for more details.
                                //   Set this variable = 0 to disable Started by RPMs method.
                                // NOTE: CURRENTLY RPM MEASUREMENT DURING STARTING IS NOT VERY STABLE.  I HAVE DISABLED IT IN THE DEFAULT CONFIG, BUT LEFT
                                //     THE CODE IN PLACE - PERHAPS IT WILL WORK BETTER ON SOMEONE ELSE’S SYSTEM.


  
                    //------- And here are delays used when doing normal shutdown of the engine.  To allow for a cool-down period.
#define ENGINE_COOLDOWN_DURATION         30000UL            // 30 second cool-down period with no load while stopping.  Also return throttle to Idle.
                                                            //  Set = 0 to skip cool-downs.  In a FAULT condition the cool-down period is skipped. 
#define ENGINE_POST_STOP_LOCKOUT           10000            // Allow 10 seconds after releasing throttle to Full Stop position before you try anything else.
                                                            //  To make sure the engine has spun down before trying to say restart. (Note UL is not used on this #define.)   





                    // ------ Engine engine operational parameters
   
#define THROTTLE_PULSE_WIDTH                  20            // When fine-tuning throttle, pulse it this much each time we make an adjustment, then wait settle time
                                                            //  (BE CAREFUL WITH THIS DELAY, It is a brute-force delay in adjust_throttle() function, make it very
                                                            //  very short... Better to have lots of small 'pulses' then one large / long one... ).  If your engine hunts
                                                            //  too much when at mid-RPMs, try reducing this value.
#define THROTTLE_SETTLE_PERIOD               750            // After fine-tuning throttle, wait this long (3/4 second) for RPMs to stabilize at new throttle position
#define EXIT_QUITE_MODE_HOLDOFF_PERIOD      5000            // If the systme has transitioned out of Quite Mode we need to hold off testing for Lugging during bulk this long
                                                            // to allow for the engine to spool up to full throttle speed..


Review and adjust as needed for different engines.  Best to fine-tune these after system is running a while

As these parameters are already adjusted for the Kubota EA-300, I made changes here.





System Running Parameters

This is where we enter the capabilities of the system. The engine speed/HP data, alternator size (Under specifying it if we want to limit the amount of heat the alternator has to put up with).  We also define the max system capabilities in terms of watts - this should match the capability of your engine to keep it from being overloaded, while at the same time making sure we get the work out of it it is capable of.

These values (combined with the battery charge profiles) are the core of the system - take time to review these and adjust them.  After running a while, look at the debug data and make adjustments to these values.  When setting up my system, I worked to get the Watts / Speed / HP limits close, but a little high.  Then I let the EGT probe measure load on the engine and reduce things in real time.  In this way the controller can adjust as needed depending on changing conditions such as air temperature, cooling water, etc.  Get these values close - or low, and then adjust them up as you gain experience with your system.






 #ifdef BREAKIN_ENGINE
   #define ALT_WM_WATTS_SETPOINT        0            // Do not allow co-gen during break-in of engine.
   #define EBIF                       0.5            // During Engine Breakin we only want to run at 50% load.
 #else  
   #define ALT_WM_WATTS_SETPOINT      875            // If not Break-in we can run, but at a reduced to 875w when watermaker is also engaged
   #define EBIF                         1            // Not breaking inthe engine, allow 100% load.
 #endif


#define ALTERNATOR_SIZE               150            // Size of Alternator in Amps.  Will cap output if current grows above this, and Fault out if 20% higher.
#define ALT_WATTS_SETPOINT          1880*EBIF        // Set point for Max Watts (engine load) allowed . . .  (6hp-cont @ 3,000 RPMs, 42% effic)


#define ENGINE_TEMP_SETPOINT          180            // We want to run around this range.  If anything above it, start backing off Alternator Field drive.
                                                     //  If INC_ET is enabled, the  controller will work to keep the engine temp around this using cooling fan/pump before Alt.
#define ALT_TEMP_SETPOINT             200            //  200f
#define EGT_SETPOINT                  935            //  935f






int const RPM_Watts_array [][2] = {                // This array is used to map RPMs needed to support a given wattage load in the engine.
                {1600, 2.8 *746*0.42*EBIF},        //   (1st entry defines lowest speed we will run the engine under load, 1600 RPMs in this case)  
                {1700, 3.2 *746*0.42*EBIF},      
                {1800, 3.6 *746*0.42*EBIF},      
                {1900, 3.9 *746*0.42*EBIF},
                {2000, 4.2 *746*0.42*EBIF},
                {2100, 4.5 *746*0.42*EBIF},        // Populate with RPM and the allowed watts for that RPM.
                {2200, 4.7 *746*0.42*EBIF},        // This array is used in the manage_engine() function.
                {2300, 5.0 *746*0.42*EBIF},
                {2400, 5.2 *746*0.42*EBIF},        // Alternator / system efficiency is assumed to be 42%
                {2500, 5.4 *746*0.42*EBIF},        //  EBIF is Engine BreakIn Factor, reduced allowed load if BREAKIN_ENGINE flag is set.
                {2600, 5.5 *746*0.42*EBIF},
                {2700, 5.7 *746*0.42*EBIF},
                {2800, 5.8 *746*0.42*EBIF},
                {2900, 5.9 *746*0.42*EBIF},        // Spec maxs at 3,000 RPMS @ 6hp cont.
                {ENGINE_MAX_RPM, ALT_WATTS_SETPOINT}};     // End of array and will cause throttle to be Full on.
              
                  

#define RPM_SENSITIVITY             75            //  If we are within +/- 75 RPMs of where we want to be, do not adjust the throttle.







                // ------ Parameters used to calibrate RPMs as measured from Alternator Stator Pulses
#define RPM_IRQ_AVERAGING_FACTOR         100            // # sector pulses we count between RPM calculations, to smooth things out.  100 should give 3-6 updates / second as speed.
#define IRQ_uS_TIMEOUT                 10000            //  If we do not see pulses every 10mS on average, figure things have stopped.
#define ALTERNATOR_POLLS                  14            // # of polls on alternator
#define ENGINE_ALT_DRIVE_RATIO     ((7.0 / 2.6) * 1.00) // engine pulley diameter / alternator diameter
                                                        //  * fine tuning calibration ratio.
#define STARTING_FIELD_PWM                 0            // Minimum alternator PWM value send to Alternator when Starting (See START_ENGINE() ).
                                                        // Set this to a value sufficient to give Stator pulses and allow for RPMs to be measured, but not so high as to
                                                        // actually start delivering amps.  This value will need to be verified for each system.  Being able to measure RPMs
                                                        // while not charging is used during Starting to allow start_by_RPMS.
                                                        //    Set this value = 0 to disable RPMs measurements during starting.
                                                        //    Note:  if STARTED_RPM_THRESH is set != 0, this value must also be non-zero.
                                                        // NOTE: CURRENTLY RPM MEASUREMENTS DURING STARTING IS NOT VERY STABLE.  I HAVE DISABLED IT IN THE DEFAULT CONFIG, BUT LEFT
                                                        //     THE CODE IN PLACE - PERHAPS IT WILL WORK BETTER ON SOMEONE ELSE’S SYSTEM.
                              

Adjusted as needed, and fine tune when system is operating.

As this values are already set for a Kubota EA-300 system I made no changes.  For the initial running the 'break-in' mode is selected, so we will be running with a light load (half power) anyway.  Once break-in is finished we can see how these values fit the system.  One parameter of particular interest is the Alternator_size; we might want to set this at either 220A to match the max current allowed for our 3x batteries, or perhaps set it for a slightly smaller size then the alternator specifications if we are worried about overworking the alternator (ala, using a small-frame alternator).  Another parameter of interest is the Alt_watts)_setpoint:  Here we can  are the Alternator_size and Alt_watts_setpoint.  It, combined with the HP/RPM table defines the load that will be placed on the engine.







Battery Charge Profile

This is the other key area of configuration - battery information.   You have the option of configuring a standard 3-step profile (Bulk, Acceptance, Float)  or 4-step (adding Overcharge step) for your system.  Each phase has parameters to set voltage limits, time limits, and exit criteria.  Here is also where you can select auto-stop; stopping the generator instead of remaining in Float mode.

Note that because the controller measures Amps we have the ability to more closely follow manufactures recommended charge profiles.  Specifically, we can measure the current being accepted by the battery and use that to decide when to terminate the Acceptance phase - doing so when the battery is truly full.  As opposed to using a time limit / guess.   Even so it is a good idea to always define time limits, just in case - but make them long and let the Amps to the work!

Note there is no equalize phase parameters, maybe I will add them in the future.  For now to equalize perhaps make up a different include file and re-flash the firmware - restoring things once the equalize task is finished. 


#define ACPT_BAT_V_SETPOINT            14.3              // Set point for Bulk and Acceptance battery voltage
#define EXIT_ACPT_DURATION        12*3600000UL           // Stay in Accept mode no longer then this in hours (12 hrs).
#define EXIT_ACPT_AMPS                     10            // If Amps being delivered falls to this level or below, exit Accept mode and go to next (OC or Float)
                                                         //        Set this = 0 to disable Amps based transition and only rely on timeout duration.



                                // Overcharge mode is sometimes used with AGM batteries and occurs between Acceptance and Float phase.
                                // In order to enable this feature, the '#define INC_OC' switch above must be defined and the OC_BAT_V_SETPOINT must be a
                                // non-zero value AND the EXIT_OC_DURATION must be a non-zero time value.
                                // If all three are true, the controller will add on an Over Charge mode following the Acceptance phase.
#define OC_BAT_V_SETPOINT          0.0                  //    Set point for Over Charge battery voltage (Set this = 0 to disable)
#define EXIT_OC_DURATION          0*3600000UL           //    Over Charge mode duration in hours.  (Set this = 0 will also disable Over Charge step.)
#define EXIT_OC_AMPS                0                   // If Amps being delivered falls to this level or below, system will exit Overcharge mode and go to Float
                                                        //     Set this = 0 to disable Amps based transition and only rely on timeout duration.


#define FLOAT_BAT_V_SETPOINT           13.5              // Set point for Float battery voltage
#define EXIT_FLOAT_DURATION         0.0*3600000UL        // Stay in Float Mode no longer then this (e.g. 0.5 hrs =  0.5*3600000UL).  System will then auto-stop and return to Ready status.
                                                         //    Set this variable = -1L  to disable time based auto-shut down in Float.  (Note the missing U - Do not use -1UL)
                                                         //    Set = 0L to bypass Float Mode entirely and immediately turn off generator immediately when charging is completed.
#define EXIT_FLOAT_AMPS            10                    // If Amps being delivered falls to this level or below, auto-stop system.
                                                         //          Set this = 0 to disable Amps based auto-stop.


 
#define BAT_TEMP_NOMINAL            77            // Nominal temp for above bat voltages (in deg-F).              
#define BAT_TEMP_1F_COMP            0.010         // Vbat temp compensation for 12v AGM batteries per degree-F (3mv/c published spec per cell, * 6 cells * 5/9 to convert to f)
#define MIN_TEMP_COMP_LIMIT         59            // If the battery temp is less than 50f, cap temp compensation voltage raise to prevent overvoltage in very very cold places.
#define MAX_TEMP_COMP_LIMIT         95            // If the battery temp is grater than 95f, cap temp compensation voltage raise to prevent overvoltage in very very hot places.
#define BAT_MAX_CHARGE_TEMP        125            // Do not charge battery above the temp, Force into Float mode.
#define BAT_MIN_CHARGE_TEMP        -50            // And do not change below this temp, again forcing to Float.




Adjust to fit your battery manufactured profile

I made a lot of changes here.  The default values were selected around a large (1,800 Ah) 12v FLA battery, while this is a 12v AGM battery - we need to be very very careful with voltages.

Referring to the Deka specs, it targets 14.1 to 14.4v as the acceptance voltage.  I selected 14.3, towards the higher end of the range for faster recharging, but a bit lower than Max to take it a little easier on the batteries.  Remember, a battery will recharge fully even at rather low voltages, it just takes longer.  I put in the 12h max time for acceptance as recommended, but when it came to exit Amps I had to make a decision.

Deka is one of the very few (if any) manufactures who specific their Acceptance exit criteria as a low rate-of-change in amps, as opposed to a % of capacity in absolute amps.  Currently rate-of-change is not a coded in for an exit criteria (I may add it later);  so I instead looked at other AGM batteries and noted their exit amps  % used ranged from 0.1% of AH capacity to 0.6%, or in the case of this 735Ah battery bank - until the acceptance amps drops to a range of  under 1 amp to almost 5A. I selected the higher end of this range, and added in an extra 5A to account for some amount of background house loads and selected 10A as the value to use for exiting Acceptance.  As you define your exit criteria, do consider what, if any, baseline house loads might be present while generating - as the DC generator will be supporting (and measuring) the current needed to not only recharge the battery, but also support those house loads.

These values are ones that can be adjusted to meet your total system needs and desire of how to run it.  Want to recharge things faster?  Increase the Acceptance Voltage limit.  Want to increase battery life?  Lower it.  OK with using the Generator to recharge to say the 90% point, and perhaps let Solar cells do the rest?  Raise the Exit Amps to say 25A.  Want to make sure the battery is 100% recharged each and every time?  Set it for 1A.  Lots of flexibility here.

Temperature limits also need to be edited to match the battery manufactures guidance.  The default values are OK for most all lead-acid based batteries, but if you are using say LiFePO4 batteries typically you would set the 1F_comp to 0, and adjust the min and max charge temperatures to protect the batteries.  Take special note of the Min charge temp - some LiFePO4 batteries specify 0c (32f) as the lower limit for charging batteries...


Included Modules Parameters

Here some customization of optional include modules are defined.  Auto-gen startup, watermaker, etc.  In the future this section may expand.  Example, adding black-out time periods for the Auto-gen..

            //-------    Auto-Start parameters
            //
            //

#ifdef INC_AG
  #define AG_VOLTS_THRESH              11.5            // If VBat falls below this voltage . . .    (Set = 0  will disable  Auto Gen).
  #define AG_HOLDOFF              5*60000UL            //  ...  for this long (5 minutes), then we can consider auto-starting the generator
                                                       //       (= 0 will also disable auto-start feature)
  #define AG_WARMING_TIME           20000UL            //  Sound the beeper 20 seconds before doing the auto start. . .
  #define AG_WARNING_DURATION          3000            //  ...  and sounds it for 3 seconds.


            //  Future will add in quite-time tables using an RTC
  #endif





            //------    Co-Gen Paramaters
            //
            //

#ifdef INC_CG
  #define CG_TEMP_START              160            // Start up the CoGeneration waste heat pump (if IN_CG flag is defined)
  #define CG_TEMP_STOP               140            // If generator falls below this value (deg-F), stop the waste heat pump.
  #endif










            //----    Watermaker Paramaters
            //
            //
#ifdef INC_WM
  #define PRE_WM_HOLD            1000UL             // When enabling the WM clutch, start the throttle to Full On, and delay this long.
                                                    //  Just to give the motor some time to start accelerating.  Do not make this TOO big
                                                    // as it is a raw delay, and the WM pump should be unloaded - giving time for the engine
                                                    // to reach full speed.
  #define POST_WM_HOLD           20000UL            // After the WM clutch is turned off, keep the motor at Full Speed (and running) this long (20 seconds)
                                                    // incase the user re-enabled the WM (ala, when priming the filters and cycling pump on and off)
  #endif


Review and adjust as needed

As none of these modules are currently being used, I made no changes here.





System Configuration Parameters

Finally we have a grouping of system configurations to adjust.  Things like the AMP shunt ratio, the address of the DS1820 temperature senders, even our 'welcome' splash on the LCD and any back light timeout we want to use.

#define AMP_SHUNT_RATIO        (250/0.075)*1.00        // Spec of amp shunt,  250A / 75mV shunt * 0% calibrating error (Edit error later after calibrating)
                                                       //  Note, if Shunt voltage will exceed 80mV, then the ina-22x calibration will need to be adjusted.
#define BAT_VOLT_SCALER        (464+33)/33             // Scaling values of Voltage Divider resisters R42/R43 on the raw Amtel VBat sensing line.
#define PBAT_SCALER            (10+10)/10              // Scaling values of Voltage Divider resisters R30/R40 on the ina-22x VBat+ sensing line.


            // ----- One Wire addresses, need to hand code these for now.
            //
            //

#define OW_NUM_DEVICES    6
#define OW_ENGINE_TEMP  {0x28, 0x13, 0x53, 0x60, 0x04, 0x00, 0x00, 0xC9}    // Engine cooling water engine temperature
#define OW_SEA_TEMP     {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}    // Sea Water temp sensor
#define OW_ALT_TEMP     {0x28, 0x2E, 0xFB, 0x5F, 0x04, 0x00, 0x00, 0xB1}    // Alternator Temp
#define OW_ALT2_TEMP    {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}    // 2nd Alternator Temp (if present)
#define OW_BAT_TEMP     {0x28, 0x28, 0x04, 0x60, 0x04, 0x00, 0x00, 0x18}    // Battery Temp
#define OW_EXT_TEMP     {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}    // Exhaust Mixer Temp
#define DS18x20_RESOLUTION     TEMP_10_BIT                                  // All devices work in 10 bit (0.25C) resolution mode.
                                                                            //  (Note if DS10S20 us used, unit is fixed to 9-bit)




const char welcomeScreen[]  PROGMEM  = { "Welcome Kubota-Gen" };        // Put your Welcome (Power on) message here.  Make it as long as you wish, noting
                                                                        // it will wrap on the LCD screen.

#define BACKLIGHT_TIMEOUT      10*60000UL                                // Number of minutes with no keyboard action, drop the backlight on the LCD.
                                                                         //  Set = 0 to disable backlight diming.
      

Review and adjust as needed, esp:  Amp shunt ratio and DS18B20 temperature probe addresses

Here I changed the Amp Shunt ratio to match what is being used.  I also set the calibration factor to 100%, after running we can calibrate it against an accurate meter if we want.   I have found the Amp Shunts are very poor in calibration - having at times as much as a 5-10% error..   Measure your system near the point that matters most, ala around 25A or so to center the calibration for use by the Acceptance Exit Amps.  Notice how I entered 0x00's for the address of probes not used, like the 2nd alternator temperature sensor.  This will disable any actions taken by the code around that probe, including fault checking.




All Done.



That is it!  Save your new configuration file.  Copy it to the Arduino sketch folder in the same sub-directory as the controller code - overwriting  the default config file.  As new revisions to the source come out there may be some additional parameters added to this config.h file, if so just copy out the new default definitions into your customized file and adjust as appropriate



No comments:

Post a Comment