diff --git a/platformio.ini b/platformio.ini index fce8421..e57a0cb 100644 --- a/platformio.ini +++ b/platformio.ini @@ -17,7 +17,8 @@ board_build.mcu = esp32 upload_protocol = esptool lib_deps = fastled/FastLED @ ~3.6.0 - https://github.com/PolarRobotics/PR-Lib.git + adafruit/Adafruit PWM Servo Driver Library @ ^3.0.2 + https://github.com/PolarRobotics/PR-Lib.git#add-pwm-module #dependent on Adafruit PWM Servo Driver Library adafruit/Adafruit LIS3MDL@^1.2.4 extra_scripts = pre:pio_build_script.py @@ -26,6 +27,8 @@ build_src_filter = +<*> - - + -<.pio\libdeps\robot\PR-Lib\src\MotorInterface.h> + -<.pio\libdeps\robot\PR-Lib\src\MotorInterface.cpp> - - - diff --git a/src/PolarRobotics.h b/src/PolarRobotics.h index 75f5eb7..4b87fbf 100644 --- a/src/PolarRobotics.h +++ b/src/PolarRobotics.h @@ -31,6 +31,8 @@ #define M2_PIN 33 // | rightMotor | rightFront | #define M3_PIN 26 // | N/A | leftRear | #define M4_PIN 27 // | N/A | rightRear | +#define PWM0_PIN 0 +#define PWM1_PIN 1 // Pins for special bot features, conveyor, flywheels, etc... #define SPECBOT_PIN1 18 diff --git a/src/Robot/Kicker.h b/src/Robot/Kicker.h index da4e663..caf46fd 100644 --- a/src/Robot/Kicker.h +++ b/src/Robot/Kicker.h @@ -3,7 +3,6 @@ #ifndef KICKER_H #define KICKER_H -#include #include #include // ESP PS5 library, access using global instance `ps5` #include diff --git a/src/Robot/MotorControl.cpp b/src/Robot/MotorControl.cpp index 37bea59..9fb6a37 100644 --- a/src/Robot/MotorControl.cpp +++ b/src/Robot/MotorControl.cpp @@ -46,8 +46,6 @@ MotorControl::MotorControl() { lastRampTime = millis(); } - - /** * @brief setup the given pin to the next free channel, returns channel number or 255 if failure * @author Rhys Davies @@ -64,7 +62,7 @@ uint8_t MotorControl::setup(int mot_pin, MotorType type, bool has_encoder, float this->enc_a_pin = enc_a_chan_pin, this->enc_b_pin = enc_b_chan_pin; // Calculate the max rpm by multiplying the nominal motor RPM by the gear ratio - this->max_rpm = int(MOTOR_MAX_RPM_ARR[static_cast(this->motor_type)] * this->gear_ratio); + this->max_rpm = uint16_t(MOTOR_MAX_RPM_ARR[static_cast(this->motor_type)] * this->gear_ratio); // call the logic to attach the motor pin and setup, return 255 on an error return Motor.attach(mot_pin, MIN_PWM_US, MAX_PWM_US); diff --git a/src/Robot/MotorControl.h b/src/Robot/MotorControl.h index 9cb46f2..3ad5b02 100644 --- a/src/Robot/MotorControl.h +++ b/src/Robot/MotorControl.h @@ -1,9 +1,10 @@ #pragma once #include +// #include #include -// #include -#include +#include +//#include // Enum for Increasing or Decreasing Flywheel Speed @@ -17,8 +18,8 @@ class MotorControl { float gear_ratio; // the input / output gear ratio // Servo: - MotorInterface Motor; - + //MotorInterface Motor; + PWM_Module Motor; // for ramp float requestedRPM; float lastRampTime; @@ -42,7 +43,7 @@ class MotorControl { float omega; public: - int max_rpm; // the motor max rpm * the gear ratio + uint16_t max_rpm; // the motor max rpm * the gear ratio MotorControl(); uint8_t setup(int mot_pin, MotorType type = big_ampflow, bool has_encoder = false, float gearRatio = 1, int enc_a_chan_pin = -1, int enc_b_chan_pin = -1); // if no encoder, leave blank, will not attach pins diff --git a/src/main.cpp b/src/main.cpp index 3096670..2063d9d 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -128,7 +128,7 @@ void setup() { default: // Assume lineman robot = new Lineman(); drive = new Drive(lineman, driveParams); - drive->setupMotors(M1_PIN, M2_PIN); + drive->setupMotors(PWM0_PIN, PWM1_PIN); } // drive->printSetup(); @@ -229,7 +229,7 @@ void loop() { robot->action(); // DEBUGGING: - // drive->printDebugInfo(); // comment this line out to reduce compile time and memory usage + drive->printDebugInfo(); // comment this line out to reduce compile time and memory usage // drive->printCsvInfo(); // prints info to serial monitor in a csv (comma separated value) format // lights.printDebugInfo();