2938 views|34 replies

3386

Posts

0

Resources
The OP
 

[Hua Diao Experience] 10-line empty board hardware control pinpong library series test (Part 3) [Copy link]

 
 
This post was last edited by eagler8 on 2022-6-19 15:48

6. Basic GPIO Usage
The pin operation of the row and blank board is the same as the general syntax of pinpong.

[Hua Diao Experience] 01 Getting started with Xingkong Board
https://en.eeworld.com/bbs/thread-1206624-1-1.html
[Hua Diao Experience] 02 Simple use of Xingkong Board
https://en.eeworld.com/bbs/thread-1206649-1-1.html
[Hua Diao Experience] 03 Building the development environment of Xingkong Board Mind+
https://en.eeworld.com/bbs/thread-1206665-1-1.html
[Hua Diao Experience] 04 Testing the common functions of Xingkong Board

https://en.eeworld.com/bbs/thread-1206842-1-1.html
[Hua Diao Experience] 05 Building a development environment for Xingkong board: SSH connection and Jupyter programming

https://en.eeworld.com/bbs/thread-1207265-1-1.html
[Hua Diao Experience] 06 Building a Xingkong board development environment for Thonny programming

https://en.eeworld.com/bbs/thread-1207286-1-1.html
[Hua Diao Experience] 07 Building a Xingkong board development environment for VSCode programming

https://en.eeworld.com/bbs/thread-1207329-1-1.html

[Hua Diao Experience] 08 Series of tests on the hardware control pinpong library of Xingkong board (Part 1)

https://en.eeworld.com/bbs/thread-1207410-1-1.html

[Hua Diao Experience] 09 Series of tests on the hardware control pinpong library of Xingkong board (Part 2)

https://en.eeworld.com/bbs/thread-1207480-1-1.html

[Hua Diao Experience] 10-line empty board hardware control pinpong library series test (Part 3)

https://en.eeworld.com/bbs/thread-1207500-1-1.html

Latest reply

Oops, wrong number, it's stem...   Details Published on 2022-6-26 23:25
 
 

3386

Posts

0

Resources
2
 
This post was last edited by eagler8 on 2022-6-19 16:26

(1) Digital output
[Popular science knowledge point] The output of digital signals is high or low level. The load end needs a digital processing circuit to further convert the received pulses into the required signals. The binary digital signal is 010100101100101010100111..., and the waveform of the digital output is shown in the figure.

 
 
 

3386

Posts

0

Resources
3
 
This post was last edited by eagler8 on 2022-6-20 02:28

The Xingkong board has four 3-pin pins (P2.0 three-pin interface), including P21 (~A) \ P22 (~A) \ P23 (~) \ P24. See the figure for specific locations.

All pins support digital output with a level voltage of 3.3V.

 
 
 

3386

Posts

0

Resources
4
 
This post was last edited by eagler8 on 2022-6-20 02:10

[Hua Diao Experience] 10 Series of tests on the pinpong library for the hardware control of the Xingkong board (Part 3)
Basic GPIO usage of the Xingkong board - Mind+ code programming
Test program 14: Make the external LED light flash once per second
Experimental wiring: Connect an LED light to P21 of the Xingkong board

#【花雕体验】10 行空板硬件控制pinpong库的系列测试(之三)
#行空板基础GPIO使用——Mind+代码编程
#测试程序十四:外接LED灯一秒闪烁一次
#实验接线:在行空板P21接一个LED灯

# -*- coding: UTF-8 -*-
import time
from pinpong.board import Board,Pin

Board().begin()               #初始化
print("外接LED灯一秒闪烁一次") 

led = Pin(Pin.P21, Pin.OUT) #引脚初始化为电平输出

while True:
  #led.value(1) #输出高电平 方法1
  led.write_digital(1) #输出高电平 方法2
  print("1") #终端打印信息
  time.sleep(1) #等待1秒 保持状态

  #led.value(0) #输出低电平 方法1
  led.write_digital(0) #输出低电平 方法2
  print("0") #终端打印信息
  time.sleep(1) #等待1秒 保持状态

 
 
 

3386

Posts

0

Resources
5
 
This post was last edited by eagler8 on 2022-6-20 02:06

Experimental serial port return status

 
 
 

3386

Posts

0

Resources
6
 
This post was last edited by eagler8 on 2022-6-20 02:02

Experimental scene diagram

 
 
 

3386

Posts

0

Resources
7
 
This post was last edited by eagler8 on 2022-6-20 01:58

[Hua Diao Experience] 10 Series of tests on the hardware control pinpong library of the Xingkong board (Part 3)
Basic GPIO usage of the Xingkong board - Mind+ Graphical Programming
Test program 15: The external LED light flashes once every 0.5 seconds
Experimental wiring: Connect an LED light to P21 of the Xingkong board

 
 
 

3386

Posts

0

Resources
8
 

Experimental serial port return status

 
 
 

3386

Posts

0

Resources
9
 

(2) Digital input
[Popular Science Knowledge Point] Digital signals refer to signals described by a set of special states. The typical example is the signal represented by the most common binary digits. The fundamental reason for using binary digits to represent signals is that the circuit can only represent two states, namely, the on and off state of the circuit. In actual digital signal transmission, a certain range of information changes are usually classified as state 0 or state 1. This state setting greatly improves the anti-noise ability of digital signals. In addition, in terms of confidentiality, anti-interference, transmission quality, etc., digital signals are better than analog signals, and they save more signal transmission channel resources. Digital signal input is a logical code consisting of 0 and 1.

 
 
 

3386

Posts

0

Resources
10
 

The Xingkong board has four 3-pin pins (P2.0 three-pin interface), including P21 (~A) \ P22 (~A) \ P23 (~) \ P24. See the figure for specific locations.

All pins support digital input with a level voltage of 3.3V.

 
 
 

3386

Posts

0

Resources
11
 

[Hua Diao Experience] 10 Series of tests on the pinpong library for the hardware control of the Xingkong board (Part 3)
Basic GPIO usage of the Xingkong board - Mind+ code programming
Test program 16: Use a button to control the on and off of the external LED light of the Xingkong board
Experimental wiring: Connect an LED light to the Xingkong board P21 and a button module to the Xingkong board P22 interface

#【花雕体验】10 行空板硬件控制pinpong库的系列测试(之三)
#行空板基础GPIO使用——Mind+代码编程
#测试程序十六:使用按钮控制行空板外接LED灯的亮灭
#实验接线:在行空板P21接一个LED灯,在行空板P22接口接一个按钮模块

#-*- coding: UTF-8 -*-
import time
from pinpong.board import Board,Pin

Board().begin()               #初始化
print("使用按钮控制行空板外接LED灯的亮灭")


btn = Pin(Pin.P22, Pin.IN) #引脚初始化为电平输入
led = Pin(Pin.P21, Pin.OUT) #L灯引脚初始化为输出

while True:
  #v = btn.value()  #读取引脚电平方法1
  v = btn.read_digital()  #读取引脚电平方法2
  print(v)  #终端打印读取的电平状态
  #led.value(v)  #将按钮状态设置给led灯引脚  输出电平方法1
  led.write_digital(v) #将按钮状态设置给led灯引脚  输出电平方法2
  time.sleep(1)

 
 
 

3386

Posts

0

Resources
12
 

Experimental serial port return status

 
 
 

3386

Posts

0

Resources
13
 

Experimental scene diagram

 
 
 

3386

Posts

0

Resources
14
 

(3) Analog output (PWM)
[Popular Science Knowledge Point] Analog output is the analog quantity output by a computer or control system. In a single-chip microcomputer control system, there are many analog quantities in the output signal. They are obtained by processing the digital signal output by the single-chip microcomputer through the analog output channel. The task of the analog output channel is to convert the digital signal processed by the computer into an analog voltage or current signal through the data bus and isolation device, and then through the D/A converter, and then amplify it to drive the corresponding actuator, thereby achieving the purpose of control.

 
 
 

3386

Posts

0

Resources
15
 

[Popular Science Knowledge Point] PWM is a method of digitally encoding the level of an analog signal. Through the use of high-resolution counters, the duty cycle of a square wave is modulated to encode the level of a specific analog signal. PWM signals are still digital because at any given moment, the full-amplitude DC power supply is either completely present (ON) or completely absent (OFF). The voltage or current source is applied to the analog load in a repetitive pulse sequence of on (ON) or off (OFF). When it is on, the DC power supply is applied to the load, and when it is off, the power supply is disconnected. As long as the bandwidth is sufficient, any analog value can be encoded using PWM. One advantage of PWM is that the signals from the processor to the controlled system are in digital form, and then converted to digital and analog. The impact of noise can be minimized (just like a computer). Noise can only affect digital signals when it is strong enough to change logic 1 to logic 0 or logic 0 to logic 1. Enhanced noise resistance is another advantage of PWM over analog control, and this is also the main reason why PWM is used for communication at some point. Switching from analog signals to PWM can greatly extend the communication distance. At the receiving end, the modulating high frequency square wave can be filtered out and the signal restored to analog form through appropriate RC or LC networks.

 
 
 

3386

Posts

0

Resources
16
 

The Xingkong board supports 8-channel 10-bit PWM, corresponding to the pins: P21 P22 P23 (gold finger part P0 P2 P3 P10 P16)

Note: P8 and P2 share one PWM, and P9 and P10 share one PWM, so P8 and P9 can also use PWM, but P2 and P10 cannot be used.

 
 
 

3386

Posts

0

Resources
17
 

[Hua Diao Experience] 10 Series of tests on the hardware control pinpong library of the Xingkong board (Part 3)
Basic GPIO usage of the Xingkong board - Mind+ code programming
Test program seventeen: PWM output experiment, controlling the brightness change of the LED light
Experimental wiring: connect the external LED light to the P21 pin of the Xingkong board

#【花雕体验】10 行空板硬件控制pinpong库的系列测试(之三)
#行空板基础GPIO使用——Mind+代码编程
#测试程序十七:PWM输出实验,控制LED灯亮度变化
#实验接线:外置LED灯接到行空板P21引脚上

# -*- coding: UTF-8 -*-
import time
from pinpong.board import Board,Pin

Board().begin()               #初始化
print("PWM输出实验,控制LED灯亮度变化")

# PWM模拟输出引脚支持: P0  P2  P3  P10  P16  P21  P22  P23
#pwm21 = PWM(Pin(Pin.P21)) #将引脚传入PWM初始化  模拟输出方法1
pwm21 = Pin(Pin.P21, Pin.PWM) #初始化引脚为PWM模式 模拟输出方法2

while True:
    for i in range(1023):
        print(i)
        #pwm21.duty(i) #PWM输出 方法1
        pwm21.write_analog(i) #PWM输出 方法2
        time.sleep(0.05)

 
 
 

3386

Posts

0

Resources
18
 

Experimental serial port return status

 
 
 

3386

Posts

0

Resources
19
 

Experimental scene diagram

 
 
 

3386

Posts

0

Resources
20
 

[Hua Diao Experience] 10 Series of tests on the pinpong library for the hardware control of the Xingkong board (Part 3)
Basic GPIO usage of the Xingkong board - Mind+ Graphical Programming
Test program 18: PWM output experiment, controlling the brightness change of the LED light
Experimental wiring: connect the external LED light to the P21 pin of the Xingkong board

 
 
 

Just looking around
Find a datasheet?

EEWorld Datasheet Technical Support

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
快速回复 返回顶部 Return list