 
   Serial.print(temp/100,DEC);        // divide by 100 and print interger value
   Serial.print(".");
-  if ((temp%100) < 10) {              // if fractional value has only one digit
+  if ((temp%100) < 10) {             // if fractional value has only one digit
     Serial.print("0");               // print a "0" to give it two digits
     Serial.print(temp%100,DEC);      // get remainder and print fractional value
   }

  power_status.pwm_duty = pwm;                             // store this value in the status
  
  if (pwm < PWM_MAX) {
    Timer1.pwm(PWM_PIN,pwm, 20); // use Timer1 routine to set pwm duty cycle at 20uS period
    //Timer1.pwm(PWM_PIN,(PWM_FULL * (long)pwm / 100));
  }												
  else if (pwm == PWM_MAX) {				  // if pwm set to 100% it will be on full but we have 
    Timer1.pwm(PWM_PIN,(PWM_FULL - 1), 1000);             // keep switching so set duty cycle at 99.9% and slow down to 1000uS period 
    //Timer1.pwm(PWM_PIN,(PWM_FULL - 1));              
  }												

#define OFF_NUM             9             // number of iterations of off charger state
  
#define PIN_LED             13            // LED connected to digital pin 13
#define BUFF_MAX            16            // Maximum buffer size for receiving from serial

//------------------------------------------------------------------------------------------------------
// global variables
enum charger_mode_t {MODE_OFF,            // The system is off
                     MODE_MPPT_ON,        // MPPT mode
                     MODE_MPPT_OFF,       // MPPT auto-off mode
                     MODE_MPPT_BULK,      // MPPT bulck charger
                     MODE_MPPT_BAT_FLOAT, // MPPT batt float mode
                     MODE_CONST_VOLT,     // Constant voltage mode
                     MODE_CONST_POWER,    // Constant power mode
                     MODE_CONST_DUTY      // Constant duty cycle mode
                    };

struct system_states_t {
   int sol_amps;                         // solar amps in 10 mV (scaled by 100)
