API and I2C Address
This article offers a detailed look at controlling DC and stepper motors using the FireBeetle Covers-DC Motor&Stepper Driver library, including communication protocols, API functions, and library installation.
Library
- Please download and install FireBeetle Covers-DC Motor&Stepper Driver library files.
- About Library installation.
Communication Protocol Description
It communicates with Microcontroller via IIC port, supports up 1000Hz refresh rate. IIC Address: 0x18.
API Description
Macro:
Object:
M1--->the first group DC motor--->[M1A(+),M1B(-)]
M2--->the second group DC motor--->[M2A(+),M1B(-)]
M3--->the third group DC motor--->[M3A(+),M3B(-)]
M4--->the fourth group DC motor--->[M4A(+),M4B(-)]
SA--->the group A stepper motor------>[M1A(A+),M1B(A-),M2A(B+),M2B(B-)]
SB--->the group A stepper motor ------>[M3A(A+),M3B(A-),M4A(B+),M4B(B-)]
Keyword Expansion:
CW: rotate in C.W.(Clockwise)
CCW: rotate in counter clockwise
CS (Chip Select) Address
A0: the first chip select address
A1: the second chip select address
A2: the third chip select address
A3: the fourth chip select address
Function:
The library used to control DC motor and stepper motor, including C.W rotation, C.C.W rotation, speed adjustment and stopping.
1. Open drive hardware of DC motor and stepper motor, read Product ID and Version ID.
void init();
2. Shutdown the drive hardware.void shutdown();
3. Stop the motor rotation.
void stop();
4. Set the DC motor rotation direction and start rotating.
void start(uint8_t dir);dir: set direction CW or CCW
5. Set angle, speed, direction of the stepper motor rotation and start rotating.
void start(float angle, uint16_t speed, uint8_t dir);angle: set the rotation resolution.
The maximum resolution is 0.9° which means the minimum rotate angle is 0.9°.
So that the motor won't rotate if the resolution set to be 0.1°and only rotate to 0.9° if the resolution set to be 1°.
Min: 0° (if the rotate angel set to be 0, the motor will keep rotating).
speed: set speed. The speed range is 0~1023. Set it to 0 and the rotate speed is 0r/min;set it to maximum 1023 and the rotate speed is 200r/min.
dir: set direction. dir=CW: rotate in C.W.(Clockwise) ; dir=CCW: rotate in CCW(anti-clockwise)
6. Speed control of DC motor & stepper motor
void speed(uint16_t val);val: set speed motor:0<=val<=4096 stepper:0<=val<=1023
Was this article helpful?
