Jane Medium : This paper gives MicroPython Kernel Development Notes : Experimental tasks are embedded in the book Medium DAC Module related Some contents of software use cases .
key word
:MicroPython,mm32f3277,DAC
Software use case :
This part of the manuscript includes :
- The basis of DAC Voltage output test .
- Output sine wave signal .
- Position in manuscript :
stay MM32F3277 In the single chip microcomputer ,DAC The channel has two outputs , The corresponding ports are :
DAC0
:PA4 DAC1
:PA5 The following test code , Respectively in DAC Two channels output two different voltages .
from machine import DAC
dac0 = DAC(0)
dac1 = DAC(1)
print('Test DAC ...')
dac0.write_u16(0x8000)
dac1.write_u16(0x4000)
The above code demonstrates declaring two DAC Channel object , It's simple . adopt write_u16 The function change DAC Output voltage , Output voltage and written value n The relationship between is : V o u t = n 0 x F F F F × 3.3 V V_{out} = {n \over {0xFFFF}} \times 3.3V Vout=0xFFFFn×3.3V among 3.3V It is the analog reference voltage of single chip microcomputer .
Use a digital multimeter , Can be separately DAC0,DAC1 The corresponding output pin measures the corresponding voltage signal .
DAC0(PA4)
:1.654V DAC1(PA5)
:0.829V The following code will DAC The channel produces sine waves with opposite phases .
from machine import DAC
from math import *
dac0 = DAC(0)
dac1 = DAC(1)
print('Test DAC ...')
angle = [int((sin(i * pi * 2 / 100)+1.0)/2*0x6000+0x2000) for i in range(100)]
while True:
for a in angle:
dac0.write_u16(a)
dac1.write_u16(0xa000 - a)
Here are two DAC Sine wave voltage signal output by the channel .
▲ Two DAC Sine wave voltage signal of the channel
This paper gives MicroPython Kernel Development Notes : Experimental tasks are embedded in the book Medium DAC Module related Some contents of software use cases .
■ Links to related literature :
● Related chart Links :