8pjaD

Encoder I2C expansion board (compatible with TI STM32 etc.)

 
Overview
Encoder Introduction:

Because the TI M0 series chips only have one quadrature encoder,
this project was created to solve this problem more elegantly.
(It's better than using GPIO external interrupts, and it doesn't consume CPU time!!!!)
It uses the WCH32V003 low-cost I2C module to obtain encoder data,
adapted to the FunTech TB6612 module (of course, this is just an adaptation).
Please note during installation! Be careful with the motor wiring and the wiring to the driver board! Be careful not to burn out the motor and the driver board as well.


Supports two encoders.
Supports 8-channel GPIO input/output and simultaneous I2C output.
3. Supports a maximum I2C speed of 400kHz.
It is not recommended to exceed 400kHz (referring to the host), otherwise, the machine may become unpleasant.
Please set the timeout when using hardware I2C. 6. The driver has been completely upgraded! It will no longer freeze and also includes a driver for the I2C data sending poll method!! 1.


Soldering process and precautions:
Regarding soldering precautions,

the power supply is taken from the encoder interface. Please only solder one 0-ohm resistor. 5V_1 For the 5V_2 silkscreen, please select only one
pin header. Please use a right-angled pin header.
Connect the LED to PD2 using a jumper cap for system indicator lights. (If you don't need it, you can add an extra I2C input/output pin, which will be on by default after system reset.)
Regarding Motor A and Motor B, the part enclosed in the ABchage silkscreen is used to adjust the encoder counting direction, because when the car moves forward, one encoder rotates clockwise and the other rotates counterclockwise (of course, the program can also adjust this, or you can add a negative sign after obtaining the information from the driver).
A 24MHz crystal oscillator is not used by default. If you have additional requirements for system stability, you can choose to solder it! Note: It is recommended to use 15~18pF capacitors; please do not use the 22pF capacitor in the schematic.
If you really want to use a crystal oscillator, please solder the select OSC silkscreen section using a 0-ohm resistor.
Regarding the debug port, this interface is provided for downloading and burning the program. Currently, the program does not use the URX interface, but it is still retained. WCH uses single-wire download, so you only need to connect the SWD interface.
VCC Supports 3.0V-5V input. When using an encoder to power the board, only connect GND; do not connect VCC, as this may damage your programmer!
If you require hardware reversal, please!!! Simply rotate the 0-ohm resistor from the ABchage silkscreen 90° and solder it vertically. (See
the attached image for a complete tutorial...) Program Notes: The program uses Mount River. This part is written in Studio and most people won't need it. TIM1 provides the encoder commutation information for motor A, and TIM2 provides it for motor B. If you move the motor to the back, it will cause TIM1 and motor A to be in reverse, so hardware or software commutation is required. Here's a method for software commutation; for hardware commutation, simply solder the resistors vertically (this is the third time I've mentioned rotating 90°). Regarding program download via serial port (ISP), unfortunately, because of this, there's no way to download via ISP using wchlink (recommended because the wch32 chip is also RISCV, requiring their official downloader). (Wait a minute! The good news is, you can directly purchase an extended version + LinkE downloader with 5 chips from the official flagship store for only 26.8. This way you can download whenever you want.) There are two download methods: you can choose to directly download using the Mount River compiler and open the project to download, as this is relatively simple and won't be discussed here (go to wch32) . Downloading a sample program will give you everything you need, and you can also learn how to use this chip. Use the official tools to download (I'm being lazy and just using screenshots ; you'll need a downloader!!!). Remember to download the HEX file. The driver usage guide uses CCS, but you can definitely use Keil! Just add the .h and .c files to the above. The header file is explained very clearly QAQ. Test images: 100kHz to get all encoder values; 400kHz to set GPIO status. I'm too lazy to set up two encoders. UART output encoder data. Regarding hardware, most can be purchased from JLCPCB. If you don't have a wchlinkE downloader, buy a development board from the official website www. For usage instructions, contact us. Special thanks to the contributor for refactoring the I2C driver code in this project (it was a huge help, thank you!). Also, please follow this Bilibili account if you can (follow the one above too!).

































参考设计图片
×
 
 
Search Datasheet?

Supported by EEWorld Datasheet

Forum More
Update:2026-03-26 02:20:45

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
community

Robot
development
community

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号