Two wire Driver / Cannot instantiate AccelStepper with fewer than (x6) arguments

116 views
Skip to first unread message

Brian C

unread,
Jan 23, 2022, 12:29:35 AM1/23/22
to accelstepper
Connecting a TB6600 driver to a Nema 17 stepper.  I've gotten this to work fine with the Stepper library integrated with Arduino's Sketch IDE.  Trying to use AccelStepper.

However, using  AccelStepper  , the constructor requires (x6) arguments.  How can this code ever work?  The include file clearly shows only one possible constructor.

-B

CODE
void setup() {
  #define _PIN_DIRECTION 6
  #define _PIN_PULSE 7

  #include <AccelStepper.h>
  AccelStepper stepper(1, _PIN_PULSE, _PIN_DIRECTION);
}

void loop() {
}


COMPILER ERROR
In file included from C:\Users\...\Documents\Arduino\testAccelStepperDriver\testAccelStepperDriver.ino:7:0:
C:\Users\...\Documents\Arduino\libraries\AccelStepper\src/AccelStepper.h:373:5: warning: 'setup()::AccelStepper::AccelStepper(uint8_t, uint8_t, uint8_t, uint8_t, uint8_t, bool)' used but never defined
     AccelStepper(uint8_t interface = AccelStepper::FULL4WIRE, uint8_t pin1 = 2, uint8_t pin2 = 3, uint8_t pin3 = 4, uint8_t pin4 = 5, bool enable = true);
     ^~~~~~~~~~~~
C:\Users\...\AppData\Local\Temp\ccC0Vm6p.ltrans0.ltrans.o: In function `setup':
C:\Users\...\Documents\Arduino\testAccelStepperDriver/testAccelStepperDriver.ino:9: undefined reference to `setup::AccelStepper::AccelStepper(unsigned char, unsigned char, unsigned char, unsigned char, unsigned char, bool)'
collect2.exe: error: ld returned 1 exit status
exit status 1
Error compiling for board Arduino Uno.


INCLUDE (*.H)
AccelStepper(uint8_t interface = AccelStepper::FULL4WIRE, uint8_t pin1 = 2, uint8_t pin2 = 3, uint8_t pin3 = 4, uint8_t pin4 = 5, bool enable = true);

Mike McCauley

unread,
Jan 23, 2022, 12:56:13 AM1/23/22
to accelstepper, Brian C
Hello,

On Sunday, 23 January 2022 15:29:35 AEST Brian C wrote:
> Connecting a TB6600 driver to a Nema 17 stepper. I've gotten this to work
> fine with the Stepper library integrated with Arduino's Sketch IDE. Trying
> to use AccelStepper.
>
> However, using AccelStepper , the constructor requires (x6) arguments.
> How can this code ever work? The include file clearly shows only one
> possible constructor.

There are 2 possible constructors

AccelStepper(uint8_t interface = AccelStepper::FULL4WIRE, uint8_t pin1 = 2,
uint8_t pin2 = 3, uint8_t pin3 = 4, uint8_t pin4 = 5, bool enable = true);

6 arguments, all optional

AccelStepper(void (*forward)(), void (*backward)());

2 arguments, both pointers, none optional.

Cheers.


>
> -B
>
> *CODE*
> void setup() {
> #define _PIN_DIRECTION 6
> #define _PIN_PULSE 7
>
> #include <AccelStepper.h>
> AccelStepper stepper(1, _PIN_PULSE, _PIN_DIRECTION);
> }
>
> void loop() {
> }
>
> *COMPILER ERROR*
> In file included from
> C:\Users\...\Documents\Arduino\testAccelStepperDriver\testAccelStepperDriver
> .ino:7:0:
> C:\Users\...\Documents\Arduino\libraries\AccelStepper\src/AccelStepper.h:37
> 3:5: warning: 'setup()::AccelStepper::AccelStepper(uint8_t, uint8_t,
> uint8_t, uint8_t, uint8_t, bool)' used but never defined
> AccelStepper(uint8_t interface = AccelStepper::FULL4WIRE, uint8_t pin1
> = 2, uint8_t pin2 = 3, uint8_t pin3 = 4, uint8_t pin4 = 5, bool enable =
> true);
> ^~~~~~~~~~~~
> C:\Users\...\AppData\Local\Temp\ccC0Vm6p.ltrans0.ltrans.o: In function
> `setup':
> C:\Users\...\Documents\Arduino\testAccelStepperDriver/testAccelStepperDriver
> .ino:9: undefined reference to `setup::AccelStepper::AccelStepper(unsigned
> char, unsigned char, unsigned char, unsigned char, unsigned char, bool)'
> collect2.exe: error: ld returned 1 exit status
> exit status 1
> Error compiling for board Arduino Uno.
>
> *INCLUDE (*.H)*
> AccelStepper(uint8_t interface = AccelStepper::FULL4WIRE, uint8_t pin1 = 2,
> uint8_t pin2 = 3, uint8_t pin3 = 4, uint8_t pin4 = 5, bool enable = true);


--
Mike McCauley VK4AMM mi...@airspayce.com
Airspayce Pty Ltd 9 Bulbul Place Currumbin Waters QLD 4223 Australia
http://www.airspayce.com 5R3MRFM2+X6
Phone +61 7 5598-7474



Alan Stepney

unread,
Jan 23, 2022, 2:14:12 AM1/23/22
to accels...@googlegroups.com
Should the #include be above setup()?

Al

Sent from my iPad

> On 23 Jan 2022, at 05:56, Mike McCauley <mi...@airspayce.com> wrote:
>
> Hello,
> --
> You received this message because you are subscribed to the Google Groups "accelstepper" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to accelstepper...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/accelstepper/6395105.4vTCxPXJkl%40zulu.

Mike McCauley

unread,
Jan 23, 2022, 5:14:09 AM1/23/22
to accels...@googlegroups.com, Alan Stepney
On Sunday, 23 January 2022 17:14:08 AEST Alan Stepney wrote:
> Should the #include be above setup()?

YES!!!

Suggest you start with the example sketches and work from there.

Brian C

unread,
Jan 23, 2022, 12:14:05 PM1/23/22
to accels...@googlegroups.com
Excellent!  Good catch.

So, now that I'm compiling I will be testing soon.  However, I think I still have the same question:

AccelStepper(AccelStepper::DRIVER, pinA, pinB) only has (x3) arguments.  There is no signature like this in the definition of the class.  How does this work?

-B

--
You received this message because you are subscribed to a topic in the Google Groups "accelstepper" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/accelstepper/ySp5NafCg4s/unsubscribe.
To unsubscribe from this group and all its topics, send an email to accelstepper...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/accelstepper/3396920.V25eIC5XRa%40zulu.

Mike McCauley

unread,
Jan 23, 2022, 3:33:02 PM1/23/22
to accels...@googlegroups.com, Brian C
On Monday, 24 January 2022 03:13:52 AEST Brian C wrote:
> Excellent! Good catch.
>
> So, now that I'm compiling I will be testing soon. However, I think I
> still have the same question:
>
> AccelStepper(AccelStepper::DRIVER, pinA, pinB) only has (x3) arguments.
> There is no signature like this in the definition of the class. How does
> this work?

This is a basic C++ question about default arguments for member function (ie
constructors). You should consult a C++ reference for that.

Cheers.

Jim Larson

unread,
Jan 23, 2022, 4:57:38 PM1/23/22
to accelstepper
To the OP - you should also instantiate the AccelStepper object globally, outside of setup(), so it can be referenced in your loop().
You will find a lot of useful information and some examples here:
HTH!
Reply all
Reply to author
Forward
0 new messages