@@ -15,29 +15,37 @@ Begin.ino
15
15
#define TOLERANCE 4.75 // Percent: 95.25% - 104.75%
16
16
17
17
// ----------------------------------------
18
- // Macros
18
+ // Hardware initialization functions
19
19
// ----------------------------------------
20
20
21
21
// ADC input
22
22
// Ra KOhms | Rb KOhms
23
23
// MAX_ADC_VOLTAGE -----/\/\/\/\-----+-----/\/\/\/\----- Ground
24
24
//
25
- #define ADC_ID_mV (RaK, RbK ) ((uint16_t )(MAX_ADC_VOLTAGE * RbK / (RaK + RbK)))
26
-
27
- // ----------------------------------------
28
- // Hardware initialization functions
29
- // ----------------------------------------
30
25
31
26
// Determine if the measured value matches the product ID value
32
- bool idWithAdc (uint16_t mvMeasured, uint16_t mvProduct )
27
+ bool idWithAdc (uint16_t mvMeasured, float resVcc, float resGnd )
33
28
{
34
29
uint16_t lowerThreshold;
30
+ float raK;
31
+ float rbK;
35
32
uint16_t upperThreshold;
33
+ float voltage;
34
+
35
+ // Compute the upper threshold
36
+ raK = resVcc * (1.0 - (TOLERANCE / 100 .));
37
+ rbK = resGnd * (1.0 + (TOLERANCE / 100 .));
38
+ voltage = MAX_ADC_VOLTAGE * rbK / (raK + rbK);
39
+ upperThreshold = (int )ceil (voltage);
40
+
41
+ // Compute the lower threshold
42
+ raK = (double )resVcc * (1.0 + (TOLERANCE / 100 .));
43
+ rbK = (double )resGnd * (1.0 - (TOLERANCE / 100 .));
44
+ voltage = MAX_ADC_VOLTAGE * rbK / (raK + rbK);
45
+ lowerThreshold = (int )floor (voltage);
36
46
37
47
// Return true if the mvMeasured value is within the tolerance range
38
48
// of the mvProduct value
39
- upperThreshold = (1.0 + (TOLERANCE / 100 .)) * mvProduct;
40
- lowerThreshold = (1.0 - (TOLERANCE / 100 .)) * mvProduct;
41
49
return (upperThreshold > mvMeasured) && (mvMeasured > lowerThreshold);
42
50
}
43
51
@@ -55,32 +63,32 @@ void identifyBoard()
55
63
56
64
// Order checks by millivolt values high to low
57
65
58
- // Facet L-Band Direct: 4.7/1 --> 551mV < 579mV < 607mV
59
- if (idWithAdc (idValue, ADC_ID_mV ( 4.7 , 1 ) ))
66
+ // Facet L-Band Direct: 4.7/1 --> 534mV < 578mV < 626mV
67
+ if (idWithAdc (idValue, 4.7 , 1 ))
60
68
productVariant = RTK_FACET_LBAND_DIRECT;
61
69
62
- // Express: 10/3.3 --> 779mV < 819mV < 858mV
63
- else if (idWithAdc (idValue, ADC_ID_mV ( 10 , 3.3 ) ))
70
+ // Express: 10/3.3 --> 761mV < 818mV < 879mV
71
+ else if (idWithAdc (idValue, 10 , 3.3 ))
64
72
productVariant = RTK_EXPRESS;
65
73
66
- // Reference Station: 20/10 --> 1047mV < 1100mV < 1153mV
67
- else if (idWithAdc (idValue, ADC_ID_mV ( 20 , 10 ) ))
74
+ // Reference Station: 20/10 --> 1031mV < 1100mV < 1171mV
75
+ else if (idWithAdc (idValue, 20 , 10 ))
68
76
{
69
77
productVariant = REFERENCE_STATION;
70
78
// We can't auto-detect the ZED version if the firmware is in configViaEthernet mode,
71
79
// so fake it here - otherwise messageSupported always returns false
72
80
zedFirmwareVersionInt = 112 ;
73
81
}
74
82
// Facet: 10/10 --> 1571mV < 1650mV < 1729mV
75
- else if (idWithAdc (idValue, ADC_ID_mV ( 10 , 10 ) ))
83
+ else if (idWithAdc (idValue, 10 , 10 ))
76
84
productVariant = RTK_FACET;
77
85
78
- // Facet L-Band: 10/20 --> 2095mV < 2200mV < 2305mV
79
- else if (idWithAdc (idValue, ADC_ID_mV ( 10 , 20 ) ))
86
+ // Facet L-Band: 10/20 --> 2129mV < 2200mV < 2269mV
87
+ else if (idWithAdc (idValue, 10 , 20 ))
80
88
productVariant = RTK_FACET_LBAND;
81
89
82
- // Express+: 3.3/10 --> 2363mV < 2481mV < 2600mV
83
- else if (idWithAdc (idValue, ADC_ID_mV ( 3.3 , 10 ) ))
90
+ // Express+: 3.3/10 --> 2421mV < 2481mV < 2539mV
91
+ else if (idWithAdc (idValue, 3.3 , 10 ))
84
92
productVariant = RTK_EXPRESS_PLUS;
85
93
86
94
// ID resistors do not exist for the following:
0 commit comments