a4988 component working?

mkeveney
Posts: 5
Joined: Sun May 05, 2019 12:25 am

a4988 component working?

Postby mkeveney » 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:

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

    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);
Has anyone ever got this component working? What's the secret?

-Matt

@In逍遥子
Posts: 78
Joined: Thu Nov 15, 2018 2:06 am

Re: a4988 component working?

Postby @In逍遥子 » Mon May 06, 2019 2:13 am

Hi,
Please provide your complete log and code for analysis.

mkeveney
Posts: 5
Joined: Sun May 05, 2019 12:25 am

Re: a4988 component working?

Postby mkeveney » Tue May 07, 2019 6:48 pm

> Please provide your complete log and code for analysis.

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

mkeveney
Posts: 5
Joined: Sun May 05, 2019 12:25 am

Re: a4988 component working?

Postby mkeveney » Wed May 08, 2019 3:19 am

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!
Attachments
a4988-test.zip
(30.3 KiB) Downloaded 79 times

meowsqueak
Posts: 144
Joined: Thu Jun 15, 2017 4:54 am
Location: New Zealand

Re: a4988 component working?

Postby meowsqueak » Fri Feb 14, 2020 9:30 pm

@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.

Who is online

Users browsing this forum: No registered users and 4 guests