voelkerb / STPM3X

Library for the ST Power Monitor Chip STPM32 and STPM34.
Creative Commons Zero v1.0 Universal
5 stars 1 forks source link

Set calibration factor vor voltage and current #4

Closed raohamza888 closed 5 months ago

raohamza888 commented 5 months ago

Hello, I am attempting to understand how you set the values inside this function. I don't understand it, and I've looked through the library files STPM3X.h and .cpp, but I couldn't find any relevant information. Could you please help me clarify this? I would greatly appreciate it. Thank you! // stpm3x.setCalibration(1.01, 1.1);

voelkerb commented 5 months ago

Hey. setCalibration(float calV, float calI) sets a member variable (calibration vector) inside the library. This is simply multiplied with all current/voltage measurements, simplified written as:

float volt = convert2Volt(rawVolt) * calV;
float current = convert2Cur(rawCur) * calI;

You can use this if e.g. your voltage dividers are designed differently or some component deviations prevent that you perfectly measure the real value. I.e. if your output is 200V but you measured it with laboratory equipment and it should be 230V, set calV to 230.0/200.0=1.15.

voelkerb commented 5 months ago

Does it answer your question? If so, I will close this issue and add the calibration section to the README.

raohamza888 commented 5 months ago

Great! Yes, you can close this issue. Thank you so much for the help.