-
Notifications
You must be signed in to change notification settings - Fork 49
Description
I propose a simplified form of voltage measurement in the Afterburner.
This affects the varVppMeasureVpp() function in aftb_vpp.h and some definitions.
The mathematical basics:
ADC = return value of analogRead()
Vin = voltage at the analog input
res = resolution - 2^10 = 1024 (10 bit resolution)
Vpp = programming voltage VPP
Vref = reference voltage of the A/D converter at pin AREF
Based on the basic formula
(1) ADC = Vin * res / Vref
After converting formula (1) we get
(2) Vin = ADC * Vref / res
Vin results from the voltage divider R5/R6
Vpp ---+
|
-
| | R5
| |
-
|
o---- Vin to analog input
|
-
| | R6
| |
-
|
___ GND
(3) Vpp / (R5 + R6) = Vin / R6
Switched to Vpp
(4) Vpp = Vin * (R5 + R6) / R6
Vin substituted by (2):
(5) Vpp = (ADC * Vref * (R5 + R6)) / (R6 * res)
If you calculate with floating point, you can measure the Vref of your specific afterburner with a good multimeter and specify it precisely, e.g.
#define VREF (3.28) // Vref in Volts as float
This also applies to the resistors R5 and R6, which can be measured beforehand.
#define ADC_R5 (99.96) // R5 in kOhm as float
#define ADC_R6 (20.01) // R6 in kOhm as float
I put the definitions of the parameters in a separate header file aftb_adcparms.h, which is included in aftb_vpp.h.
This makes it easy to adapt to your own hardware without having to spend a long time searching between the lines of code.
The varVppMeasureVpp() function has been completely rewritten.
Measuring using this method provides a significantly better agreement between the displayed VPP values compared to a multimeter.
The difference between the Arduino measurement and the multimeter was a maximum of 0.02V (Arduino NANO, Vref = internal 1.1V, R5 = 20k, R6 = 1.3k).