This utility program helps calibrate constants for accurate current measurement and calculation.
Due to the voltage used by the JBL XTREME 2 being much greater than what can be measured by the Arduino, a voltage divider should be used.
There are two voltage dividers: one for each end of the current sense shunt. Connect the common ends of the dividers together and ground them. The midpoint of each divider should be connected to the corresponding Arduino pin. The remaining ends of the dividers should be connected to the ends of the current sense shunt.
- Power supply 7-9 V;
- Adjustable load - to get current 100mA-1A;
- Ammeter - to measure milliampers;
- Shunt (sense resistor) ~400 milliohms (2W);
- 4 resistors for voltage divider: 68k each;
- Measure voltage on the Arduino 5V pin and set this value to the constant
REF_VOLTin millivolts. - Set the value of the constant
MODEequalMode::PRINT_ANALOG_VALUES: you may check raw analog values from the pins. - Set the value of the constant
MODEequalMode::MEASURE. - Measure voltages on the each end of the shunt.
- Set the values of the constants:
VOLTAGE_DIVIDER_RATIO_1= voltage on the one end of the shunt divided byvDivider1;VOLTAGE_DIVIDER_RATIO_2= voltage on the other end of the shunt dividedvDivider2;
- Check wether
vShunt1andvShunt2are correct now, otherwise - adjust the voltage dividers ratio constants. - Pass through the shunt different currents and calculate the average resistance of the shunt:
R_SHUNT = vShuntDrop / current;
- Adjust
R_SHUNTwhile calculated current become accurate enouph.
