setEnablePin + setPinsInverted(false, false, true) != inverted. BUG?

2,193 views
Skip to first unread message

Duane Bishop

unread,
May 25, 2013, 4:39:00 AM5/25/13
to accels...@googlegroups.com

First off, AWESOME bit of coding. My compliments to the programmer(s). :)

That said, it seems that if I use setEnablePin, then set it inverted; it will remain non-inverted. As in, the inversion flag has no bearing on the setEnablePin whatsoever.

Sparkfun's "quadStepper" board requires the enable pin as active LOW. Thus, if I call fooStepper.disableOutputs(); the stepper becomes enabled and vise verse.

Any ideas?

Mike McCauley

unread,
May 25, 2013, 5:56:56 AM5/25/13
to accels...@googlegroups.com
Hello,

you will need to use setPinsInverted() to specify the enable pin is inverted,

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

Duane Bishop

unread,
May 25, 2013, 7:37:48 AM5/25/13
to accels...@googlegroups.com
Correct, that is with the use of: setPinsInverted(false,false,true); == No effect. (enPin remains False)
If I should apply the setting of: setPinsInverted(false,false,false); == Same effect.

disableOutputs = enabled.
enableOutputs = disabled.

My plight is that setPinsInverted seems to have no effect on on toggling the default setting of "HIGH" as stated in the .cpp file.

I'm not real good with c++ (as in the .cpp file is somewhat arcane to me.)
It seems like the setPinInverted("","",bool) and/or setEnablePin(int) is either not getting registered, or being spammed back to default. With my setup I can't tell for certain but I think its related to the pin inversion function.

MCU==Arduino Due.
Driver=SparkFun's quadstepper.
Library Instances==4.

Mike McCauley

unread,
May 25, 2013, 8:59:17 PM5/25/13
to accels...@googlegroups.com
Hi,

You will need to call:
setEnablePin(whatever);
setPinsInvertedfalse, false, true);
enableOutputs();

in that order.

Cheers.

Duane Bishop

unread,
May 25, 2013, 10:02:04 PM5/25/13
to accels...@googlegroups.com

  stepper1.setEnablePin(36);
  stepper2.setEnablePin(37);
  stepper3.setEnablePin(38);
  stepper4.setEnablePin(39);
  stepper1.setPinsInverted(false, false, true);
  stepper2.setPinsInverted(false, false, true);
  stepper3.setPinsInverted(false, false, true);
  stepper4.setPinsInverted(false, false, true);
  stepper1.enableOutputs();
  stepper2.enableOutputs();
  stepper3.enableOutputs();
  stepper4.enableOutputs();
  
Has no effect on enable pins. They remain LOW when they should be HIGH. Bare in mind this is being ran on an Arduino Due.

Actual sketch is attached.



--
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/6KNJ1801Vl4/unsubscribe?hl=en.
To unsubscribe from this group and all its topics, send an email to accelstepper...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.



testingMultiStepper.ino

Mike McCauley

unread,
May 26, 2013, 2:14:37 AM5/26/13
to accels...@googlegroups.com
Hello,

If you define an enable pin, then when enableOutputs() is called, that enable
pin will be turned 'on'.

If setPinsInverted(x, x, true);

has been called, the enable pin will be set to LOW when it is turned 'on',
else (the default) it will be set to HIGH.

So your code is doing exactly what is expected: the enable output pin is set
to LOW.

If you want it set to HIGH when the stepper outputs are enabled, dont call
setPinsInverted().


Cheers.

Duane Bishop

unread,
May 26, 2013, 5:18:52 AM5/26/13
to accels...@googlegroups.com
Mine is active LOW.

 What I'm trying to express is that regardless of which way I set pinsInverted(x,x,?); It never gets set or is overridden back to default, as active HIGH. (As observed via logic probe.)
 -OR possibly-
setEnablePin(#); never sets 0xFF to an actual value. (Leaving the pin at the default HIGH following mcu powerOn.)

Either way, I have tried both true/false for setPinsInverted with no effect; even if I call setEnablePin, with and without previously declaring the EN pins as outputs.

I only get motion when I manually setup the EN pins and set them low. setPinsInverted as well as setEnablePin seems to have no effect.

I did notice that in the .cpp file that both methods are exclusive in the use of the  ^  (XOR) operand compared to the rest of the file. Perhaps the beta 1.5.2 IDE doesn't handle it correctly.

Mike McCauley

unread,
May 26, 2013, 6:14:59 AM5/26/13
to accels...@googlegroups.com
Hello Duane,

After configuration, the enable pin only changes state when enableOutputs and
disableOutputs() are called.

After calling enableOutputs your code never calls disableOutputs so your
enable pins always stay 'on' (LOW).

Cheers.

On Sunday, May 26, 2013 04:18:52 AM Duane Bishop wrote:
> Mine is active LOW.
>
> What I'm trying to express is that regardless of which way I set
> pinsInverted(x,x,?); It never gets set or is overridden back to default, as
> active HIGH. (As observed via logic probe.)
> -OR possibly-
> setEnablePin(#); never sets 0xFF to an actual value. (Leaving the pin at
> the default HIGH following mcu powerOn.)
>
> Either way, I have tried both true/false for setPinsInverted with no
> effect; even if I call setEnablePin, with and without previously declaring
> the EN pins as outputs.
>
> I only get motion when I manually setup the EN pins and set them low.
> setPinsInverted as well as setEnablePin seems to have no effect.
>
> I did notice that in the .cpp file that both methods are exclusive in the
> use of the *^* (XOR) operand compared to the rest of the file. Perhaps

Duane Bishop

unread,
May 26, 2013, 6:35:41 AM5/26/13
to accels...@googlegroups.com
Ok, here's what I scratch out so far...

  stepper1.setEnablePin(36); // stepper A
  stepper2.setEnablePin(37); // stepper Z
  stepper3.setEnablePin(38); // stepper Y
  stepper4.setEnablePin(39); // stepper X
  stepper1.setPinsInverted(false, false, false);
  stepper2.setPinsInverted(false, false, true);
  stepper3.setPinsInverted(false, false, true);
  stepper4.setPinsInverted(false, false, false);
  stepper1.disableOutputs(); // stepper runs. (should be disabled.)
  stepper2.disableOutputs(); // works correctly. (is disabled.)
  stepper3.enableOutputs(); // no motion
  stepper4.enableOutputs(); // no motion either.

Ok, from this I can deduce that:
  • setEnablePin() works correctly.
  • setPinsInverted() works correctly.
  • disableOutputs() works correctly. (Self-correction, my driver needs +v on enable pin to go active.)
  • enableOutputs() not behaving as expected.

Duane Bishop

unread,
May 26, 2013, 7:00:02 AM5/26/13
to accels...@googlegroups.com
Ah HA! I found the culprit.

In AccelStepper.cpp lines 547 & 548 just needed to be swapped.

Calling pinMode resets the pin state to low. Not good if you need it to be HIGH. (Otherwise it goes un-noticed, or could this be a Due specific problem?)

> > > > For more options, visit https://groups.google.com/groups/opt_out.
> >
> > --
> > Mike McCauley                                     mi...@airspayce.com
> > Airspayce Pty Ltd
> > 9 Bulbul Place Currumbin Waters QLD 4223 Australia
> > http://www.airspayce.com
> > Phone +61 7 5598-7474                       Fax   +61 7 5598-7070
> >
> > --
> > 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/6KNJ1801Vl4/unsubscribe?hl=
> > en .
> > To unsubscribe from this group and all its topics, send an email to

> > For more options, visit https://groups.google.com/groups/opt_out.
--
Mike McCauley                                     mi...@airspayce.com
Airspayce Pty Ltd
9 Bulbul Place Currumbin Waters QLD 4223 Australia   http://www.airspayce.com
Phone +61 7 5598-7474                       Fax   +61 7 5598-7070

--
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/6KNJ1801Vl4/unsubscribe?hl=en.
To unsubscribe from this group and all its topics, send an email to accelstepper+unsubscribe@googlegroups.com.

Mike McCauley

unread,
May 26, 2013, 7:46:49 AM5/26/13
to accels...@googlegroups.com
Hi,

On Sunday, May 26, 2013 04:00:02 AM Duane Bishop wrote:
> Ah HA! I found the culprit.
>
> In AccelStepper.cpp lines 547 & 548 just needed to be swapped.
>
> Calling pinMode resets the pin state to low. Not good if you need it to be
> HIGH. (Otherwise it goes un-noticed, or could this be a Due specific
> problem?)

Looks like thats a Due specific thing.
I dont see that behaviour on other Arduino boards.

Change has been made in new version 1.32 uploaded now.
Thanks for the report and diagnosis.

Cheers.


>
> On Sunday, May 26, 2013 5:35:41 AM UTC-5, Duane Bishop wrote:
> > Ok, here's what I scratch out so far...
> >
> > stepper1.setEnablePin(36); // stepper A
> > stepper2.setEnablePin(37); // stepper Z
> > stepper3.setEnablePin(38); // stepper Y
> > stepper4.setEnablePin(39); // stepper X
> > stepper1.setPinsInverted(false, false, false);
> > stepper2.setPinsInverted(false, false, true);
> > stepper3.setPinsInverted(false, false, true);
> > stepper4.setPinsInverted(false, false, false);
> > stepper1.disableOutputs(); // stepper runs. (should be disabled.)
> > stepper2.disableOutputs(); // works correctly. (is disabled.)
> > stepper3.enableOutputs(); // no motion
> > stepper4.enableOutputs(); // no motion either.
> >
> > Ok, from this I can deduce that:
> > - setEnablePin() works correctly.
> > - setPinsInverted() works correctly.
> > - disableOutputs() works correctly. (Self-correction, my driver needs
> > +v on enable pin to go active.)
> > - enableOutputs() *not *behaving as expected.
> >> > > > > accelstepper...@googlegroups.com.
> >> > > > > For more options, visit https://groups.google.com/groups/opt_out.
> >> > >
> >> > > --
> >> > > Mike McCauley mi...@airspayce.com
> >> > > Airspayce Pty Ltd
> >> > > 9 Bulbul Place Currumbin Waters QLD 4223 Australia
> >> > > http://www.airspayce.com
> >> > > Phone +61 7 5598-7474 Fax +61 7 5598-7070
> >> > >
> >> > > --
> >> > > 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/6KNJ1801Vl4/unsubscribe?hl
> >> =
> >>
> >> > > en .
> >> > > To unsubscribe from this group and all its topics, send an email to
> >> > > accelstepper...@googlegroups.com.
> >> > > For more options, visit https://groups.google.com/groups/opt_out.
> >>
> >> --
> >> Mike McCauley mi...@airspayce.com
> >> Airspayce Pty Ltd
> >> 9 Bulbul Place Currumbin Waters QLD 4223 Australia
> >> http://www.airspayce.com
> >> Phone +61 7 5598-7474 Fax +61 7 5598-7070
> >>
> >> --
> >> 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/6KNJ1801Vl4/unsubscribe?hl
> >> =en .
> >> To unsubscribe from this group and all its topics, send an email to
> >> accelstepper...@googlegroups.com.

Duane Bishop

unread,
May 26, 2013, 7:53:35 AM5/26/13
to accels...@googlegroups.com
Glad to be of service.

I'll go fetch a copy right now. :)

Thx, for putting up with yet another case of "the odd user application."

(I know how that goes.)
Duane Bishop
Coder of EMC2Arduino && HAL2Arduino.
TTFN
Reply all
Reply to author
Forward
0 new messages