- Create class 'controlledMotor':
- handles 'fading / ramp' of the pwm duty
- handles current limit **not implemented yet**
- has .handle function that is intended to be run very fast in another task
commands are sent via queue
- Create config.hpp
- Globally available instance motorLeft of controlledMotor class
- Create config.cpp
- Configuration of motordriver and control parameters for motorLeft
- Add config.cpp and motorctl.cpp to cmakelists
- main.cpp:
- create 'task_motorctl' which repeatedly runs motorLeft.handle()
- modify testing code for testing the new class
- comments
The fading/ramp capability of the new class was tested successfully
using a breakoutboard with an led.
23 lines
502 B
C++
23 lines
502 B
C++
#include "config.hpp"
|
|
|
|
|
|
//configure motor driver
|
|
single100a_config_t configDriverLeft = {
|
|
.gpio_pwm = GPIO_NUM_14,
|
|
.gpio_a = GPIO_NUM_12,
|
|
.gpio_b = GPIO_NUM_13,
|
|
.ledc_timer = LEDC_TIMER_0,
|
|
.ledc_channel = LEDC_CHANNEL_0,
|
|
.abInverted = true,
|
|
.resolution = LEDC_TIMER_11_BIT,
|
|
.pwmFreq = 10000
|
|
};
|
|
|
|
motorctl_config_t configControlLeft = {
|
|
.msFade = 5000,
|
|
.currentMax = 10
|
|
};
|
|
|
|
//create controlled motor
|
|
controlledMotor motorLeft(configDriverLeft, configControlLeft);
|