筆者使用的是 ESP-8266 NodeMCU 開發板作測試,並使用電壓基準(Yokogawa 2553)作電壓輸出,接到 ESP8266 ADC 接腳,ADC 電壓作 0.1V 增加,並讀出 ESP8266 的轉換數值(10-bit / 0 ~ 1023 整數數值)。
ESP-12F ADC 類比數位轉換器測試 |
Input Voltage
|
Min ADC Reading
|
Max ADC Reading
|
Range
|
Average
|
|
0.00
|
V
|
3
|
9
|
6
|
6
|
0.10
|
V
|
34
|
39
|
5
|
37
|
0.20
|
V
|
68
|
70
|
2
|
69
|
0.30
|
V
|
98
|
104
|
6
|
101
|
0.40
|
V
|
134
|
136
|
2
|
135
|
0.50
|
V
|
169
|
171
|
2
|
170
|
0.60
|
V
|
200
|
206
|
6
|
203
|
0.70
|
V
|
233
|
237
|
4
|
235
|
0.80
|
V
|
265
|
270
|
5
|
268
|
0.90
|
V
|
298
|
304
|
6
|
301
|
1.00
|
V
|
331
|
337
|
6
|
334
|
1.10
|
V
|
365
|
369
|
4
|
367
|
1.20
|
V
|
397
|
401
|
4
|
399
|
1.30
|
V
|
433
|
437
|
4
|
435
|
1.40
|
V
|
464
|
469
|
5
|
467
|
1.50
|
V
|
498
|
502
|
4
|
500
|
1.60
|
V
|
530
|
535
|
5
|
533
|
1.70
|
V
|
562
|
568
|
6
|
565
|
1.80
|
V
|
596
|
600
|
4
|
598
|
1.90
|
V
|
628
|
633
|
5
|
631
|
2.00
|
V
|
661
|
666
|
5
|
664
|
2.10
|
V
|
693
|
700
|
7
|
697
|
2.20
|
V
|
729
|
734
|
5
|
732
|
2.30
|
V
|
761
|
763
|
2
|
762
|
2.40
|
V
|
794
|
799
|
5
|
797
|
2.50
|
V
|
828
|
834
|
6
|
831
|
2.60
|
V
|
859
|
867
|
8
|
863
|
2.70
|
V
|
893
|
898
|
5
|
896
|
2.80
|
V
|
926
|
931
|
5
|
929
|
2.90
|
V
|
958
|
966
|
8
|
962
|
3.00
|
V
|
993
|
1000
|
7
|
997
|
3.05
|
V
|
1009
|
1015
|
6
|
1012
|
3.06
|
V
|
1012
|
1020
|
8
|
1016
|
3.07
|
V
|
1016
|
1020
|
4
|
1018
|
3.08
|
V
|
1020
|
1023
|
3
|
1022
|
3.10
|
V
|
1023
|
1023
|
0
|
1023
|
3.20
|
V
|
1023
|
1023
|
0
|
1023
|
3.30
|
V
|
1023
|
1023
|
0
|
1023
|
ESP-12F ADC 類比數位轉換器測試程式:
int analogRead(uint8_t pin)
{
uint8_t low, high;
if (pin >= 14) pin -= 14; // allow
for channel or pin numbers
// set the analog reference (high two
bits of ADMUX) and select the
// channel (low 4 bits). this also sets ADLAR (left-adjust result)
// to 0 (the default).
ADMUX = (analog_reference << 6)
| (pin & 0x07);
// start the conversion
sbi(ADCSRA, ADSC);
// ADSC is cleared when the
conversion finishes
while (bit_is_set(ADCSRA, ADSC));
// we have to read ADCL first; doing
so locks both ADCL
// and ADCH until ADCH is read. reading ADCL second would
// cause the results of each
conversion to be discarded,
// as ADCL and ADCH would be locked
when it completed.
low
= ADCL;
high = ADCH;
// combine the two bytes
return (high << 8) | low;
}
|
ESP-12F ADC 類比數位轉換器測試程式結果圖示 |
ESP-12F ADC 類比數位轉換器測試程式顯示 |
2017年 12月 5日 天氣報告
氣溫:18.0度 @ 20:30
相對濕度:百分之 74%
天氣:多雲
沒有留言:
張貼留言