MCP23017 for i2c control of steppers

477 views
Skip to first unread message

Harrzack

unread,
Feb 21, 2018, 2:14:36 PM2/21/18
to accelstepper
Greets!

I have found the library 'MCP3017AccelStepper' which extends AccelStepper to use the port expander MCP23017.  It all looks fairly easy - except I can't quite figure out what they are doing for pin assignments.

Here is a snippet from an example setup using the library:

MCP3017AccelStepper steppers[STEPPER_COUNT] = {
   
// interface, step, dir, en
    MCP3017AccelStepper
(AccelStepper::DRIVER, 15, 14, 8),
    MCP3017AccelStepper
(AccelStepper::DRIVER, 4, 5, 6),
    MCP3017AccelStepper
(AccelStepper::DRIVER, 12, 11, 10),
    MCP3017AccelStepper
(AccelStepper::DRIVER, 3, 1, 2),
};

I have worked with this chip before, and the pin numbers listed in this example don't correlate to the GPIO pins on the chip. Pins 1-8 are GPIOB pins and pins 21-28 are GPIOA pins.

Has anybody worked with this extension & chip who might have an idea of the pin setting are doing?
I've scoured the source of all the libraries and can't seem to find what pins are being referenced. I've also set a note to the dev (johan nilsson), and will list any info he sends.

=A.

Mike McCauley

unread,
Feb 21, 2018, 3:56:48 PM2/21/18
to accels...@googlegroups.com
I havent used this library or the MCP23017, but looking at the
MCP3017AccelStepper code, the pin numbering system is the same as used in
Adafruit-MCP23017-Arduino-Library
If I read the code correctly,

pins 0 to 7 are GPA0 to GPA7
pin 8 to 15 are GPB0 to GPB7

Cheers.
> <https://github.com/johannilsson/MCP3017AccelStepper/commits?author=johannil
> sson>), and will list any info he sends.
>
> =A.


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

Harrzack

unread,
Feb 22, 2018, 9:27:15 AM2/22/18
to accelstepper
Mike - Thanks for the heads up! It is with a BIG RED FACE that I read your info... LOL! I actually have the data sheet for the chip - but simply misread the pin-numbers and jumped up with my question a bit too quickly. :-( Johan also replied and gave the same info. Think I may be getting too old for this stuff! :-(

ob dev

unread,
Jun 6, 2018, 5:19:33 PM6/6/18
to accelstepper
Did you make any progress with this combination ?

I just tried to compile it and had to move all the private: AccelStepper class members to public:. A terrible hack, I agree, but it'll do for now :)

Mike - did you change the access of these members sometime in the 5 years since the other library was last touched ?

One answer is for someone to write access methods for all the private members, but that's a big job and probably not worthwhile if no one else is sub-classing AccelStepper.

Am I right in thinking that the FUNCTION driver interface is the correct/intended way to proceed, if I intend to write something new ?

Thanks

Dillon MacEwan

unread,
Nov 21, 2018, 7:54:05 AM11/21/18
to accelstepper
If you check the Library documentation, it says to change the private:  AccelStepper  class members to protected:

This has worked for me
Reply all
Reply to author
Forward
0 new messages