Hi,
i have a Teensy 4.0 attached to a DRV8825 Stepper Driver using the minimal wiring diagram from here:
https://www.pololu.com/product/2133
The driver is connected to the Teensy using the pins 3V/GND/5/6.
Motor is a SM-42BYG011-25 (SparkFun / others) 12V/0.33A using it's own wall plug psu.
This basically works ok, but after running a test program for some minutes, the motor starts erratic behaviour and the Teensy seems to reboot / reflash itself. Sometimes this happens in short intervals. Even sometimes the Teensy "flasher" shows "Error" or some Bootloader warning. Connections between Teensy and the DRV8825 are soldered so it's no breadboard installation. Teensy is powered using USB, behaviour also happens if an additional 3.7 V Accu is attached via Teensy Feather adapter. During the "reboots" it also seems to disconnect from the USB. Serial device is gone and OSX mentiones disconnect/connect of USB device.
What's going on here? What could cause this "reboots"? How can i debug this?
Using platformio and this packages:
PACKAGES:
- framework-arduinoteensy 1.152.0 (1.52)
- toolchain-gccarmnoneeabi 1.50401.190816 (5.4.1)
Code below.
Best regards,
Michael
i have a Teensy 4.0 attached to a DRV8825 Stepper Driver using the minimal wiring diagram from here:
https://www.pololu.com/product/2133
The driver is connected to the Teensy using the pins 3V/GND/5/6.
Motor is a SM-42BYG011-25 (SparkFun / others) 12V/0.33A using it's own wall plug psu.
This basically works ok, but after running a test program for some minutes, the motor starts erratic behaviour and the Teensy seems to reboot / reflash itself. Sometimes this happens in short intervals. Even sometimes the Teensy "flasher" shows "Error" or some Bootloader warning. Connections between Teensy and the DRV8825 are soldered so it's no breadboard installation. Teensy is powered using USB, behaviour also happens if an additional 3.7 V Accu is attached via Teensy Feather adapter. During the "reboots" it also seems to disconnect from the USB. Serial device is gone and OSX mentiones disconnect/connect of USB device.
What's going on here? What could cause this "reboots"? How can i debug this?
Using platformio and this packages:
PACKAGES:
- framework-arduinoteensy 1.152.0 (1.52)
- toolchain-gccarmnoneeabi 1.50401.190816 (5.4.1)
Code below.
Best regards,
Michael
Code:
/*
Example sketch to control a stepper motor with A4988/DRV8825 stepper motor driver
and Arduino without a library. More info: https://www.makerguides.com
*/
#include <Arduino.h>
// Define stepper motor connections and steps per revolution:
#define dirPin 5
#define stepPin 6
#define stepsPerRevolution 200
void setup() {
Serial.begin(115200);
// Declare pins as output:
pinMode(stepPin, OUTPUT);
pinMode(dirPin, OUTPUT);
Serial.println("===============================================================");
Serial.println("Setup done.");
Serial.println("===============================================================");
}
void step() {
int d = 900; // 800 - 1000 is best
digitalWriteFast(stepPin, HIGH);
delayMicroseconds(d);
digitalWriteFast(stepPin, LOW);
delayMicroseconds(d);
}
void stepn(int n) {
Serial.printf("Step n: %d ", n);
uint32_t t1 = millis();
for (int i = 0; i < n; i++) {
step();
}
uint32_t elapsed = millis() - t1;
Serial.printf("%dms\r\n", elapsed);
}
void loop() {
Serial.println("Loop");
// Set the spinning direction clockwise:
Serial.println("Spin clockwise.");
digitalWrite(dirPin, HIGH);
stepn(stepsPerRevolution);
Serial.println("Wait 1s...");
delay(1000);
yield();
// Set the spinning direction counterclockwise:
Serial.println("Spin counterclockwise.");
digitalWrite(dirPin, LOW);
stepn(stepsPerRevolution);
Serial.println("Wait 1s...");
delay(1000);
yield();
Serial.println("Ten rotations.");
digitalWrite(dirPin, HIGH);
stepn(stepsPerRevolution * 10);
digitalWrite(dirPin, LOW);
digitalWrite(stepPin, LOW);
Serial.println("Wait 10s...");
delay(10000);
yield();
}