Test the basic functions of mm32 microphoton test circuit board

Zhuo Qing 2021-11-25 11:18:17
test basic functions mm32 mm

Jane Medium : For those from flying by MM32 MicroPython Module for supplementary testing . It summarizes some missing functions .

key word MicroPython,MM32, Fly by fly , Smart single chip microcomputer

 

§01 measuring Introduction to test plate


stay Test the flight by flight MM32F3277 MicroPython The basic functions of the development board For the from flying MM32 MicroPython The basic functions of the test module are preliminarily tested . Include GPIO, ADC, PWM as well as Timer The function of . Next, test other functions of the module one by one .

One 、 Improved Download Software

Use STM32 Bootloader Using serial port REPL The function is to download the program for the test board . Place the... On the test board SD After the card is removed , After reset, the module automatically enters the REPL state . The improved software passed the test “>>> ” The string determines whether to start sending CTRL+E. Using this condition improves STM32 Bootloader Download success rate .

▲ chart 1.1.1 download MicroPython The process of

▲ chart 1.1.1 download MicroPython The process of

Two 、SD The sample program in the card

Inside the module SD The following sample programs are included in :

  • ADC.py
  • CCD.py
  • ENCODER.py
  • GPIO.py
  • LCD180.py
  • main.py
  • MicroPython Driver layer interface definition .xlsx
  • PWM.py
  • SERVO.py
  • TIMER.py
  • UART.py

3、 ... and 、 take REPL Of RX Connect to B11

1、 Development board transformation

In order to be able to implement MicroPython Procedure and REPL Interaction between , Will debug port RX Connect to B11(UART,RX). This is mainly after transplantation MicroPython There is no implementation in Input function , So pass UART3 The reception comes from REPL The characters of , You can test instant noodles later .

2、STM32 command

Use as follows tsp Commands can be obtained from UART3 Received character :

stm32cmd('SENDC%s‘%string)

Yes MicroPython Receive... Through the following subroutine string.

while True:
if uart.any():
uart_str = uart.read()
print(uart_str)
servo.angle(int(uart_str))

 

§02 measuring Test module


One 、UART test

1、UART modular

UART1 Used MCU Of UART3.

UART Parameters :
port :UART3
RX:B11
TX:B10

▲ chart 2.1.1 UART Basic information of the module

▲ chart 2.1.1 UART Basic information of the module

▲ chart 2.1.2 B10,B11 Position on the backplane

▲ chart 2.1.2 B10,B11 Position on the backplane

2、 Test code

Cyclic output ‘U’, It should correspond 0b01010101 character .

from seekfree import UART,GPIO
uart = UART(115200)
def delay(loop=50000):
for _ in range(loop):
pass
print('Test UART.')
while True:
uart.write('U')
delay(100000)

3、 Measurement results

stay B10(TX) Measure to output character ‘U’ Corresponding voltage waveform :

▲ chart 2.1.3 B10 Output signal waveform

▲ chart 2.1.3 B10 Output signal waveform

But at the same time , stay REPL Received ‘1’ Character output . Here is REPL UART Output waveform .

▲ chart 2.1.4 REPL Output waveform

▲ chart 2.1.4 REPL Output waveform

Modify the transmitted character information to “HELLO”, It's in REPL The output will get ‘5’. This means that whenever uart When the output , At the same time REPL Port output UART Number of characters sent .

Tips : This should be the debugging information in the original migration process , Need to be removed .

while True:
uart.write('HELLO')
delay(100000)

4、 Test input and output

take B10,B11 Short it up , In this way, self transmitted characters can be received .

(1) Test code

from seekfree import UART,GPIO
uart = UART(115200)
def delay(loop=50000):
for _ in range(loop):
pass
print('Test UART.')
while True:
if uart.any():
uart_str = uart.read()
print(uart_str)
uart.write('HELLO')
delay(100000)

(2)REPL Output

▲ chart 2.1.5 REPL Window output results

▲ chart 2.1.5 REPL Window output results

Two 、SERVO measurement

1、 Hardware port

Output interface of steering gear :
MCU port :A15

▲ chart 2.2.1 SERVO Basic characteristics

▲ chart 2.2.1 SERVO Basic characteristics

2、 The output signal

(1)Angle=0 Output pulse

angle=0 when , The output pulse width is 0.5ms.
▲ chart 2.2.2 angle = 0 Corresponding servo Pulse of

▲ chart 2.2.2 angle = 0 Corresponding servo Pulse of

(2)Angle=180 Output pulse

angle = 180, The width of the output pulse is 2.5ms.

▲ chart 2.2.3 angle = 180 Corresponding servo Pulse of

▲ chart 2.2.3 angle = 180 Corresponding servo Pulse of

3、 Test different angle

By setting angle from 0 ~ 180, measurement SERVO Pulse average voltage . As shown in the figure below .

You can see that except for a few measurement jitters , The average value of the output voltage increases with angle Linear rise .
▲ chart 2.2.4 Different ANGLE Set the next measurement SERVO Pulse average voltage

▲ chart 2.2.4 Different ANGLE Set the next measurement SERVO Pulse average voltage

explain : Later, it is proved by experiments that , The downward third jitter in the above curve , It comes from the fact that the acceptance string does not fully receive the setting parameters 3 Characters . If will judge Change to uart.any() >= 3, This jitter can be eliminated .

4、 Drive the steering gear

(1) Test code

from seekfree import SERVO,GPIO,UART
servo = SERVO(50)
uart = UART(115200)
dir = 1
n = 0
count = 0x2ff
led1 = GPIO(0x1d, 1, 0)
led2 = GPIO(0x72, 1, 0)
servo.angle(180)
print("Test Servo..")
flag = 1
while True:
if uart.any():
uart_str = uart.read()
print(uart_str)
servo.angle(int(uart_str))
#--------------------------------------------------------
while count != 0:
count -= 1
count = 0x2ff
if flag == 0:
led1.high()
led2.low()
flag = 1
else:
led1.low()
led2.high()
flag = 0
#--------------------------------------------------------
if dir == 1:
n += 1
if n >= 180:
dir = 0
else:
n -= 1
if n <= 0:
dir = 1
servo.angle(n)

(2) Steering gear movement

▲ chart 2.2.5 Control the motion of the steering gear

▲ chart 2.2.5 Control the motion of the steering gear

3、 ... and 、LCD180 test

1、HELP Information

module : LCD180
---------------------------------------------------------------------------------
func | explain
---------------------------------------------------------------------------------
LCD180() | Parameter up to one, at least zero.
LCD180(dir) | dir[[0-PORTAIT_U,1-PORTAIT_D,2-CROSSWISE_R,3-CROSSWISE_L]], default dir = 0.
LCD180(dir, pen_color) | pen_color[RGB565], default pen_color = BLACK<0x0000>.
LCD180(dir, pen_color, bgcolor)| bgcolor[RGB565], default bgcolor = WHITE<0xFFFF>.
---------------------------------------------------------------------------------
LCD180.help() | No parameter. Module prompt.
---------------------------------------------------------------------------------
LCD180.info() | No parameter. Module parameter info.
---------------------------------------------------------------------------------
LCD180.full() | Parameter up to one, at least zero.
LCD180.full(color) | color[RGB565]
| Enter with no Parameter will full whith bgcolor.
---------------------------------------------------------------------------------
LCD180.show_image \ | Parameter up to six, at least three.
(img, length, wide, x, y, zoom)| img - image, must be entered.
| length - image length, must be entered.
| wide - image wide, must be entered.
| x - display offset for x axial, default 0, should be less than X_MAX.
| y - display offset for y axial, default 0, should be less than Y_MAX.
| zoom - the ratio of display reduction, default 0, scale down the length and width.
---------------------------------------------------------------------------------
LCD180.show_wave \ | Parameter up to six, at least three.
(wave, length, max, | wave - wave, must be entered.
x, y, zoom_x, zoom_y) | length - wave length, must be entered.
| max - wave max value, must be entered.
| x - display offset for x axial, default 0, should be less than X_MAX.
| y - display offset for y axial, default 0, should be less than Y_MAX.
| zoom_x - the ratio of display reduction, default 0, scale down the length.
| zoom_y - the ratio of display reduction, default 0, scale down the max.
---------------------------------------------------------------------------------
LCD180.show_str \ | Parameter up to six, at least three.
(str, x, y, color, sparency) | str - string, must be entered.
| x - display offset for x axial, default 0, should be less than X_MAX.
| y - display offset for y axial, default 0, should be less than Y_MAX.
| color - string color, RGB565 data, default bgcolor.
| sparency- background transparent, default is 0-disable, set 1-enable.
---------------------------------------------------------------------------------

2、 Fill color

from seekfree import GPIO,UART,LCD180
dis = LCD180(0)
def delay(loop=50000):
for _ in range(loop):
pass
while True:
delay()
dis.full(dis.BLUE)
delay()
dis.full(dis.RED)

▲ chart 2.3.1 Repeat fill color

▲ chart 2.3.1 Repeat fill color

3、 display string

from seekfree import GPIO,UART,LCD180
dis = LCD180(0)
dis.full(dis.BLUE)
def delay(loop=50000):
for _ in range(loop):
pass
dis.show_str('hello', 0, 0)
count = 0
while True:
dis.show_str('COUNT:%04d'%count, 10, 100)
count += 1
delay(10000)

▲ chart 2.3.2 display string

▲ chart 2.3.2 display string

4、 Display voltage waveform

from ADC Read voltage , And displayed in LCD in .

from seekfree import GPIO,UART,LCD180,ADC
adc = ADC(0)
adc.channel_init(adc.A4)
dis = LCD180(1)
dis.full(dis.WHITE)
def delay(loop=50000):
for _ in range(loop):
pass
dis.show_str('hello', 0, 0)
count = 0
buf = [0] * 128
while True:
for i in range(128):
value = adc.value(adc.A4)
buf[i] = value//16
delay(100)
dis.show_wave(bytes(buf), 128, 0xff, 0, 0, 0, 2)
delay(10000)

▲ chart 2.3.3 Displayed waveform

▲ chart 2.3.3 Displayed waveform

Four 、CCD test

1、 Hardware interface

▲ chart 2.4.1 CCD Interface

▲ chart 2.4.1 CCD Interface

▲ chart 2.4.2 CCD Interface

▲ chart 2.4.2 CCD Interface

▲ chart 2.4.3 CCD Interface

▲ chart 2.4.3 CCD Interface

2、 Display the acquisition results

1 Test code

from seekfree import GPIO,UART,LCD180,ADC,CCD
dis = LCD180(1)
dis.full(dis.WHITE)
def delay(loop=50000):
for _ in range(loop):
pass
ccd = CCD(1)
while True:
dis.show_wave(ccd, 128, 0xff, 0, 0, 0, 2)
delay(10000)

(2) test result

▲ chart 2.4.4 Use LCD Show CCD Data collected

▲ chart 2.4.4 Use LCD Show CCD Data collected

5、 ... and 、 Encoder

1、 Encoder interface

▲ chart 2.5.1 Encoder interface

▲ chart 2.5.1 Encoder interface

▲ chart 2.5.2 Encoder interface

▲ chart 2.5.2 Encoder interface

▲ chart 2.5.3 Encoder interface

▲ chart 2.5.3 Encoder interface

▲ chart A2.5.4 Coding interface

▲ chart A2.5.4 Coding interface

2、 Quadrature coded signal

By DC motor HALL The encoder obtains the corresponding speed signal .

▲ chart 2.5.4 DC motor output speed signal

▲ chart 2.5.4 DC motor output speed signal

▲ chart 2.5.6 DC motor

▲ chart 2.5.6 DC motor

stay STM32 Graduation project : be based on stm32c8t6 Production tutorial of ramp traveling patrol car The basic parameters of the motor are given .

  • model MG513 p30 12v
  • One turn 390 Pulse
  • Reduction ratio 1 Than 30

▲ chart 2.5.5 Two orthogonal speed coded signals

▲ chart 2.5.5 Two orthogonal speed coded signals

--------------------------------------------------------------------------------
module : ENCODER
---------------------------------------------------------------------------------
func | explain
---------------------------------------------------------------------------------
ENCODER(ch, mode) | Constructor, ch [1-2], mode[1-2]<QuadDec, Incremental>.
---------------------------------------------------------------------------------
ENCODER.help() | No parameter. Module prompt.
---------------------------------------------------------------------------------
ENCODER.value() | No parameter. Get encoder count.
---------------------------------------------------------------------------------
ENCODER.reset() | No parameter. Reset encoder count.
---------------------------------------------------------------------------------
ENCODER.enable() | No parameter. Module enable.
---------------------------------------------------------------------------------
ENCODER.disable() | No parameter. Module disable.
---------------------------------------------------------------------------------

3、 Test code

(1) Basic test code

from seekfree import ENCODER,GPIO,TIMER
encoder1 = ENCODER(2, 1)
n = 0
flag = 0
def time1_callback(s):
global n, flag
n = encoder1.value()
encoder1.reset()
flag = 1
time1 = TIMER(500)
time1.callback(time1_callback)
while True:
if flag:
flag = 0
print(n)

(2) Interactive test code

from seekfree import ENCODER,GPIO,TIMER,UART
encoder1 = ENCODER(2, 1)
n = 0
flag = 0
uart1 = UART(115200)
def time1_callback(s):
global n, flag
n = encoder1.value()
encoder1.reset()
flag = 1
time1 = TIMER(100)
time1.callback(time1_callback)
while True:
if uart1.any() >= 1:
strread = uart1.read()
print('%c'%0)
print(n)

4、 Different voltages correspond to different speeds

Apply different voltages to the motor to be tested , Measure the speed signal read out by the corresponding encoder .

from headm import *
from tsmodule.tsvisa import *
from tsmodule.tsstm32 import *
data = stm32data()
dh1766volt(0)
time.sleep(5)
vdim = linspace(0, 12, 100)
sdim = []
for v in vdim:
dh1766volt(v)
time.sleep(.5)
data = stm32data()[0]
printff(v, data)
sdim.append(data)
tspsave('measure', vdim=vdim, sdim=sdim)
plt.plot(vdim, sdim)
plt.xlabel("Voltage(V)")
plt.ylabel("Speed")
plt.grid(True)
plt.tight_layout()
plt.show()

▲ chart 2.5.7 Different voltages correspond to different speeds

▲ chart 2.5.7 Different voltages correspond to different speeds

5、 Measure the speed ratio

▲ chart 2.5.9 Measure the speed of the motor output shaft

▲ chart 2.5.9 Measure the speed of the motor output shaft

▲ chart 2.5.10 HALL Output waveform

▲ chart 2.5.10 HALL Output waveform

Measure the output shaft HALL Magnetic field intensity change frequency :6.15Hz.

Measure the of the motor HALL Output pulse frequency :2.216kHz.

therefore , The ratio of the number of pulses to the rotation of the output shaft : 2.216 6.15 = 360.3 { {2.216} \over {6.15}} = 360.3 6.152.216=360.3

▲ chart 2.5.11 The motor HALL Output waveform

▲ chart 2.5.11 The motor HALL Output waveform

 

measuring Try to summarize ※


For those from flying by MM32 MicroPython Perform additional tests on the test circuit board . except Encoder outside , Other modules are working relatively well .

Tests so far , You can see that there are still some problems to be determined in the transplanted version :

  • Directly in MicroPython Environment for SD Card file for operation ;
  • Floating point number 、MATH Related functions ;
  • about MCU Medium SPI,I2C,CAN, Inside FLASH The operation still lacks support ;
  • Lack of MCU Registers in the are accessed directly , This can be done in addition to supporting functions , Add additional features ;


■ Links to related literature :

● Related chart Links :

版权声明
本文为[Zhuo Qing]所创,转载请带上原文链接,感谢
https://pythonmana.com/2021/11/20211109010513916Q.html

  1. Python basic syntax -- Boolean operation, break, continue, pass
  2. Python basic syntax -- loop
  3. Python first experience - efficient office, data analysis, crawler
  4. Modulenotfounderror: no module named 'Django summernote details
  5. Key points for Django to make personal blog website
  6. Path setting of templates in Django settings
  7. Leetcode 1611. Minimum one bit operations to make integers Zero (Python)
  8. Directory C: \ users \ a \ desktop \ Django_ The blog master is registered as the GIT root, but no git repository details are found there
  9. Django. Core. Exceptions. Improveconfigured: application labels aren't unique, duplicates: admin
  10. How to verify that Django has created the project details correctly
  11. How to create a database when using Django to construct a website
  12. The solution of using Django framework to create project in Windows system
  13. Running Python virtual environment on win10 system to execute ll_ Env \ scripts \ activate: unable to load file elaboration scheme
  14. Detailed explanation of constructing virtual environment with Django in Python 3
  15. Python implementation of affine cipher
  16. RC4 Python implementation
  17. Simple: Python_ Automatic body temperature clock
  18. 用python把两个csv中的日期的列提出年,做出新的一列,再把两个csv表格按照新做出的日期这列和ID号合并为一个表。
  19. python中类实例化后,其对象无法被其他模块调用方法
  20. [JSON] - Python creates JSON file format
  21. Utilisez Python pour proposer l'année de la colonne de date dans les deux CSV, faire une nouvelle colonne, puis combiner les deux tableaux CSV en un seul tableau avec la colonne de date et le numéro d'identification.
  22. 关于#python#的问题,请各位专家解答!
  23. ***
  24. ***
  25. 關於#python#的問題,請各比特專家解答!
  26. S'il vous plaît répondre aux questions de Python!
  27. About the import of Python class
  28. Magic Python property decorator: 1 line of code makes Python methods become properties in seconds
  29. Python 音频调整音量(附代码) | Python工具
  30. Python programming ideas [series of articles]
  31. Python crawler programming idea (67): modify nodes using pyquery
  32. Python crawler programming idea (66): using pyquery to obtain node information
  33. Python crawler programming idea (65): find nodes using pyquery
  34. Python crawler programming idea (64): using CSS selectors in pyquery
  35. Python crawler programming idea (63): basic knowledge of pyquery
  36. Python crawler programming idea (62): project practice: capturing cool dog online red song list
  37. Python crawler programming idea (61): project practice: capturing rental information
  38. Python crawler programming idea (60): get CSS selector code through browser
  39. Python爬虫编程思想(85):在Python中使用非关系型数据库
  40. Volume de réglage audio Python (avec Code) | outils Python
  41. Python crawler programming idea (59): get attribute value and text with beautiful soup CSS selector
  42. Python crawler programming idea (58): nested selection nodes with beautiful soup CSS selectors
  43. Python crawler programming idea (57): basic usage of CSS selector in beautiful soup
  44. Python crawler programming idea (56): find method of beautiful soup method selector
  45. Python crawler programming idea (55): find of beautiful soup method selector_ All method
  46. Python crawler programming idea (54): use beautiful soup to select sibling nodes
  47. Python crawler programming idea (53): use beautiful soup to select the parent node
  48. Django3.0 solves the problem of error reporting in reverse parsing
  49. Precautions for Python crawler
  50. Python 3 crawler series (1) -- climbing blind date websites
  51. Python到底是什么?为什么要学Python?
  52. #yyds干货盘点#Pandas数据清洗实用指南
  53. Python打包exe文件无法运行
  54. Two common ways to save files in Python
  55. #yyds幹貨盤點#Pandas數據清洗實用指南
  56. Yyds Dry Inventory pandas Data Cleaning Practical Guide
  57. PYTHON用LSTM长短期记忆神经网络的参数优化方法预测时间序列洗发水销售数据
  58. Python集成学习:自己编写构建AdaBoost分类模型可视化决策边界及sklearn包调用比较
  59. Python 3 makes a search software
  60. Python 3 simulated microblog login