-
11Step 11
Calibration
1. #define CALIBRATION in software and recompile and flash ATtiny861
2. For each range make two measurements in order to calculate the line v=k*ADC + m. With this simple approach I get about 10-20mV and 10-20mA accuracy ( compared to my UNI-T UT132E ;-)
U[0] Vref= 1.1V, Gain x1, Range 13.2V, ADC clock 125kHz, pin PA4
{ 3000mV, 231 ADC}, {13000mV, 1003 ADC} => k=10000/772 m=8
U[1] Vref= 2.56, Gain x1, Range 30.9V, ADC clock 125kHz, pin PA4
{ 3000mV, 98 ADC}, {19000mV, 628 ADC} => k=16000/530 m=42
I[0] Vref= 1.1, Differential gain x30, range 1.6A, ADC clock 250kHz, pin PA 5-6
{ 200mA, 115 ADC}, {1310mA, 807 ADC} => k=1110/692 m=16
I[1] Vref= 2.56,Differential gain x20, range 6.2A, ADC clock 250kHz, pin PA 5-6
{ 500mA, 78 ADC}, {5190mA, 856 ADC} => k=4690/778 m=30
Update source code with calculated values
3. Calculate time correction
For each timer interrupt a two bytes counter is incremented ( ctr1,ctr0 ). These two bytes are used to estimate one second ( measurement cycle ). If the interrupt were precisely matched to 9600 baud; ctr1 = 9600/256=37 and ctr0=128. Since this it not the case you have do real world adjustments...
Note start time on the display and a watch. Let it run for at least one hour. Estimate number of timer interrupts that occurred during this period and divide it by the real number of seconds (measured by watch).
Example,
Time passed according to display 20:07:00 time according to watch 20.19.00. In the source code the current number of timer interrupts per second is defined as NINT_SEC 9783. The total number of interrupts according to display is (20*3600+7*60)*9783 the number of seconds according to watch 20*3600+19*60
new NINT_SEC=(20*3600+7*60)*9783/(20*3600+19*60)=9687
Update in source code NINT_SEC 9687
-
12Step 12
Time to think inside the box...
1. Flash ATtiny without CALIBRATION defined ( see step 4 )
2. Verify everything works as expected
3. Assemble project box and solder connectors.
\(^_^)/ DONE !
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.