程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
您现在的位置: 程式師世界 >> 編程語言 >  >> 更多編程語言 >> Python

Software use cases in micropython kernel development notebook: DAC related experiments

編輯:Python

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

The contents of the manuscript Objective record
Contents
Basic experiments Two ways DAC transport
Output voltage signal
Generate sinusoidal waveform total junction

 

  • The contents of this manuscript belong to MicroPython Kernel Development Notes : Experimental tasks are embedded in the book The content in .

Software use case :
This part of the manuscript includes :

  1. The basis of DAC Voltage output test .
  2. Output sine wave signal .
  • Position in manuscript :

 

§01 book Draft content


stay MM32F3277 In the single chip microcomputer ,DAC The channel has two outputs , The corresponding ports are :

DAC port :
DAC0:PA4
DAC1:PA5

One 、 Basic experiments

1、 Two ways DAC Output voltage signal

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 .

DAC Output voltage :
DAC0(PA4):1.654V
DAC1(PA5):0.829V

2、 Generate sinusoidal waveform

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

 

※ total junction ※


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 :

  • MicroPython Kernel Development Notes : Experimental tasks are embedded in the book

● Related chart Links :

  • Two DAC Sine wave voltage signal of the channel

  1. 上一篇文章:
  2. 下一篇文章:
Copyright © 程式師世界 All Rights Reserved