Battery voltage reading error with SUNRAY.

rafvice

New member
I'm currently testing everything with the PCB 1.3 on the desk. The power supplied is coming from a desk power supply and, playing with the voltage, I have seen that the voltage displayed through the App or through the serial terminal is not the same than the displayed by the power supply. Looks that the measured voltage with SUNRAY code is (more or less) 1 volt below than real value.
Doing the same test with the AZURIT code, the measured battery voltage is correct, so the problem should be inside the SUNRAY code. Did anybody find the same results?

Best regards.

Rafa
 
I'm currently testing everything with the PCB 1.3 on the desk. The power supplied is coming from a desk power supply and, playing with the voltage, I have seen that the voltage displayed through the App or through the serial terminal is not the same than the displayed by the power supply. Looks that the measured voltage with SUNRAY code is (more or less) 1 volt below than real value.
Doing the same test with the AZURIT code, the measured battery voltage is correct, so the problem should be inside the SUNRAY code. Did anybody find the same results?

Best regards.

Rafa
Rafa,

did you manage to solve it?

Best regards,
Vytautas
 
as EinEinach already wrote. Search for "batteryFactor" in AmRobotDriver.cpp ( line535 ) and reduce it slowly. I am very close with 10.88; instead the original 11.0

!! keep it a float value.

regards - Mark
 
EinEinach, Mark,

thanks for a tip. I will test it. Of course, it would be nice to have all adjustable parameters in config.h. Hopefully, it will happen one day.

Best regards,
Vytautas
 
Here is my solution:
Code:
float AmBatteryDriver::getBatteryVoltage(){
  float voltage = ((float)ADC2voltage(analogRead(pinBatteryVoltage))) * batteryFactor + 0.4;
  return voltage; 
}

float AmBatteryDriver::getChargeVoltage(){
  float voltage = ((float)ADC2voltage(analogRead(pinChargeVoltage))) * batteryFactor + 0.4;
  return voltage;
}
I just add a small offset for both voltages. It is very important to have correct voltage, because it is also used to switch the charging relais.
 
Here is my solution:
Code:
float AmBatteryDriver::getBatteryVoltage(){
  float voltage = ((float)ADC2voltage(analogRead(pinBatteryVoltage))) * batteryFactor + 0.4;
  return voltage;
}

float AmBatteryDriver::getChargeVoltage(){
  float voltage = ((float)ADC2voltage(analogRead(pinChargeVoltage))) * batteryFactor + 0.4;
  return voltage;
}
I just add a small offset for both voltages. It is very important to have correct voltage, because it is also used to switch the charging relais.


this solution worked for me better than changing the value for "batteryFactor" in AmRobotDriver.cpp

if you ant to set it in the config.h just set a var instead of the 0.4 and define it with a value in the config.h

f.e. use:
Code:
#define BatteryVoltageOffset 0.31
#define ChargingVoltageOffset 0.31
in your config.h and

Code:
float AmBatteryDriver::getBatteryVoltage(){
  float voltage = ((float)ADC2voltage(analogRead(pinBatteryVoltage))) * batteryFactor + BatteryVoltageOffset;
  return voltage;  
}
float AmBatteryDriver::getChargeVoltage(){
  float voltage = ((float)ADC2voltage(analogRead(pinChargeVoltage))) * batteryFactor + ChargingVoltageOffset;
  return voltage;
}
in your AmRobotDriver.cpp

just tested the BatteryVoltageOffset and 0.31 is sometimes perfect but maximum 2mV below for me.

Mark
 
Oben