In its current state, each stepper provides movement by stopping at a certain distance at the same time. It does this with an accelerated movement. After this process, I want them to wait 3 seconds and move on to the next movement sequence. For example, in a symmetrical way. After these two steps, the steppers will stop.
This is important: I am using accelstepper library. So i want keep using acceleration/decleration on steppers' start-stop.
Welcome to the Arduino forum.
I guess I don't understand. Why not just write the code to delay and do what you want? What have you tried and what are the results? Since your current code must be working properly, carry on with what you are doing.
// MultiStepper.pde
// -*- mode: C++ -*-
// Use MultiStepper class to manage multiple steppers and make them all move to
// the same position at the same time for linear 2d (or 3d) motion.
#include <AccelStepper.h>
#include <MultiStepper.h>
// EG X-Y position bed driven by 2 steppers
// Alas its not possible to build an array of these with different pins for each :-(
AccelStepper stepper1(AccelStepper::FULL4WIRE, 2, 3, 4, 5);
AccelStepper stepper2(AccelStepper::FULL4WIRE, 8, 9, 10, 11);
// Up to 10 steppers can be handled as a group by MultiStepper
MultiStepper steppers;
void setup() {
Serial.begin(9600);
// Configure each stepper
stepper1.setMaxSpeed(100);
stepper2.setMaxSpeed(100);
// Then give them to MultiStepper to manage
steppers.addStepper(stepper1);
steppers.addStepper(stepper2);
}
void loop() {
long positions[2]; // Array of desired stepper positions
positions[0] = 1000;
positions[1] = 50;
steppers.moveTo(positions);
steppers.runSpeedToPosition(); // Blocks until all are in position
delay(1000);
// Move to a different coordinate
positions[0] = -100;
positions[1] = 100;
steppers.moveTo(positions);
steppers.runSpeedToPosition(); // Blocks until all are in position
delay(1000);
}
Then you wouldn't have to carefully compute each axis's accelerations and the maximum speeds so they end their motions and start/stop their accelerations at the same times.
Oops. That's wrong. Multistepper doesn't do acceleration:
Thanks.
As i said on title, i dont know how to code next step to do second process. I just want to move the position of the steppers to a different position after the first process in a run. There is no problem with the current process. If i code them on void loop section like this, all steppers moving simultaneously as i want. If i code them on void setup section they are moving in order. Probably have to code what I want to do in the void loop section. But I dont know what to write, I'm newbie.
Yes. This is exactly what I want. I have a robot arm project. I want to move them to several positions with 3 or 4 steps in a single run command. These steps will run in a order. The code I showed you is the first step.
if you're trying to build some animated robot (e.g. dog) several steppers need to move in unison between each movement of the appendages. 1+ motors needs to be moved for each "movement".
there would be a sequence of movements and then a sequence might repeat
but for a single movement, all the motors would be stepped at various times so that they all start and stop at the same time. once motor may require 20 steps and another 12 steps
so at the very least, if all motor need to complete the movement in time T and the motor requiring the most steps requires N steps, then that motor needs to be stepped every T/N seconds.
other motors wouldn't be stepped every T/N seconds. you'd need to keep track of which T/N events to step the other motor. if N is 20 and another motor requires 12 steps then it would stepped every 20/12 = 5/3 T/N events
the following shows how 4 motors might be stepped using the T/N approach. the 4 motors require 20, 7, 12 and 13 steps / movement. the columns show an accumulated step amount. a step is made when the accumulated value is >= 1. a "*" when a step occurs and the accumulated value subtracted by 1
Yes, I am aware of this situation. This is how it should be. I just want to move the position of the steppers to a different position after the first process in a run. After all i'll calculate what you explained. Denavit Hartenberg calculation is also a separate issue
The way CNC/3dPrinter machines solve synchronized, straight-line motion is by figuring out the axis with the longest motion, planning the speed/acceleration curve for it, and synchronizing all the slower axes with the motion of the controlling axis. The synchronization uses the Bresenham Algorithm trick that all the slower axes will step at most once per fast-axis-step.
If you identify the fastest axis and let AccelStepper determine its acceleration, you could step the other, slower axes as needed when that fast axis steps.
AccelStepper doesn't directly expose when a step happens but you could use something like this to determine if a step happened:
Now I can move 2 steppers as I said. However, when I install more than two steppers, it runs smoothly until the last step I process, and then enters the loop at the last step. I think I'm having a problem with the following part;
I couldn't fully adapt it here. There is no problem while using 2 steppers but +2 steppers not compatible for this i think. How can i my first question with +2 steppers
The floating point arithmetic, roundoffs, and comparisons might make it hard to tell if a number is 1.00 or not, which could be the cause.
This T/N approach almost like the integer based Bresenham algorithm. If you were to multiply the table, increments, and decision rule by 40, the operations and storage would all be in perfect integers. Bresenham also shifts the accumulator initialization a bit to center the slower series of steps within the run and to make the decision-rule comparison into a comparison with zero.