-
Notifications
You must be signed in to change notification settings - Fork 672
Open
Labels
Description
Describe the bug
This code triggers a core panic on the ESP32-S3 when run, and works fine if the output ramp line is commented out.
#include <SimpleFOC.h>
#define ENC_A 7
#define ENC_B 5
#define ENC_C 6
#define INHA 14
#define INLA 11
#define INHB 13
#define INLB 10
#define INHC 12
#define INLC 9
BLDCMotor motor = BLDCMotor(1, 0.112, 2000); // Assuming delta wiring, tuned to 2000 KV
BLDCDriver6PWM driver = BLDCDriver6PWM(INHA, INLA, INHB, INLB, INHC, INLC);
HallSensor sensor = HallSensor(ENC_A, ENC_B, ENC_C, 1);
Commander command = Commander(Serial);
hw_timer_t *timer = NULL;
void onPID(char* cmd){ command.pid(&motor.PID_velocity, cmd); }
void onMotion(char* cmd){command.motion(&motor, cmd); }
void doA(){sensor.handleA();}
void doB(){sensor.handleB();}
void doC(){sensor.handleC();}
void IRAM_ATTR foc_loop() {
noInterrupts();
motor.loopFOC();
motor.move();
interrupts();
}
void setup() {
Serial.begin(115200);
SimpleFOCDebug::enable(&Serial);
driver.pwm_frequency = 16000;
driver.voltage_power_supply = 12;
driver.init();
sensor.velocity_max = 2000;
sensor.enableInterrupts(doA, doB, doC);
sensor.init();
motor.foc_modulation = FOCModulationType::Trapezoid_120;
motor.torque_controller = TorqueControlType::estimated_current;
motor.controller = MotionControlType::velocity;
motor.updateVoltageLimit(12);
motor.updateCurrentLimit(10);
motor.target = 0.0;
motor.linkDriver(&driver);
motor.linkSensor(&sensor);
motor.useMonitoring(Serial);
motor.zero_electric_angle = 1.047;
motor.sensor_direction = Direction::CW;
motor.PID_velocity.P = 0.01;
motor.PID_velocity.I = 0;
motor.PID_velocity.D = 0;
motor.PID_velocity.output_ramp = 0.001;
motor.LPF_velocity.Tf = 0.0001;
motor.init();
motor.initFOC();
command.add('V', onPID, "pid");
command.add('M', onMotion, "motion");
timer = timerBegin(1000000);
timerAttachInterrupt(timer, &foc_loop);
// Set alarm to call foc_loop every 50us (20kHz)
timerAlarm(timer, 50, true, 0);
}
void loop() {
command.run();
}Log:
ESP-ROM:esp32s3-20210327
Build:Mar 27 2021
rst:0x10 (RTCWDT_RTC_RST),boot:0xb (SPI_FAST_FLASH_BOOT)
SPIWP:0xee
mode:DIO, clock div:1
load:0x3fce2820,len:0x116c
load:0x403c8700,len:0xc2c
load:0x403cb700,len:0x3108
entry 0x403c88b8
ESP32-DRV: Configuring 6PWM in group: 0 on timer: 0
ESP32-DRV: Configuring 3 operators.
ESP32-DRV: Configuring 6PWM with hardware dead-time
ESP32-DRV: Configuring 3 comparators.
ESP32-DRV: Configuring 6 generators.
ESP32-DRV: Configuring Center-Aligned 6 pwm.
ESP32-DRV: Configuring dead-time.
ESP32-DRV: Enabling timer: 0
ESP32-DRV: MCPWM configured!
MOT:Monitor enabled!
MOT:Init
MOT:Enable driver.
MOT:Align sensor.
MOT:Skip dir calib.
MOT:Skip offset calib.
ERR-MOT:No current sense.
MOT:Ready.
E (1030) mcpwm: mcpwm_comparator_set_compare_value(195): compare value out of range
E (1034) mcpwm: mcpwm_comparator_set_compare_value(195): compare value out of range
E (1042) mcpwm: mcpwm_comparator_set_compare_value(195): compare value out of range
E (1049) mcpwm: mcpwm_comparator_set_compare_value(195): compare value out of range
E (1056) mcpwm: mcpwm_comparator_set_compare_value(195): compare value out of range
E (1064) mcpwm: mcpwm_comparator_set_compare_value(195): compare value out of range
E (1071) mcpwm: mcpwm_comparator_set_compare_value(195): compare value out of range
E (1078) mcpwm: mcpwm_comparator_set_compare_value(195): compare value out of range
E (1086) mcpwm: mcpwm_comparator_set_compare_value(195): compare value out of range
E (1093) mcpwm: mcpwm_comparator_set_compare_value(195): compare value out of range
E (1101) mcpwm: mcpwm_comparator_set_compare_value(195): compare value out of range
E (1108) mcpwm: mcpwm_comparator_set_compare_value(195): compare value out of range
E (1115) mcpwm: mcpwm_comparator_set_compare_value(195): compare value out of range
E (1123) mcpwm: mcpwm_comparator_set_compare_value(195): compare value out of range
Guru Meditation Error: Core / panic'ed (Cache error).
MMU entry fault error
Core 0 register dump:
Guru Meditation Error: Core 0 panic'ed (Unhandled debug exception).
Debug exception reason: Stack canary watchpoint triggered (IDLE0)
Core 0 register dump:
PC : 0x4200f4cb PS : 0x00060836 A0 : 0x8200f2c8 A1 : 0x3fca0850
A2 : 0x3fca09e0 A3 : 0x00000000 A4 : 0x00000000 A5 : 0x00000000
A6 : 0x3fca09e0 A7 : 0x3fca0860 A8 : 0x00000050 A9 : 0x3fca0860
A10 : 0x3c042b8a A11 : 0x3c04cb9c A12 : 0x00000060 A13 : 0x3fca08c0
A14 : 0x3c042c50 A15 : 0x00000000 SAR : 0x0000000c EXCCAUSE: 0x00000001
EXCVADDR: 0x00000000 LBEG : 0x40056f5c LEND : 0x40056f72 LCOUNT : 0x00000000
Backtrace: 0x4200f4c8:0x3fca0850 0x4200f2c5:0x3fca08e0 0x4200f2f1:0x3fca0900 0x42032f1f:0x3fca0920 0x42008860:0x3fca0950 0x4200f289:0x3fca0970 0x40375e9d:0x3fca09c0 0x40376144:0x3fca09e0 0x00040022:0x3fca0aa0 |<-CORRUPTED
Core 1 register dump:
PC : 0x40374340 PS : 0x00050034 A0 : 0x420067d9 A1 : 0x3fc958c0
A2 : 0x00000000 A3 : 0x3fc958e0 A4 : 0x403776d4 A5 : 0x3fc95b90
A6 : 0x00000000 A7 : 0x00000000 A8 : 0x00000000 A9 : 0x4037c906
A10 : 0x00116e96 A11 : 0x6001e000 A12 : 0x00000001 A13 : 0x3fc95b60
A14 : 0x3fc988a8 A15 : 0x0000abab SAR : 0x00000004 EXCCAUSE: 0x00000007
EXCVADDR: 0x3fc95b90 LBEG : 0x400570e8 LEND : 0x400570f3 LCOUNT : 0x00000000
Backtrace: 0x4037433d:0x3fc958c0 0x420067d6:0x3fc95980 0x42003289:0x3fc959b0 0x40375368:0x3fc959e0 0x40377d69:0x3fc95a00 0x40377e2a:0x3fc95a20 0x403769d1:0x3fc95a50 0x403776d1:0x3fc95a70 0x420067d6:0x3fc95b30 0x42003289:0x3fc95b60 0x40375368:0x3fc95b90 0x40377d69:0x3fc95bb0 0x40377e2a:0x3fc95bd0 0x403769d1:0x3fc95c00 0x403776d1:0x3fc95c20 0x420065da:0x3fc95ce0 0x420031df:0x3fc95d10 0x42003720:0x3fc95d40 0x40375374:0x3fc95d70 0x40377d69:0x3fc95d90 0x40377e2a:0x3fc95db0 0x403769d1:0x3fc95de0 0x403776d1:0x3fc95e00 0x420067d6:0x3fc95ec0 0x42003289:0x3fc95ef0 0x40375368:0x3fc95f20 0x40377d69:0x3fc95f40 0x40377e2a:0x3fc95f60 0x403769d1:0x3fc95f90 0x403776d1:0x3fc95fb0 0x420065da:0x3fc96070 0x420031df:0x3fc960a0 0x42003720:0x3fc960d0 0x40375374:0x3fc96100 0x40377d69:0x3fc96120 0x40377e2a:0x3fc96140 0x403769d1:0x3fc96170 0x403776d1:0x3fc96190 0x420067d6:0x3fc96250 0x42003289:0x3fc96280 0x40375368:0x3fc962b0 0x40377d69:0x3fc962d0 0x40377e2a:0x3fc962f0 0x403769d1:0x3fc96320 0x403776d1:0x3fc96340 0x420065da:0x3fc96400 0x420031df:0x3fc96430 0x42003720:0x3fc96460 0x40375374:0x3fc96490 0x40377d69:0x3fc964b0 0x40377e2a:0x3fc964d0 0x403769d1:0x3fc96500 0x403776d1:0x3fc96520 0x420067d6:0x3fc965e0 0x42003289:0x3fc96610 0x40375368:0x3fc96640 0x40377d69:0x3fc96660 0x40377e2a:0x3fc96680 0x403769d1:0x3fc966b0 0x403776d1:0x3fc966d0 0x420065da:0x3fc96790 0x420031df:0x3fc967c0 0x42003720:0x3fc967f0 0x40375374:0x3fc96820 0x40377d69:0x3fc96840 0x40377e2a:0x3fc96860 0x403769d1:0x3fc96890 0x403776d1:0x3fc968b0 0x420067d6:0x3fc96970 0x42003289:0x3fc969a0 0x40375368:0x3fc969d0 0x40377d69:0x3fc969f0 0x40377e2a:0x3fc96a10 0x403769d1:0x3fc96a40 0x403776d1:0x3fc96a60 0x420065da:0x3fc96b20 0x420031df:0x3fc96b50 0x42003720:0x3fc96b80 0x40375374:0x3fc96bb0 0x40377d69:0x3fc96bd0 0x40377e2a:0x3fc96bf0 0x403769d1:0x3fc96c20 0x403776d1:0x3fc96c40 0x420067d6:0x3fc96d00 0x42003289:0x3fc96d30 0x40375368:0x3fc96d60 0x40377d69:0x3fc96d80 0x40377e2a:0x3fc96da0 0x403769d1:0x3fc96dd0 0x403776d1:0x3fc96df0 0x420065da:0x3fc96eb0 0x420031df:0x3fc96ee0 0x42003720:0x3fc96f10 0x40375374:0x3fc96f40 0x40377d69:0x3fc96f60 0x40377e2a:0x3fc96f80 0x403769d1:0x3fc96fb0 0x403776d1:0x3fc96fd0 0x420067d6:0x3fc97090 0x42003289:0x3fc970c0 0x40375368:0x3fc970f0 |<-CONTINUES
ELF file SHA256: 06fca82c2
Describe the hardware setup
For us it is very important to know what is the hardware setup you're using in order to be able to help more directly
- Motor: Standard BLDC Motor
- Driver: DRV8300
- Microcontroller: ESP32-S3
- Sensor: Hall Sensor
- Current Sensing: None
IDE you are using
- Arduino IDE
Reactions are currently unavailable