Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 26 additions & 12 deletions main/Kconfig.projbuild
Original file line number Diff line number Diff line change
@@ -1,19 +1,33 @@
menu "Example Configuration"

choice EXAMPLE_HARDWARE
prompt "Hardware"
default EXAMPLE_HARDWARE_MOTORGO_MINI
help
Select the hardware to run this example on.
choice EXAMPLE_HARDWARE
prompt "Hardware"
default EXAMPLE_HARDWARE_MOTORGO_MINI
help
Select the hardware to run this example on.

config EXAMPLE_HARDWARE_MOTORGO_MINI
depends on IDF_TARGET_ESP32S3
bool "MotorGo Mini"
config EXAMPLE_HARDWARE_MOTORGO_MINI
depends on IDF_TARGET_ESP32S3
bool "MotorGo Mini"

config EXAMPLE_HARDWARE_TEST_STAND
depends on IDF_TARGET_ESP32S3
bool "BLDC Motor Test Stand (TinyS3)"
config EXAMPLE_HARDWARE_TEST_STAND
depends on IDF_TARGET_ESP32S3
bool "BLDC Motor Test Stand (TinyS3)"

endchoice
endchoice

choice EXAMPLE_BLDC_MOTOR
prompt "Which BLDC motor to control"
default EXAMPLE_BLDC_MOTOR_1
depends on EXAMPLE_HARDWARE_MOTORGO_MINI
help
Select the BLDC motor to control. This is only used for the MotorGo Mini hardware, which has two motors.

config EXAMPLE_BLDC_MOTOR_1
bool "Motor 1"
config EXAMPLE_BLDC_MOTOR_2
bool "Motor 2"

endchoice

endmenu
33 changes: 31 additions & 2 deletions main/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,38 @@ extern "C" void app_main(void) {
logger.info("Using MotorGo Mini hardware configuration");
// we don't want to init both motors, so we'll pass in auto_init=false
auto &motorgo_mini = espp::MotorGoMini::get();
auto motor1_config = motorgo_mini.default_motor1_config;
motorgo_mini.init_motor_channel_1(motor1_config);

#if CONFIG_EXAMPLE_BLDC_MOTOR_1
#pragma message("Using MotorGo Mini Motor 1")
logger.info("Configuring Motor 1");
auto motor_config = motorgo_mini.default_motor1_config;
#elif CONFIG_EXAMPLE_BLDC_MOTOR_2
#pragma message("Using MotorGo Mini Motor 2")
logger.info("Configuring Motor 2");
auto motor_config = motorgo_mini.default_motor2_config;
Comment thread
finger563 marked this conversation as resolved.
#else
#error "No motor selected"
#endif

// velocity PID config:
motor_config.velocity_pid_config.kp = 0.010f;
motor_config.velocity_pid_config.ki = 0.100f;
motor_config.velocity_pid_config.kd = 0.000f;
// angle PID config:
motor_config.angle_pid_config.kp = 5.000f;
motor_config.angle_pid_config.ki = 1.000f;
motor_config.angle_pid_config.kd = 0.000f;

#if CONFIG_EXAMPLE_BLDC_MOTOR_1
motorgo_mini.init_motor_channel_1(motor_config);
auto motor = motorgo_mini.motor1();
#elif CONFIG_EXAMPLE_BLDC_MOTOR_2
motorgo_mini.init_motor_channel_2(motor_config);
auto motor = motorgo_mini.motor2();
#else
#error "No motor selected"
#endif

using BldcHaptics = espp::BldcHaptics<espp::MotorGoMini::BldcMotor>;
#elif CONFIG_EXAMPLE_HARDWARE_TEST_STAND
#pragma message("Using TinyS3 Test Stand hardware configuration")
Expand Down
Loading