Arduino UNO stepper motor issue

Hi,

I've been fiddling with an Arduino UNO- and have had some unexpected issues I have yet to resolve. I was hoping to get a few ideas of things to look into.

First- I am powering the UNO (which is several years old) via USB from a laptop. I am powering the stepper board with a "wall wart" 3-12v 750ma ps- on 12v.

The first issue I have found, is using a small stepper motor (this-- https://www.allelectronics.com/item/me-125/stepper-motor-and-driver-board/1.html )

when I use only code to step the motor (in loop-- step-, delay, step+, delay, nothing else,) it works great. When I use the extra code (shown below) that adds a do-while loop and a change in stepper position after a condition is met, the stepper loses steps/ doesn't seem to go to the - step positions/ etc.

Could this be because of USB power issues? I do have other boards, UNO's, a redboard, a couple nano clones to try that I haven't done yet.

Any ideas?-- Thanks in advance!


#include <Adafruit_GFX.h>
#include <ArducamSSD1306.h>
#include <Wire.h>
#include <SPI.h>
#define OLED_RESET 16
#define LOGO16_GLCD_HEIGHT 16
#define LOGO16_GLCD_WIDTH 16
ArducamSSD1306 display(OLED_RESET);
const int button_1 = 8;

int sensorPin = A0;
int sensorValue = 0;
int var = 0;
int cycle_delay = 100;

#include <Stepper.h>
#define STEPS 32
Stepper stepper(STEPS, 8, 10, 9, 11);

void setup(){
stepper.setSpeed(600);
}

void loop(){
do{

stepper.step(-110);
delay(800);
stepper.step(110);
delay(800);
var++;
cycle_delay=analogRead(0);
cycle_delay=map(cycle_delay,0,1023,30,600);
}
while (var<cycle_delay);
delay(800);
stepper.step(110);
delay(800);
stepper.step(-110);
delay(800);
stepper.step(110);
delay(800);
stepper.step(-110);
delay(800);
var=0;

}


SPI uses 11,12,13, and 10 must be an output for the Uno to be SPI Master, so I would move away from those pins to start.

Hmm, I must have left that library there after messing with other items, I'll try removing it, but would be curious how it would not affect the stepper in a "simpler" sketch. That what has me the most puzzled.

Apparently seems the issue was my power supply. I switched to a 12v 2amp PS, drove the stepper from it, and also bucked it to 6v to run the UNO. I was able to run my "full" program without missing steps.

Oddly enough the original PS gave me issues with servos as well. No control, they would just run to the hard stops when the signal was hooked up. Using the different PS, they work fine with the same code.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.