We’re rewarding the question askers & reputations are being recalculated! Read more.

Hot answers tagged

2

If you have any code you want to run only once at the beggining of your program you can use the setup() method. It can actually do much more than just setting up pins and default values. The code of main function of Arduino (main.cpp) looks like this: int main(void) { //(...) I cut some stuff from here setup(); for (;;) { loop(); ...


2

Generic solution: void loop() { static bool yes_we_did_the_one_time_job = false; if (yes_we_did_the_one_time_job) { do_the_other_jobs(); } else { do_the_one_time_job(); yes_we_did_the_one_time_job = true; } }


2

Depending on the type of stepper motor the answer can be "Yes" or "No". There are two types of stepper motor: Unipolar and Bipolar. Bipolar motors typically have 4 wires and require a H-bridge to drive them. The L239D is a popular (and cheap), though inefficient, H-bridge that is commonly used. But it is possible to build your own H-bridge from discrete ...


1

When motors stuck their current draw increases, you can sense that increase in the current and then change the rotation of the motor. The simplest way to measure current is with using a shunt resistor, for sensing high currents, current sensors based on hall effect sensors is usually used. ACS712 is one example. How to sense current using a shunt? ...


1

The documentation notes a setCurrentPosition() function. void AccelStepper::setCurrentPosition ( long position ) Resets the current position of the motor, so that wherever the motor happens to be right now is considered to be the new 0 position. Useful for setting a zero position on a stepper after an initial hardware positioning move. Has the ...


1

Thanks. Your description of the fault makes sense to me. As you point out blocking would be a problem as I need the counter to continue to be registering while the movement is being executed. I've revised the script as you suggest - inside the loop but outside the if statement - have I done as you meant? But the same problem occurs - the motor advances in ...


1

why exactly is there only one power supply being shown here, is it because the Arduino can get its power from the driver? No. It is assumed that you will provide the power to the Arduino yourself - either through the USB connection to the computer, or through the barrel jack. The thing I want to know, is whether this circuit would function without an ...


1

About errors with stepper motors: Stepper motors introduce errors depending on the forces, that act upon them. For example: If your stepper does not have enough power to accellerate the attached weight, it will loose steps when trying (meaning that the rotor does not do a step despite the coils being controlled for the step). (The same of course also goes ...


1

AccelStepper, as hinted by the name, uses acceleration always. By setting the acceleration high, you reduce the amount of time spent accelerating to the set speed. setAcceleration() sets the rate in steps per second per second. If your MaxSpeed is 200 steps per second, then setting the acceleration to 200*10 means all acceleration is over in 1/10 second. ...


1

Like @chris! suggested, you could include two Stepper variables. So in the line where you were initializing the variable, you could instead have: Stepper steppermotor1(stepsPerRevolution, 8, 10, 9, 11); Stepper steppermotor2(stepsPerRevolution, 4, 5, 6, 7); and then continue on with the code for speed, rotation and so on for each motor.


Only top voted, non community-wiki answers of a minimum length are eligible