--
You received this message because you are subscribed to the Google Groups "accelstepper" group.
To unsubscribe from this group and stop receiving emails from it, send an email to accelstepper...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "accelstepper" group.
To unsubscribe from this group and stop receiving emails from it, send an email to accelstepper...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
hey sandy,
i found some time to check things out which we discussed here.
this is the code i tried (according to your suggestions from above).
i also changed the values around in line
stepper1.moveTo(random(20000,100))
both cases didnt work.
It is getting frustrating as it seems i am too stupid :-(
If it is ok for you, i ll list some further questions and anotations in the
code for further understanding.
#include <AccelStepper.h>
#include <Wire.h>
#include <Adafruit_MotorShield.h>
#include "utility/Adafruit_PWMServoDriver.h"
(Do I need to include all of these? I have an Arduino Uno Rev and the Adafruit Motor Shield Version 2 stacked upon it.)
Adafruit_MotorShield AFMSbot(0x61); // Rightmost jumper closed
Adafruit_MotorShield AFMStop(0x60); // Default address, no jumpers
(I dont understand these two lines. I guess this somehow activates the Motor Shield but I have no clue about the Pins. One of my motors is connected to the block which indicates M1 and M2 and the other one is connected to M3 and M4.)
// Connect two steppers with 200 steps per revolution (1.8 degree) to the top
shield
Adafruit_StepperMotor *myStepper1 = AFMStop.getStepper(200, 1);
Adafruit_StepperMotor *myStepper2 = AFMStop.getStepper(200, 2);
(This initilizes the motors and defines them by the
names *mystepper1 and *mystepper2 ?!)
// you can change these to DOUBLE or INTERLEAVE or MICROSTEP!
// wrappers for the first motor!
(still no clue what a "wrapper" is and does. What do i need it for?)
void forwardstep1() {
myStepper1->onestep(FORWARD, DOUBLE);
}
void backwardstep1() {
myStepper1->onestep(BACKWARD, DOUBLE);
}
// wrappers for the second motor!
void forwardstep2() {
myStepper2->onestep(BACKWARD, DOUBLE);
}
void backwardstep2() {
myStepper2->onestep(FORWARD, DOUBLE); //
}
// Now we'll wrap the 2 steppers in an AccelStepper object
AccelStepper stepper1(forwardstep1, backwardstep1);
AccelStepper stepper2(forwardstep2, backwardstep2);
(What’s the object for?)
void setup()
{
AFMSbot.begin(); // Start the bottom shield
stepper1.setMaxSpeed(180.0); //
Geschwindgkeit Motor 1
stepper1.setAcceleration(80.0);
stepper2.setMaxSpeed(30.0); //
Geschwindgkeit Motor 2
stepper2.setAcceleration(100.0);
stepper1.moveTo(random(20000,100)); // Umdrehungen
Motor 1
stepper2.moveTo(random(20000,200)); // Umdrehungen
Motor 2
}
void loop()
{
//Change direction at the limits
if (stepper1.distanceToGo() == 0 ) {
stepper1.moveTo(-stepper1.currentPosition());
}
if (stepper2.distanceToGo() == 0 ) {
stepper2.moveTo(-stepper2.currentPosition());
}
stepper1.run();
stepper2.run();
}
I think all I need would be something like
- Include the respective libraries
- Define/initialize motor shield
- Define motors
- void setup
Function to make both motors run with specific direction (counter/clockwise) and speed
So sorry, Sandy, for my incompetence.
void setup()
{
AFMSbot.begin(); // Start the bottom shield
stepper1.setMaxSpeed(180.0); // Geschwindgkeit Motor 1
stepper1.setAcceleration(80.0);
stepper2.setMaxSpeed(30.0); // Geschwindgkeit Motor 2
stepper2.setAcceleration(100.0);
stepper1.moveTo(random(20000,100)); // Umdrehungen Motor 1
stepper2.moveTo(random(20000,200)); // Umdrehungen Motor 2
}
This compiles ok for me, but I don't have a motorshield to test it on right here.
sn
void loop()
{
//Change direction at the limits
if (stepper1.distanceToGo() == 0 ) {
stepper1.moveTo(-stepper1.currentPosition());
}
if (stepper2.distanceToGo() == 0 ) {
stepper2.moveTo(-stepper2.currentPosition());
}
stepper1.run();
stepper2.run();
}
--
You received this message because you are subscribed to the Google Groups "accelstepper" group.
To unsubscribe from this group and stop receiving emails from it, send an email to accelstepper...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "accelstepper" group.
To unsubscribe from this group and stop receiving emails from it, send an email to accelstepper...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
hey sandy,
yeah, exactly.
The code we worked on the entire time was a code i found online that somehow got my motors running. I did not get anything to work with the accel stepper library myself.
Like I said in the first post
I need the accel stepper library just to do the following
- Have both motors running endlessly with different speeds and different directions
So that I can have for example
Motor 1 running with a speed of
80 counterclockwise
Motor 2 running with a
speed of 150 clockwise
--
You received this message because you are subscribed to the Google Groups "accelstepper" group.
To unsubscribe from this group and stop receiving emails from it, send an email to accelstepper...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
#include <AccelStepper.h>
#include <Wire.h>
#include <Adafruit_MotorShield.h>
#include "utility/Adafruit_PWMServoDriver.h"
Adafruit_MotorShield AFMStop(0x60); // Rightmost jumper closed
Adafruit_StepperMotor *myStepper1 = AFMStop.getStepper(200,1);
Adafruit_StepperMotor *myStepper2 = AFMStop.getStepper(200,2);
void forwardstep1() {
myStepper1->onestep(FORWARD, DOUBLE);
}
void backwardstep1() {
myStepper1->onestep(BACKWARD, DOUBLE);
}
// wrappers for the second motor!
void forwardstep2() {
myStepper2->onestep(BACKWARD, DOUBLE);
}
void backwardstep2() {
myStepper2->onestep(FORWARD, DOUBLE); //
}
AccelStepper stepper1(forwardstep1, backwardstep1);
AccelStepper stepper2(forwardstep2, backwardstep2);
void setup()
void setup()
{
stepper1.setSpeed(80); // forward speed
stepper2.setSpeed(-150); // reverse speed
}
void loop()
{
stepper1.runSpeed();
stepper2.runSpeed();
}