laurb9 / StepperDriver

Arduino library for A4988, DRV8825, DRV8834, DRV8880 and generic two-pin (DIR/STEP) stepper motor drivers
MIT License
556 stars 228 forks source link

Sketch didn't work on Apple M1 Pro Sonoma v14.1.2 #125

Open YanisDeplazes opened 8 months ago

YanisDeplazes commented 8 months ago

Describe the bug A clear and concise description of what the bug is.

To Reproduce Steps to reproduce the behavior:

  1. Example sketch code: `/* Simple demo with DRV8255 driver on CNC shield

    Connect STEP, DIR as indicated! Driverslots X, Y, Z on the CNC shield can be used

    In this demo driver chip is in slot X (pin 5, 2)

    Adapted 2021/2022 by Gordan Savicic based on Copyright (C)2015-2017 Laurentiu Badea

    This file may be redistributed under the terms of the MIT license. A copy of this license has been included with this distribution in the file LICENSE.

*/

include

include "BasicStepperDriver.h"

// Motor steps per revolution. Most steppers are 200 steps or 1.8 degrees/step

define MOTOR_STEPS 200

define RPM 120

// Since microstepping is set externally, make sure this matches the selected mode // Set the jumper to middle position when using MICROSTEPS 4, no jumper = MICROSTEPS 1 // 1=full step, 2=half step etc.

define MICROSTEPS 1

// Driver in CNC shield X

define DIR_X 5

define STEP_X 2

// Driver in CNC shield Y

define DIR_Y 6

define STEP_Y 3

// Driver in CNC shield Z

define DIR_Z 7

define STEP_Z 4

// Define the pin for enable/disable functionality

define SLEEP 8

// Initialize the driver(s) BasicStepperDriver stepper(MOTOR_STEPS, DIR_Y, STEP_Y, SLEEP); BasicStepperDriver stepper2(MOTOR_STEPS, DIR_X, STEP_X, SLEEP);

void setup() { // Pass some config to the instances and begin stepper.begin(RPM, MICROSTEPS);

// if using enable/disable on ENABLE pin (active LOW) instead of SLEEP uncomment next line stepper.setEnableActiveState(LOW);

stepper2.begin(RPM, MICROSTEPS);

// if using enable/disable on ENABLE pin (active LOW) instead of SLEEP uncomment next line stepper2.setEnableActiveState(LOW); }

void loop() { // energize coils stepper.enable(); stepper2.enable();

// Moving motor one full revolution using the degree notation stepper.rotate(360); stepper2.rotate(360);

// pause and allow the motor to be moved by hand stepper.disable(); stepper2.disable();

delay(2000); // repeat after 2sec. pause }`

  1. Compiled the code (Worked) (On Mac)

  2. Uploaded the code (Worked) (On Mac)

  3. Motors didn't rotate as expected.

  4. When running and compiling over a windows it did work as expected.

Expected behavior I expected the library to work on a Apple Macbook.

Platform Setup (please complete the following information):

laurb9 commented 8 months ago

This is likely an Arduino support issue on M1 Sonoma Macs. The library code is cross-compiled to the target arch by Arduino or PlatformIO so it has no dependency on the host machine itself. Perhaps the Arduino configuration or version on the two platforms tried differ in some way that causes this. I suggest trying out another simple sketch like Blink to make sure that works to eliminate that possibility. I've found that Bing ChatGPT can be an useful assistant in troubleshooting the issue, if that does not yield results you may try opening an issue in the Arduino forums.

Please do post back if you find a resolution to this issue.