1.硬件图 
   
2.板载ADC 
(1)案例说明  ??Haas506开发板有两个ADC接口,可以使用板载ADC接口进行数据测量。  (2)main.py  
from driver import ADC
import utime as time
print("-------------------start adc test--------------------")
adc0 = ADC()
adc1=ADC()
for i in range(100):
    time.sleep(2)
    adc0.open("ADC0")
    adc1.open("ADC1")
    value0=adc0.read()
    value1=adc1.read()
    print("values of adc0 and adc1 ",value0,value1)
    adc0.close()
    adc1.close()
print("-------------------end adc test--------------------")
  
(3)board.json  
{
"version": "1.0.0",
"io": {
    "ADC0": {
            "type": "ADC",
            "port": 0,
            "sampling": 12000000
        },
    "ADC1": {
              "type": "ADC",
              "port": 1,
              "sampling": 12000000
        }
    },
"debugLevel": "DEBUG"
}
  
3.日志 
-------------------start adc test-------------------
values of adc0 and adc1 : 279 225
values of adc0 and adc1 : 242 1
values of adc0 and adc1 : 225 231
values of adc0 and adc1 : 222 236
values of adc0 and adc1 : 355 2287
values of adc0 and adc1 : 961 3184
values of adc0 and adc1 : 3184 2820
values of adc0 and adc1 : 3184 1522
values of adc0 and adc1 : 3184 843
values of adc0 and adc1 : 3184 501
...
-------------------end adc test---------------------
  
4.总结 
??本节介绍了如何使用haas506的driver库的ADC模块,进行数据测量。注意所测得的数据的单位是mv(毫伏)。 
                
                
                
        
        
    
 
 |