Problems with A4988 Stepper Drivers

I am wondering if anyone can help me with an issue regarding conflict between the A4988 stepper library and a small OLED display.

I have a project designed to run two stepper motors from a NANO using A4988 stepper drive boards. The logic is driven by a small control box containing pushbuttons and a 0.96" OLED display (SSD1306).

I can run the OLED display with no problems and the logic will respond to button pushes. I can drive the stepper motors OK from the logic via the A4988 library. The problem arises when I try to do both things in the same sketch.

Once I define an A4988 stepper motor object using the line
A4988 stepper(MOTOR_STEPS, DIR, STEP, SLEEP, MS1, MS2, MS3);
this causes the OLED display statement to hang and the program just stops.

The OLEDdisplay uses the standard address 0x3C. Does this conflict with anything in the A4988 library?

As a matter if interest I started developing this with project with the Accelstepper library and encountered the same problem.

I am mystified. Any help would be appreciated.

I attach the code in its current state. All stepper commands were commeted out then enabled one at a time. Once the A4988 stepper object was uncommented and recompiled, the problem occurs.

Colin M.

A4988_Traverser_with_Acceleration_DEBUG.ino (8.45 KB)

Please post links to the libraries you are using, and a wiring diagram with all the pins labeled, as described in the "How to use this forum" post.

There appears to be a conflict between pin usage, as at the very least, pins 11 and 12 are used for more than one purpose.

Hi there. Thanks for the response.

Yes - there was a conflict with pins 11 & 12 which I have now resolved. However this makes no difference to the problem.

In response to your request I will get a diagram done and post it here together with the information you request about the libraries.

Sorry for the delay, but here is the information you requested.

Attached is a layout of the components in the project - A4988 and OLED Stepper Driver.pdf. I have also attached two sketches:
A4988_OLED_no_Stepper.ino - in this the stepper code is comment out. If this is uploaded the OLED and buttons work correctly.
A4988_Stepper_no_OLED.ino - in this the OLED function is commented out. If this is uploaded the buttons work OK and the stepper runs as required (output via the serial monitor as no OLED).

If the 1st sketch is used and the stepper code is gradually uncommented, all works until the stepper object is defined - A4988 stepper(MOTOR_STEPS, DIR, STEP, SLEEP, MS1, MS2, MS3);.

The libraries are :

I note that the Adafruit-GFX library has a later version available - 1.5.7 in place of the 1.5.6 I have installed. I will update that and see if that makes any difference.

Any ideas of what could be causing this issue would be appreciated.

A4988 and OLED Stepper Driver.pdf (1.04 MB)

A4988_OLED_no_Stepper.ino (8.71 KB)

A4988_Stepper_no_OLED.ino (8.69 KB)

Hi,
Ops circuit;

Do you have any bypass capacitors around the 12V regulator as per the data sheet for that regualtor?

Tom.... :slight_smile:

Tom,

Yes - I do have a capacitor across the 12v supply close to the regulator. Sorry I missed it on the diagram. It’s a 33 Microfarad 50 volt, the closest I had to the 47 Microfarad recommended.

Regards,

Colin