a4988 component working?
Posted: Sun May 05, 2019 1:01 am
I want to drive stepper motors, so I'm trying out the a4988 component.
No luck so far.
With code straight from the repo, I get this:
Looking at the a4988.cpp(), it appears that the ledc init code never set
this 'hpoint' parameter. Perhaps that was for an earlier version of ESP-IDF?
The intr_type paramter is also missing.
So, I updated a4988.cpp to initialize these to (what I assume to be) reasonable defaults:
This cures the 'hpoint' error, but now I get a 'LoadProhibited' crash:
The EXCVADDR 0x0000014 suggests a null reference to a struct, but there doesn't seem to be such a reference near the code referenced in the backtrace. Am I missing something obvious?
My code is almost verbatim from the unit test:
Has anyone ever got this component working? What's the secret?
-Matt
No luck so far.
With code straight from the repo, I get this:
Code: Select all
.
.
E (247) ledc: ledc_set_duty_with_hpoint(383): hpoint argument is invalid
.
.
this 'hpoint' parameter. Perhaps that was for an earlier version of ESP-IDF?
The intr_type paramter is also missing.
So, I updated a4988.cpp to initialize these to (what I assume to be) reasonable defaults:
Code: Select all
ledc_ch.intr_type = LEDC_INTR_DISABLE;
ledc_ch.hpoint = 0;
Code: Select all
Guru Meditation Error: Core 0 panic'ed (LoadProhibited). Exception was unhandled.
Core 0 register dump:
PC : 0x40086423 PS : 0x00060930 A0 : 0x800864f2 A1 : 0x3ffb6ae0
0x40086423: prvProcessReceivedCommands at /Users/mkeveney/src/esp/esp-iot-solution/submodule/esp-idf/components/freertos/timers.c:961
A2 : 0x00000000 A3 : 0x00000000 A4 : 0x00000001 A5 : 0x3ffb51b4
A6 : 0x00000000 A7 : 0x00000001 A8 : 0x00000008 A9 : 0x3ffb6aa0
A10 : 0x00000001 A11 : 0x00000000 A12 : 0x3ffb6314 A13 : 0x00000000
A14 : 0x3ffb63ac A15 : 0x00000000 SAR : 0x00000000 EXCCAUSE: 0x0000001c
EXCVADDR: 0x00000014 LBEG : 0x4000c2e0 LEND : 0x4000c2f6 LCOUNT : 0x00000000
Backtrace: 0x40086423:0x3ffb6ae0 0x400864ef:0x3ffb6b20
0x40086423: prvProcessReceivedCommands at /Users/mkeveney/src/esp/esp-iot-solution/submodule/esp-idf/components/freertos/timers.c:961
0x400864ef: prvTimerTask at /Users/mkeveney/src/esp/esp-iot-solution/submodule/esp-idf/components/freertos/timers.c:961
My code is almost verbatim from the unit test:
Code: Select all
CA4988Stepper stepper(CONFIG_STEP_GPIO, CONFIG_DIR_GPIO, STEPS_PER_REV,
LEDC_HIGH_SPEED_MODE, LEDC_TIMER_0);
stepper.setSpeedRpm(80);
stepper.step(100);
vTaskDelay(1000/portTICK_RATE_MS); // crash happens during this delay.
stepper.step(-100);
vTaskDelay(1000/portTICK_RATE_MS);
-Matt