Diagnostic variables, SMC G2 18v15

Hello;
My current and temperatures are reading incorrectly.
Not sure what to do at this point.

Any help would make by bot feel much better:smiley:

Randy

//  ???????????????????????  WRONG AMPS, 190ma is reported as 28ma  ????????????????????????????????
void reportMotorCurrent() {
  // write motor current (in MilliAmps) to the serial monitor
  uint16_t motorCurrent = getVariable(CURRENT);
  Serial.print(" Motor Current = ");
  Serial.print(motorCurrent);
  Serial.println(" mA");
} //  end reportMotorCurrent

//  ???????????????????????  WRONG TEMPS,  80°F is reported as 543°F  ??????????????????
void reportControllerTemperature() {
    uint16_t ControllerTemperature_A = getVariable(TEMPERATURE_A);
  // write Board Temperature (in C) to the serial monitor
  Serial.print(" Controller Temperature A = ");
  Serial.print(ControllerTemperature_A);
  Serial.println(" °C");
  
// write Board Temperature (in F) to the serial monitor
  uint16_t degF = (((ControllerTemperature_A) * 9 / 5) + 32);
  Serial.print(" Controller Temperature A = ");
  Serial.print(degF);
  Serial.println(" °F");

  uint16_t ControllerTemperature_B = getVariable(TEMPERATURE_B);

  Serial.print(" Controller Temperature B = ");
  Serial.print(ControllerTemperature_B);
  Serial.println(" °C");
  
  degF = (((ControllerTemperature_B) * 9 / 5) + 32);
  Serial.print(" Controller Temperature B = ");
  Serial.print(degF);
  Serial.println(" °F");
} //  end reportControllerTemperature

Hello, Randy.

I am sorry you are having problems reading the current and temperature from your G2 SMC. From your formula to convert to Fahrenheit it looks like you are not taking into account that the temperature variables are reported in units of 0.1 °C. Also, it looks like you are expecting the controller’s temperature to be 80°F; I am not sure where you are getting this reference, but I recommend looking at the temperatures and current values reported in the Simple Motor Control Center G2 software and comparing them to the raw values you are reading from the device. If those suggestions do not help you find the problem, you might try checking that your getVariable() function is correctly combining the two bytes received back from the controller into one 16-bit value.

If you try those things and still cannot get the readings you expect, can you post more information about what you tried and what the results were? For example, it would be helpful to see a screenshot of your Serial Monitor output as well as the “Status” tab of your Simple Motor Control Center G2 software with your controller connected. Additionally, could you post the simplest complete program that demonstrates the problem?

Brandon

Thanks Brandon,
My error was using “uint16_t” instead of “unsigned int”.
All data from SMC now agrees with the Motor Control Center and my external bench test equipment.

Love these Controllers!

void reportMotorCurrent() {
  // motor current (in MilliAmps) converted to (Amps) to the serial monitor
  unsigned int motorCurrent = getVariable(CURRENT);
  Serial.print(" Motor Current = ");
  Serial.print(motorCurrent * .001, 3);
  Serial.println(" A");
} //  end reportMotorCurrent

void reportControllerTemperature() {

  unsigned int ControllerTemperature_A = getVariable(TEMPERATURE_A);
  // Temperature A (in 0.1°C) to the serial monitor
  Serial.print(" Controller Temperature A = ");
  Serial.print(ControllerTemperature_A * 0.1, 1);
  Serial.println(" °C");

  // Temperature A (in 0.1°C) converted to (in °F) to the serial monitor
  float degF = (((ControllerTemperature_A * 0.1) * 9 / 5) + 32);
  Serial.print(" Controller Temperature A = ");
  Serial.print(degF, 1);
  Serial.println(" °F");
  
} //  end reportControllerTemperature

1 Like