• Система автоматизации с открытым исходным кодом на базе esp8266/esp32 микроконтроллеров и приложения IoT Manager. Наша группа в Telegram

Проблемы с АЦП ESP32

Vaffanculo

New member
Привет всем.

Наблюдаю странное поведение АЦП на ESP32.
Схема собрана вот так.
1589281994368.png
Пробую все на китайском NodeMCU ESP-32S, питание от USB. Опорное напряжение 3.3в беру со встроенного в модуль преобразователя.
На ножке АЦП 800мв (если сосчитать по номиналам резисторов, то должно быть 755мв, но это к моему вопросу не относится).

Код вот такой.
C++:
extern "C" void app_main()
{
  printf( "DAC v.3 Calibrator starting...\n" );
  auto channel = ADC1_CHANNEL_6;
  adc1_config_width( ADC_WIDTH_BIT_12 );
  adc1_config_channel_atten( channel, ADC_ATTEN_DB_6 );

  TASK_DELAY( 100 );

  int counter = 0;
  while ( true ) {
    counter++;

    int measurement1 = adc1_get_raw( channel );
    int measurement2 = adc1_get_raw( channel );
    int measurement3 = adc1_get_raw( channel );
    int measurement4 = adc1_get_raw( channel );
    int average = ( measurement1 + measurement2 + measurement3 + measurement4 ) >> 2;

    printf( "Loop iteration #%d. ADC_1 CHANNEL_%d: %d\n", counter, channel, average );

    TASK_DELAY( 2 * 1000 );
  }
}
Однако наблюдаемые показания совершенно не те, которые я ожидал.
Loop iteration #59. ADC_1 CHANNEL_6: 0
Loop iteration #60. ADC_1 CHANNEL_6: 0
Loop iteration #61. ADC_1 CHANNEL_6: 0
Loop iteration #62. ADC_1 CHANNEL_6: 0
Loop iteration #63. ADC_1 CHANNEL_6: 0
Loop iteration #64. ADC_1 CHANNEL_6: 0
Loop iteration #65. ADC_1 CHANNEL_6: 0
Loop iteration #66. ADC_1 CHANNEL_6: 0
Loop iteration #67. ADC_1 CHANNEL_6: 0
Loop iteration #68. ADC_1 CHANNEL_6: 0
Loop iteration #69. ADC_1 CHANNEL_6: 0
Loop iteration #70. ADC_1 CHANNEL_6: 0
Loop iteration #71. ADC_1 CHANNEL_6: 2
Loop iteration #72. ADC_1 CHANNEL_6: 22
Loop iteration #73. ADC_1 CHANNEL_6: 37
Loop iteration #74. ADC_1 CHANNEL_6: 53
Loop iteration #75. ADC_1 CHANNEL_6: 52
Loop iteration #76. ADC_1 CHANNEL_6: 25
Loop iteration #77. ADC_1 CHANNEL_6: 30
Loop iteration #78. ADC_1 CHANNEL_6: 9
Loop iteration #79. ADC_1 CHANNEL_6: 4
Loop iteration #80. ADC_1 CHANNEL_6: 3
Loop iteration #81. ADC_1 CHANNEL_6: 1
Loop iteration #82. ADC_1 CHANNEL_6: 0
Loop iteration #83. ADC_1 CHANNEL_6: 0
Loop iteration #84. ADC_1 CHANNEL_6: 0
Loop iteration #85. ADC_1 CHANNEL_6: 0
Loop iteration #86. ADC_1 CHANNEL_6: 0
Loop iteration #87. ADC_1 CHANNEL_6: 0
Loop iteration #88. ADC_1 CHANNEL_6: 0
Loop iteration #89. ADC_1 CHANNEL_6: 0
Loop iteration #90. ADC_1 CHANNEL_6: 0
Loop iteration #91. ADC_1 CHANNEL_6: 0
Loop iteration #92. ADC_1 CHANNEL_6: 0
Loop iteration #93. ADC_1 CHANNEL_6: 0
Loop iteration #94. ADC_1 CHANNEL_6: 0
Loop iteration #95. ADC_1 CHANNEL_6: 0
Loop iteration #96. ADC_1 CHANNEL_6: 0
Loop iteration #97. ADC_1 CHANNEL_6: 0
Loop iteration #98. ADC_1 CHANNEL_6: 0
Loop iteration #99. ADC_1 CHANNEL_6: 0
Loop iteration #100. ADC_1 CHANNEL_6: 0
Loop iteration #101. ADC_1 CHANNEL_6: 0
Loop iteration #102. ADC_1 CHANNEL_6: 0
Loop iteration #103. ADC_1 CHANNEL_6: 0
Loop iteration #104. ADC_1 CHANNEL_6: 0
Loop iteration #105. ADC_1 CHANNEL_6: 0
Loop iteration #106. ADC_1 CHANNEL_6: 0
Loop iteration #107. ADC_1 CHANNEL_6: 0
Loop iteration #108. ADC_1 CHANNEL_6: 0
Loop iteration #109. ADC_1 CHANNEL_6: 0
Loop iteration #110. ADC_1 CHANNEL_6: 1
Loop iteration #111. ADC_1 CHANNEL_6: 7
Loop iteration #112. ADC_1 CHANNEL_6: 27
Loop iteration #113. ADC_1 CHANNEL_6: 22
Loop iteration #114. ADC_1 CHANNEL_6: 28
Loop iteration #115. ADC_1 CHANNEL_6: 47
Loop iteration #116. ADC_1 CHANNEL_6: 53
Loop iteration #117. ADC_1 CHANNEL_6: 55
Loop iteration #118. ADC_1 CHANNEL_6: 57
Loop iteration #119. ADC_1 CHANNEL_6: 52
Loop iteration #120. ADC_1 CHANNEL_6: 28
Loop iteration #121. ADC_1 CHANNEL_6: 38
Loop iteration #122. ADC_1 CHANNEL_6: 74
Loop iteration #123. ADC_1 CHANNEL_6: 98
Loop iteration #124. ADC_1 CHANNEL_6: 57
Loop iteration #125. ADC_1 CHANNEL_6: 88
Loop iteration #126. ADC_1 CHANNEL_6: 61
Loop iteration #127. ADC_1 CHANNEL_6: 112
Loop iteration #128. ADC_1 CHANNEL_6: 20
Loop iteration #129. ADC_1 CHANNEL_6: 16
Loop iteration #130. ADC_1 CHANNEL_6: 19
Loop iteration #131. ADC_1 CHANNEL_6: 119
Loop iteration #132. ADC_1 CHANNEL_6: 14
Loop iteration #133. ADC_1 CHANNEL_6: 8
Loop iteration #134. ADC_1 CHANNEL_6: 3
Loop iteration #135. ADC_1 CHANNEL_6: 0
Loop iteration #136. ADC_1 CHANNEL_6: 0
Loop iteration #137. ADC_1 CHANNEL_6: 0
Loop iteration #138. ADC_1 CHANNEL_6: 0
Loop iteration #139. ADC_1 CHANNEL_6: 0
Loop iteration #140. ADC_1 CHANNEL_6: 0
Loop iteration #141. ADC_1 CHANNEL_6: 0
Loop iteration #142. ADC_1 CHANNEL_6: 0
Loop iteration #143. ADC_1 CHANNEL_6: 0
Loop iteration #144. ADC_1 CHANNEL_6: 0
Loop iteration #145. ADC_1 CHANNEL_6: 0
Loop iteration #146. ADC_1 CHANNEL_6: 0
Loop iteration #147. ADC_1 CHANNEL_6: 0
Loop iteration #148. ADC_1 CHANNEL_6: 0
Loop iteration #149. ADC_1 CHANNEL_6: 0
Loop iteration #150. ADC_1 CHANNEL_6: 0
Loop iteration #151. ADC_1 CHANNEL_6: 0
Loop iteration #152. ADC_1 CHANNEL_6: 0
Loop iteration #153. ADC_1 CHANNEL_6: 0
Loop iteration #154. ADC_1 CHANNEL_6: 0
Loop iteration #155. ADC_1 CHANNEL_6: 0
Loop iteration #156. ADC_1 CHANNEL_6: 0
Loop iteration #157. ADC_1 CHANNEL_6: 0
Loop iteration #158. ADC_1 CHANNEL_6: 0
Loop iteration #159. ADC_1 CHANNEL_6: 0
Loop iteration #160. ADC_1 CHANNEL_6: 0
Loop iteration #161. ADC_1 CHANNEL_6: 0
Loop iteration #162. ADC_1 CHANNEL_6: 0
Loop iteration #163. ADC_1 CHANNEL_6: 0
Loop iteration #164. ADC_1 CHANNEL_6: 0
Loop iteration #165. ADC_1 CHANNEL_6: 0
Loop iteration #166. ADC_1 CHANNEL_6: 0
Loop iteration #167. ADC_1 CHANNEL_6: 0
Loop iteration #168. ADC_1 CHANNEL_6: 0
Loop iteration #169. ADC_1 CHANNEL_6: 2
Loop iteration #170. ADC_1 CHANNEL_6: 19
Loop iteration #171. ADC_1 CHANNEL_6: 35
Loop iteration #172. ADC_1 CHANNEL_6: 50
Loop iteration #173. ADC_1 CHANNEL_6: 56
Loop iteration #174. ADC_1 CHANNEL_6: 55
Loop iteration #175. ADC_1 CHANNEL_6: 34
Loop iteration #176. ADC_1 CHANNEL_6: 30
Loop iteration #177. ADC_1 CHANNEL_6: 19
Loop iteration #178. ADC_1 CHANNEL_6: 7
Loop iteration #179. ADC_1 CHANNEL_6: 2
Loop iteration #180. ADC_1 CHANNEL_6: 0
Loop iteration #181. ADC_1 CHANNEL_6: 0
Loop iteration #182. ADC_1 CHANNEL_6: 0
Loop iteration #183. ADC_1 CHANNEL_6: 0
Loop iteration #184. ADC_1 CHANNEL_6: 0
Loop iteration #185. ADC_1 CHANNEL_6: 0
Loop iteration #186. ADC_1 CHANNEL_6: 0
Loop iteration #187. ADC_1 CHANNEL_6: 0
Loop iteration #188. ADC_1 CHANNEL_6: 0
Loop iteration #189. ADC_1 CHANNEL_6: 0
Loop iteration #190. ADC_1 CHANNEL_6: 0
Loop iteration #191. ADC_1 CHANNEL_6: 2
Loop iteration #192. ADC_1 CHANNEL_6: 16
Loop iteration #193. ADC_1 CHANNEL_6: 33
Loop iteration #194. ADC_1 CHANNEL_6: 39
Loop iteration #195. ADC_1 CHANNEL_6: 54
Loop iteration #196. ADC_1 CHANNEL_6: 55
Loop iteration #197. ADC_1 CHANNEL_6: 55
Loop iteration #198. ADC_1 CHANNEL_6: 45
Loop iteration #199. ADC_1 CHANNEL_6: 30
Loop iteration #200. ADC_1 CHANNEL_6: 15
Loop iteration #201. ADC_1 CHANNEL_6: 1
Loop iteration #202. ADC_1 CHANNEL_6: 0
Loop iteration #203. ADC_1 CHANNEL_6: 0
Loop iteration #204. ADC_1 CHANNEL_6: 0
Loop iteration #205. ADC_1 CHANNEL_6: 0
Loop iteration #206. ADC_1 CHANNEL_6: 0
Loop iteration #207. ADC_1 CHANNEL_6: 0
Loop iteration #208. ADC_1 CHANNEL_6: 0
Loop iteration #209. ADC_1 CHANNEL_6: 0
Loop iteration #210. ADC_1 CHANNEL_6: 0
Loop iteration #211. ADC_1 CHANNEL_6: 0
Loop iteration #212. ADC_1 CHANNEL_6: 0
Loop iteration #213. ADC_1 CHANNEL_6: 0
Loop iteration #214. ADC_1 CHANNEL_6: 0
Loop iteration #215. ADC_1 CHANNEL_6: 0
Loop iteration #216. ADC_1 CHANNEL_6: 0
Loop iteration #217. ADC_1 CHANNEL_6: 0
Loop iteration #218. ADC_1 CHANNEL_6: 0
Loop iteration #219. ADC_1 CHANNEL_6: 0
Loop iteration #220. ADC_1 CHANNEL_6: 0
Как видно, большую часть времени считываются нули, потом значения начинают нарастать, потом убывают до нуля и снова долгое время идут нули, и потом все повторяется.
На разных каналах ADC1 картина одинаковая. Изменение уровня ослабления меняет только амплитуду, но характер поведения остается прежним.

В чем может быть проблема?
Спасибо.
 
Сверху Снизу