PWM
— 脉冲宽度调制¶
使用示例¶
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | # coding=utf-8
# This is a sample Python script.
from driver import PWM
print("------------haas eduk1 无对外的PWM接口---------")
print("-------------------pwm test--------------------")
pwm = PWM()
pwm.open("pwm3")
duty = pwm.getDuty()
freq = pwm.getFreq()
print(duty)
print(freq)
pwm.setConfig(3250000, 0.5)
duty = pwm.getDuty()
freq = pwm.getFreq()
print(duty)
print(freq)
pwm.close()
print("-------------------pwm end--------------------")
|
配置信息¶
board.jon 语法和功能的详细配置项信息请参考 BoardConfig — 硬件端口配置文件(board.json)详解 。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | {
"io": {
"pwm0": {
"type": "PWM",
"port": 0
},
"pwm1": {
"type": "PWM",
"port": 1
},
"pwm2": {
"type": "PWM",
"port": 2
},
"pwm3": {
"type": "PWM",
"port": 3
}
},
"debugLevel": "DEBUG"
}
|