Page 1 of 1

a4988 component working?

Posted: Sun May 05, 2019 1:01 am
by mkeveney
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:

Code: Select all

    E (247) ledc: ledc_set_duty_with_hpoint(383): hpoint argument is invalid
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:

Code: Select all

  ledc_ch.intr_type  = LEDC_INTR_DISABLE;
  ledc_ch.hpoint     = 0;
This cures the 'hpoint' error, but now I get a 'LoadProhibited' crash:

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
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:

Code: Select all


    vTaskDelay(1000/portTICK_RATE_MS);      // crash happens during this delay.
Has anyone ever got this component working? What's the secret?


Re: a4988 component working?

Posted: Mon May 06, 2019 2:13 am
by @In逍遥子
Please provide your complete log and code for analysis.

Re: a4988 component working?

Posted: Tue May 07, 2019 6:48 pm
by mkeveney
> Please provide your complete log and code for analysis.

Will do shortly. I got tied up for a few days. Thanks for your interest.

Re: a4988 component working?

Posted: Wed May 08, 2019 3:19 am
by mkeveney
Here's my source code (including a log as produced by 'make monitor').
The 'stepper_test' directory goes in 'examples' under esp-iot-solution/.
I'm also including my modified a4988 directory. The only change is the two lines mentioned above.

Thanks for taking the time!

Re: a4988 component working?

Posted: Fri Feb 14, 2020 9:30 pm
by meowsqueak
@mkeveney - did you end up solving this problem? I found `a4988.cpp` in the espressif/esp-iot-solution repository, but I'm not sure about the status of this repository at the moment - seems to have been a long time since it was last updated. In particular, `a4988.cpp` hasn't been updated since July 2018, predating your post.