-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from ElectroMagus/featureupdate
Feature update for new release
- Loading branch information
Showing
7 changed files
with
68 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,50 +1,75 @@ | ||
|
||
# MX1508 Driver Board Library for ESP32/Arduino | ||
|
||
Arduino library for MX1508 dual DC motor driver compatible with the ESP32. | ||
|
||
This was originally from the wonderful AVR Library at https://github.com/Saeterncj/MX1508 This is my first library, so I'm also using their project as a skeleton for the extra information. | ||
|
||
|
||
This was inspired by [this wonderful AVR Library](https://github.com/Saeterncj/MX1508). This is my first library, so please feel free to provide feedback. | ||
|
||
It was modified for the ESP32 to use the LEDC Driver to send the PWM signals for speed control. Since the ESP32 can multiplex many of its pin functions, this library creates PWM Channels and assigns them to the pins specified. | ||
The MX1508 Motor Driver is a nice, low cost motor driver works from 2-10VDC, with a 1.5A operating current (2A peak). The driver is ideal for battery powered, smaller DC motors. | ||
|
||
The ESP32 to use the LEDC Driver to send the PWM signals for speed control. The ESP32 can multiplex many of its pin functions, this library creates PWM Channels and assigns them to the pins specified. | ||
|
||
The LEDC driver supports 8, 12 and 16 bit PWM resolution and can operate at a variety of frequencies allowing you to tune the driver to your particular motor. | ||
|
||
|
||
|
||
|
||
## Objective | ||
This library is made to simplify the use of MX1508. This Arduino Libary only requires a few lines of code to | ||
start controlling DC motors with mx1508. Resolutions of 8, 12, and 16 bits are supported for control of the motor speed. | ||
|
||
|
||
This library is made to simplify the use of MX1508 by allowing for the simple setup of motors and then using functions to drive them. | ||
``` | ||
#include <ESP32MX1508.h> | ||
#define PINA 9 | ||
#define PINB 10 | ||
#define CH1 0 // 16 Channels (0-15) are availible | ||
#define CH2 1 // Make sure each pin is a different channel and not in use by other PWM devices (servos, LED's, etc) | ||
#define CH1 0 // 16 Channels (0-15) are availible | ||
#define CH2 1 // Make sure each pin is a different channel and not in use by other PWM devices (servos, LED's, etc) | ||
// Optional Parameters | ||
#define RES 8 // Resolution in bits: 8 (0-255), 12 (0-4095), or 16 (0-65535) | ||
#define FREQ 5000 // PWM Frequency in Hz | ||
#define RES 8 // Resolution in bits: 8 (0-255), 12 (0-4095), or 16 (0-65535) | ||
#define FREQ 5000 // PWM Frequency in Hz | ||
MX1508 motorA(PINA,PINB, CH1, CH2); // Default- 8 bit resoluion at 2500 Hz | ||
//MX1508 motorA(PINA,PINB, CH1, CH2, RES); // Specify resolution | ||
//MX1508 motorA(PINA,PINB, CH1, CH2, RES, FREQ); // Specify resolution and frequency | ||
MX1508 motorA(PINA,PINB, CH1, CH2); // Default- 8 bit resoluion at 2500 Hz | ||
//MX1508 motorA(PINA,PINB, CH1, CH2, RES); // Specify resolution | ||
//MX1508 motorA(PINA,PINB, CH1, CH2, RES, FREQ); // Specify resolution and frequency | ||
void setup() {} | ||
void setup() { | ||
Serial.begin(9600); | ||
} | ||
void loop() { | ||
motorA.motorGo(200); // Pass the speed to the motor: 0-255 for 8 bit resolution | ||
delay(100); | ||
motorA.motorStop(); // Stop no argument | ||
motorA.motorStop(); // Soft Stop -no argument | ||
delay(100); | ||
motorA.motorRev(200); // Pass the speed to the motor: 0-255 for 8 bit resolution | ||
delay(100); | ||
MotorA.motorBrake(); // Hard Stop -no arguement | ||
} | ||
``` | ||
|
||
## Methods and Functions | ||
+ motorGo(pwmVal) | ||
- This sets the PWM val which is related to the speed, depending on selected resolution | ||
+ motorRev(pwmVal) | ||
- This sets the PWM val which is related to the speed, depending on selected resolution | ||
+ motorStop() | ||
- Simply stops the motor | ||
|
||
|
||
|
||
## Methods and Functions | ||
|
||
+ motorGo(pwmVal) | ||
|
||
- This sets the PWM val which is related to the speed, depending on selected resolution | ||
|
||
+ motorRev(pwmVal) | ||
|
||
+ This sets the PWM val which is related to the speed, depending on selected resolution | ||
|
||
+ motorStop() | ||
|
||
+ Stops the motor from moving in the current direction | ||
|
||
+ motorBrake() | ||
|
||
- Actively brakes the motor |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters