1
#ifndef TK_CALIBRATION_H
2
#define TK_CALIBRATION_H
4
* Attiny calibration header.
5
* This allows using a single set of hardcoded values across multiple projects.
7
* Copyright (C) 2015 Selene Scriven
9
* This program is free software: you can redistribute it and/or modify
10
* it under the terms of the GNU General Public License as published by
11
* the Free Software Foundation, either version 3 of the License, or
12
* (at your option) any later version.
14
* This program is distributed in the hope that it will be useful,
15
* but WITHOUT ANY WARRANTY; without even the implied warranty of
16
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
* GNU General Public License for more details.
19
* You should have received a copy of the GNU General Public License
20
* along with this program. If not, see <http://www.gnu.org/licenses/>.
25
/********************** Voltage ADC calibration **************************/
27
//-------------------------------------------------------------------------------------------
28
// The tables below represent the max value for reporting of that associated voltage value.
29
// For example, for 3.0V reporting in the 1000K table, the max value is 125, but the range
30
// for 3.0V is 122 to 125.
31
// The tables are all calculated values, the equations used:
33
// ADC_FACTOR = R2/ (R2+R1) * 256/1.1, Val = (V - D1) * ADC_FACTOR
35
//-------------------------------------------------------------------------------------------
38
#ifdef USING_1000K // GT-buck
39
// The ADC values we expect for specific voltages: 2.2v to 4.4v per cell. This is
40
// for 4S cells (17.6V max) using R1=1000K, R2=47K, D1=0, and direct connection from Batt+
41
// to R1, no diode in-between
49
#define ADC_28 119 // 0%
56
#define ADC_35 148 // 25% (3.5V)
58
#define ADC_37 157 // 50% (3.72V)
61
#define ADC_40 169 // 75% (3.95V)
63
#define ADC_42 178 // 100%
69
// The ADC values we expect for specific voltages: 4.4V to 8.8V (2.2v to 4.4v per cell). This is
70
// for using R1=360K/36K, R2=47K/4.7K, and direct connection from Batt+
71
// to R1, no diode in-between, with an LDO and a 2S battery configuration.
73
// MAX value for the voltage range:
80
#define ADC_28 153 // 0%
87
#define ADC_35 191 // 25% (3.5V)
89
#define ADC_37 202 // 50% (3.72V)
92
#define ADC_40 218 // 75% (3.95V)
94
#define ADC_42 228 // 100%
100
// The ADC values we expect for specific voltages: 2.2v to 4.4v. This is
101
// for using R1=220K/22K, R2=47K/4.7K, and direct connection from Batt+
102
// to R1, no diode in-between
109
#define ADC_28 117 // 0%
116
#define ADC_35 145 // 25% (3.5V)
118
#define ADC_37 154 // 50% (3.72V)
121
#define ADC_40 166 // 75% (3.95V)
123
#define ADC_42 174 // 100%
128
#define ADC_LOW ADC_30 // When do we start ramping down
129
#define ADC_CRIT ADC_28 // When do we shut the light off
131
#endif // TK_CALIBRATION_H