Skip to content
Closed
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
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
#include <SimpleFOC.h>

// Motor instance
BLDCMotor motor = BLDCMotor(11);
BLDCMotor motor = BLDCMotor(12);
BLDCDriver6PWM driver = BLDCDriver6PWM(A_PHASE_UH, A_PHASE_UL, A_PHASE_VH, A_PHASE_VL, A_PHASE_WH, A_PHASE_WL);
LowsideCurrentSense currentSense = LowsideCurrentSense(0.003f, -64.0f/7.0f, A_OP1_OUT, A_OP2_OUT, A_OP3_OUT);


// encoder instance
Encoder encoder = Encoder(A_HALL2, A_HALL3, 2048, A_HALL1);
// encoder instance,Hall or quadrature encoder in B-G431B-ESC1
Encoder encoder = Encoder(A_ENCODER_A,A_ENCODER_B,5000);

// Interrupt routine intialisation
// channel A and B callbacks
Expand Down Expand Up @@ -54,10 +54,11 @@ void setup() {

// set motion control loop to be used
motor.controller = MotionControlType::velocity;
motor.torque_controller=TorqueControlType::foc_current;
motor.foc_modulation = FOCModulationType::SpaceVectorPWM;

// contoller configuration
// default parameters in defaults.h

// velocity PI controller parameters
motor.PID_velocity.P = 0.2;
motor.PID_velocity.I = 20;
Expand Down Expand Up @@ -99,7 +100,7 @@ void loop() {

// Motion control function
motor.move();

motor.loopFOC();
// function intended to be used with serial plotter to monitor motor variables
// significantly slowing the execution down!!!!
// motor.monitor();
Expand Down
3 changes: 2 additions & 1 deletion examples/hardware_specific_examples/B_G431B_ESC1/build_opt.h
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
-DHAL_OPAMP_MODULE_ENABLED
build_flags=-DHAL_OPAMP_MODULE_ENABLED
lib_archive = false