function ChargeTimerCallBack(obj,event,ljudObj,ljhandle,LowLD_sp,HighLD_sp)

global CalFactors MinChargeCurrent fid Outputs;

persistent ImonHigh_History ctr;

Num_Samples = 80;  %This is hard-coded here and should be an even multiple of the charge period divided by the sample period. 
if(isempty(ctr))   
    ImonHigh_History = 10*MinChargeCurrent*ones(1,Num_Samples);  %initial fill with a value 10 times the MinChargeCurrent it will be compared to.
    ctr = 0;
end

[analog0, analog1] = SetGetLJ(ljudObj,ljhandle,Outputs);  %Get Analog Voltages

ImonHigh = (analog0-CalFactors.ImonHigh_Zero)*CalFactors.ImonHigh_AmpsperVolt;
ImonLow = (analog1-CalFactors.ImonLow_Zero)*CalFactors.ImonLow_AmpsperVolt;


[VmonLow, Temp_ImonLow, err_Low] = BK_ReadVandI(LowLD_sp);
[VmonHigh, Temp_ImonHigh, err_High] = BK_ReadVandI(HighLD_sp);


if((err_Low == 0) && (err_High == 0))   %If there was a timeout or other error, do nothing and wait until next time.
  txt1 = 'Callback event: ';
  event_type = event.Type;
  event_time = datestr(event.Data.time);
  msg = [event_type txt1 event_time  ' VmonLow = ' num2str(VmonLow) 'V  ImonLow = '  num2str(ImonLow) ' A   VmonHigh = ' num2str(VmonHigh) 'V   ImonHigh = '  num2str(ImonHigh) ' A    ImonHigh_mean = ' num2str(mean(ImonHigh_History)) ' A'];
  disp(msg)

  msg = [event_time '   ' num2str(VmonLow) '  '  num2str(ImonLow) '      ' num2str(VmonHigh) '  ' num2str(ImonHigh) '    ' num2str(mean(ImonHigh_History))];
  fprintf(fid,'%s\n',msg);

  if(Outputs.DO2 == 1)  %Fill circular buffer with ImonHigh values.
    ctr = ctr+1;
    if(ctr > Num_Samples)
      ctr = 1;
    end
    ImonHigh_History(ctr) = ImonHigh;
  end

  %Check to see if charge is complete
  if(ImonLow < MinChargeCurrent)
    Outputs.DO0 = 0;  %Set to turn off next time.
  end
  if(mean(ImonHigh_History) < MinChargeCurrent)
    Outputs.DO2 = 0;  %Set to turn off next time.
    ImonHigh_History =  10*MinChargeCurrent*ones(1,Num_Samples);  %Set up buffer for next time.
    ctr = 0;
  end

  if((Outputs.DO0 == 0) && (Outputs.DO2 == 0))
    disp('Done Charging.  Stopping Timer!');
    stop(obj);
  end
end

end