Arduino Forum

Topics => Robotics => Topic started by: SkyProjects on Aug 21, 2019, 01:04 am

Title: Move stepper by steps.
Post by: SkyProjects on Aug 21, 2019, 01:04 am


The stepper driver I am using.
 TB6600

(https://core-electronics.com.au/media/catalog/product/cache/1/image/650x650/fe1bcd18654db18f328c2faaaf3c690a/t/b/tb6600-stepper-motor-driver.jpg)

The stepper I am using.
jk42hs34-0404 nema 17

(https://botland.com.pl/46497-large_default/stepper-motor-jk42hs34-0404-200-stepspr-12v-04a-025nm.jpg)


So I searched a lot on the internet about how to move a stepper by steps like a servo.
I am trying to build a robotic arm with two steppers, but to do that I need to make it move a certain amount of steps.

Here is my code to make it the two steppers move back and forth:

Code: [Select]
int Distance = 0;
void setup(){
pinMode(8, OUTPUT);

pinMode(9, OUTPUT);

pinMode(10, OUTPUT);

pinMode(11, OUTPUT);

digitalWrite(8, LOW);

digitalWrite(9, LOW);

digitalWrite(10, LOW);

digitalWrite(11, LOW);
}

void loop() {

digitalWrite(8, HIGH);
digitalWrite(10, HIGH);

delayMicroseconds(5000);

digitalWrite(8, LOW);
digitalWrite(10, LOW);

delayMicroseconds(5000);


Distance = Distance + 1;



if (Distance == 6400) {
  delay(100);

if (digitalRead(9) == LOW) {

digitalWrite(11, HIGH);
digitalWrite(9, HIGH); }

else {

digitalWrite(11, LOW);
digitalWrite(9, LOW);


}

Distance = 0;

}


}


How do I move the stepper to the steps i want Ex: move the stepper to the 153rd step.

Thanks.

Title: Re: Move stepper by steps.
Post by: soceraso on Aug 21, 2019, 01:29 am
The university of new orleans robotics club has a guide of motion workshops that may be able to help: https://unorobotics.herokuapp.com/resources (https://unorobotics.herokuapp.com/resources). They use "bit-banging" with specific registers.

here's some pseudocode that uses digitalWrite() that may help as well:

Code: [Select]

const int MOTOR = 8; //whatever pin number step is connected to
const int STEPS = 5000; //number of steps you want to move

for (int i =0; i < STEPS; i++) {

digitalWrite(MOTOR, HIGH);
delayMicroseconds(1000); //change this delay to change the speed of the motor
digitalWrite(MOTOR, LOW); //you may have to adjust the step mode. this code assumes 1/4 step

     }


You may also have a problem that your driver does not have a 5V threshold voltage. Check the data sheet to see if you can trigger it with an arduino.

Another helpful thing are these drivers from pololu: https://www.pololu.com/product/2133
Title: Re: Move stepper by steps.
Post by: TomGeorge on Aug 25, 2019, 02:29 pm
Hi,
What are pins 8, 9, 10 and 11 connected to?
It would be better for the pin numbers to be represented by variable names indicating what they do.

Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png?


Thanks.. Tom... :)