       }                                            //and stay in the charger on state
       else {                                          
         pwm = ((bat_volts * 10) / (sol_volts / 10)) + 5;  //else if we are making more power than low solar watts figure out what the pwm
-        charger_state = bulk;                              //value should be and change the charger to bulk state 
+        power_status.mode = bulk;                              //value should be and change the charger to bulk state 
       }
       break;
     case bulk:
       if (sol_watts < MIN_SOL_WATTS) {          //if watts input from the solar panel is less than
-        charger_state = off;                    //the minimum solar watts then it is getting dark so
+        power_status.mode = auto_off;                    //the minimum solar watts then it is getting dark so
         off_count = OFF_NUM;                    //go to the charger off state
         TURN_OFF_MOSFETS; 
       }
       else if (bat_volts > MAX_BAT_VOLTS) {     //else if the battery voltage has gotten above the float
-        charger_state = bat_float;              //battery float voltage go to the charger battery float state
+        power_status.mode = bat_float;              //battery float voltage go to the charger battery float state
       }
       else if (sol_watts < LOW_SOL_WATTS) {     //else if the solar input watts is less than low solar watts
-        charger_state = on;                     //it means there is not much power being generated by the solar panel
+        power_status.mode = mppt_on;                     //it means there is not much power being generated by the solar panel
         TURN_ON_MOSFETS;                        //so go to charger on state
       }
       else {                                    // this is where we do the Peak Power Tracking ro Maximum Power Point algorithm

  Serial.print("  ");

  Serial.print("charger = ");
  if (charger_state == on) Serial.print("on   ");
  else if (charger_state == off) Serial.print("off  ");
  else if (charger_state == bulk) Serial.print("bulk ");
  else if (charger_state == bat_float) Serial.print("float");
  Serial.print("  ");

  Serial.print("pwm = ");
  print_int100_dec2((long)power_status.pwm_duty * 10000 / (PWM_FULL - 1));

}

//------------------------------------------------------------------------------------------------------
// PWM Adjustments for constant voltage and constant power modes.
// If "target_difference" > 0, it increases PWM
// If "target_difference" < 0, it decreases PWM
// The PWM step adjustment depends on the difference between target and current voltage/power
//------------------------------------------------------------------------------------------------------
void adjust_pwm(int target_difference) {

  int current_pwm = power_status.pwm_duty;
  int target_difference = target_watts - power_status.sol_watts;

