Arduino Forum

Using Arduino => General Electronics => Topic started by: IRLSteveO on Mar 07, 2019, 06:03 pm

Title: Bipolar Stepper Motor with Gecko Drive 201X
Post by: IRLSteveO on Mar 07, 2019, 06:03 pm
Hi All

Completely new to all of this, and having to pick up half completed projects. I am using the Arduino to control me motor and gecko drive 201X. I have the script written and proven, but I cannot seem to increase the speed of the motor through the pot on the gecko drive. The motor is to turn clockwise until a limit switch is triggered, and then begins to turn counter-clockwise, and so on.

Anyone out there that can review the script and advise as to where the speed or RPM's can be amended??

const int stepPin = 9;
const int dirPin = 8;
const int topPin = 4;
const int bottomPin = 5;
int topValue = 1;
int bottomValue = 0;

void setup()
{
pinMode(topPin, INPUT_PULLUP);
pinMode(bottomPin, INPUT_PULLUP);
pinMode(stepPin, OUTPUT);
pinMode(dirPin, OUTPUT);
pinMode(13, OUTPUT);
digitalWrite(dirPin, HIGH);
Serial.begin(9600);
}


void loop(){
    digitalWrite(stepPin, HIGH);
    delay(5);
    digitalWrite(stepPin, LOW);
    delay(5);


topValue = digitalRead(topPin);
bottomValue = digitalRead(bottomPin);
if((topValue == 1)&&(bottomValue == 1))
{}
else if((topValue == 1)&&(bottomValue == 0)){digitalWrite(dirPin, HIGH);}
else if((topValue == 0)&&(bottomValue == 1)){digitalWrite(dirPin, LOW);}
else{}

}
Title: Re: Bipolar Stepper Motor with Gecko Drive 201X
Post by: groundFungus on Mar 08, 2019, 01:29 am
Quote
where the speed or RPM's can be amended??
Code: [Select]
digitalWrite(stepPin, HIGH);
    delay(5);
    digitalWrite(stepPin, LOW);
    delay(5);

This code sets the speed of the stepper.   The length of the delays set the speed.  Reduce the delays to speed the motor up.

Robin2's simple stepper code (https://forum.arduino.cc/index.php?topic=277692.0) shows how to adjust the speed of a stepper.  It is written for the A4988 or DRV9925 drivers but should work fine with your driver.   Note that the pulse high time is constant (20us) and the time between steps is adjusted to set the speed.