yahboom
HomeLearn
Solution
Blog
Online Store
About Us
EN/中文
AT8236 2-Channel Motor Driver Module📖
1.Introduction
  • Introduction
2.Tutorials
  • 2.1 For STM32
  • 2.2 For Arduino
  • 2.3 For RaspberryPi
  • 2.4 For RaspberryPi Pico
  • 2.5 For jetson nano
  • 2.6.1 For RDK X3-Lite Version
  • 2.6.2 For RDK X3-Standard Version
  • 2.7.For MSPM0G3507
  • 2.8.For MSPM0G3519new
Download
  • Code
  • SCH_Model
Download ZIP

Welcome to AT8236 2-Channel Motor Driver Module repository

2.6.2 For RDK X3-Standard Version

Standard Version Tutorial

 

1. Environment preparation

Write the official horizon image to the motherboard, and install the WiringPi tool on RDK_X3 after boot

sudo apt update
sudo apt install git-core

Get the WiringPi source code online via git and execute the following command

xxxxxxxxxx
git clone https://gitee.com/study-dp/WiringPi.git

Go to the WiringPi directory to install WiringPi. Run the build.sh script to automatically compile and install the WiringPi library

xxxxxxxxxx
cd WiringPi
./build

Create a working folder on the motherboard and paste the motor.c file in the file

xxxxxxxxxx
cd && mkdir motor && cd motor

Compile the motor.c file. If you do not install the gcc compiler, please install the gcc compiler by yourself

xxxxxxxxxx
gcc -o motor motor.c -lwiringPi

You can see that the terminal displays a green executable file

Refer to the cable preparation below, after the cable is connected, you can directly run the file

xxxxxxxxxx
sudo ./motor

2. Prepare cable connections

Connect the AT8236 thin module to the RDK-X3 according to the wiring diagram. The battery is connected to the power input port of the module. (VM and GND are the power input ports of the module. ), the input voltage range is 5~12V, which is determined according to the working voltage of the motor.

Where M+ and M- are the two power inputs of the motor respectively, which are determined according to their own motor pins

RDK-X3(40pin)Double circuit motor drive board|Double circuit motor drive boardmotor
GPIO6AIN1|AO1M+
GPIO5AIN2|AO2M-
GPIO30BIN1|BO1M+
GPIO27BIN2|BO2M-
3V3VCC|  

*Note: The line sequence of the motor interface must correspond to the motor pin! No match will burn the drive board!! *

3. Main code display
​x
#include <stdio.h>
#include <wiringPi.h>
#include <softPwm.h>

/* GPIO config define */
#define AIN1 6
#define AIN2 5
#define BIN1 30
#define BIN2 27

/* Parameter define */
static int high_edge_time = 0;     //初始化设定值  initialValue
static int cycle_time     = 500;   //pwm范围0~500     pwmRange

void forward(void)
{
    softPwmWrite(AIN1, 500);       // duty = 500/cycle_time
    softPwmWrite(AIN2, 0);
    softPwmWrite(BIN1, 500);
    softPwmWrite(BIN2, 0);
}

void back(void)
{
    softPwmWrite(AIN1, 0); 
    softPwmWrite(AIN2, 500);       // duty = 500/cycle_time
    softPwmWrite(BIN1, 0);
    softPwmWrite(BIN2, 500);
}

void stop(void)
{
    softPwmWrite(AIN1, 0);         // duty = 0/cycle_time
    softPwmWrite(AIN2, 0);
    softPwmWrite(BIN1, 0);
    softPwmWrite(BIN2, 0);
}

int main (void)
{
    /* Initial gpio with chip pin ,if use mapping pin -> wiringPiSetup*/
    wiringPiSetupGpio () ;

    printf("cycle_time:%d\n", cycle_time);
    pinMode(AIN1, OUTPUT);
    pinMode(AIN2, OUTPUT);
    pinMode(BIN1, OUTPUT);
    pinMode(BIN2, OUTPUT);
    softPwmCreate(AIN1, high_edge_time, cycle_time);
    softPwmCreate(AIN2, high_edge_time, cycle_time);
    softPwmCreate(BIN1, high_edge_time, cycle_time);
    softPwmCreate(BIN2, high_edge_time, cycle_time);

    /* Control pwm */
    forward();
    printf("forward\n");
    delay (5000);
    stop();
    delay (1000);
    back();
    printf("back\n");
    delay (5000);
    stop();
    delay (1000);
    printf("over\n"); 
    
}

Horizon official wiringpi usage reference:https://gitee.com/study-dp/WiringPi

wiringpi official documentation: http://wiringpi.com/reference/software-pwm-library/

4. Experimental results

Run the program, drive board drive motor forward 5s, then reverse 5s.

For RDK X3-Lite Version
For MSPM0G3507

COMPANY

  • About us
  • Team Style
  • Blog

LEARNING & EXPLORATION

  • Tutorials
  • Edge AI hardware
  • Educational robots
  • Embedded intelligent hardware

WHERE TO BUY

  • Yahboom Online Store
  • Amazon
  • Alibaba
  • AliExpress
  • Mercado

TECHNOLOGY SUPPORT

  • Email: support@yahboom.com

BE A DISTRIBUTOR

  • Email: sales@yahboom.com
QR Code
QR Code

Copyright © 2017-2026 Yahboom. All Rights Reserved.

EN/中文