Stepper acceleration for a timed duration

I'm green but have successfully completed some real world projects with the help of others here, for some reason I can't get back into that account, sorry if this gets long. I'm trying to make something like this video, (sorry I tried to use link button above several times and it was giving a %22hhttps error, it adds %22 into any link I tried. Anycubic Wash and Cure First Look - YouTube ). It ramps up to speed, runs for x minutes, reverses for x minutes then stops. From my current testing (described below) It will need the acceleration to overcome the water pressure. The second part of this will turn the motor at about 10 rpm in a single direction, but that is a future addition I'm not at all worried about at this time.

Did a couple hours of digging last night and it seems like AccelStepper will easily do the acceleration I need, but won't easily do the timed cycle. How do I go about doing the timing/duration part of this problem? I honestly have no idea what top speeds need to be at this point. It's just got to create a vortex in the water, but I can design and print different styles of impeller that may be more efficient spinning the water at lower rpm. Currently have 12 volt power supplies here with varying current output for motor, but not beyond getting a higher voltage supply to get the speeds where they need to be.

Now for what I have tried to this point, not much info here pertinent to the issue above if you want to stop reading, just where I'm at. I have tried this with the guts of a magnetic stir plate. Basically a brushed dc motor with a magnet bar on the armature with a potentiometer. It would only move a small bar type impeller design in water, if I ramped up the power slowly, and it didn't move it enough to get the vortex. So I tried different impeller designs including another bar style just longer, one being an almost direct copy of the one in the video above. I could get them to couple to each other but if I ramped up the power it would eventually just free spin the motor because the coupling wasn't strong enough to turn the impeller. If I beefed up the magnets enough to improve coupling, it was too much magnet that the motor wouldn't even turn. I also tried with a brushless motor and esc (small drone size) I have here, but that was way too high of an rpm to be useful. I found pics and a couple videos of the above unit on a page about repairing a problem, and it shows a stepper being used for this task. There are 3 commercial units on the market that do this same thing, and I know at least 2 are using steppers, and assume the 3rd is too. The one in the video is being run by a 12v 6a power supply.

Edited to add: I have a 2a nema size 17 and DRV8825 driver coming to start testing with. Should be here next week. I haven't really worked with this setup much just the small stepper and driver that came with my arduino starter kit a while back.

I've also come across this video that shows the competitor unit, with a little bit more flexibility in the times, you can choose in 1 minute intervals and it halves the cycle to do the same as above with the reverse halfway through. This would be a great add, but need to slay the bigger dragon first. This video shows the whole cycle a little better. Best I can tell this unit uses a metal plate the spins in the bed, and the magnets of the impeller just stick to that plate for the coupling instead of magnet to magnet. My test bed with the brushless I described in the first post was designed similar to this.

Use millis, set a time for the change in acceleration when You set the first acceleration. Then just watch mills and compare if it's time for that change in acceleration.

ericksaint:
it seems like AccelStepper will easily do the acceleration I need, but won't easily do the timed cycle.

Surely the simple solution is to choose a maximum speed (steps per second) and then calculate how many steps are needed to keep the motor running for the desired time.

I suspect the small timing error due to the effect of acceleration and deceleration won't matter. If it does, it would be possible to calculate how long the acceleration phase takes as the acceleration is defined a the number of steps the speed increases every second. (steps per second per second).

...R

Railroader:
Use millis, set a time for the change in acceleration when You set the first acceleration. Then just watch mills and compare if it's time for that change in acceleration.

I'll look into this, I did think about it, but seemed like everything I came across mentioned having to use steps with AccelStepper.

Robin2:
Surely the simple solution is to choose a maximum speed (steps per second) and then calculate how many steps are needed to keep the motor running for the desired time.

I suspect the small timing error due to the effect of acceleration and deceleration won't matter. If it does, it would be possible to calculate how long the acceleration phase takes as the acceleration is defined a the number of steps the speed increases every second. (steps per second per second).

...R

Your suspicion is correct, won't matter in the least, just trying to ballpark those 2/4/6 minute overall durations, and it doesn' have to move a precise amount of steps. I'll have to do some calculations when I actually figure what the speed needs to be to get my vortex. I wasn't sure if the hardware would keep up with the amount of steps it seems like a ton. I was also trying to math and didn't know if I was on the right path.

Be gentle, steppers are foreign to me. Also these numbers are just arbitrary and not real goals. Just trying to understand. So the motor I have coming for testing is 2A with a 3mH induction. According to a calculator I found online at 12 volts it has a max speed of 5 rev/s. Or am I totally off on this? This is where I started getting foggy last night and stepped away from the computer until morning.

5 x 60 = 300 steps/second?
300 x 60 = 18000 steps/minute
18000 x 3 = 54000 steps for 3 minute run time?

ericksaint:
So the motor I have coming for testing is 2A with a 3mH induction. According to a calculator I found online at 12 volts it has a max speed of 5 rev/s.

Please post a link to the datasheet for the motor.

For higher speeds you may need a higher voltage power supply.

For a 2 amp motor make sure to use a driver than can deliver at least 3 amps.

5 x 60 = 300 steps/second?

Most stepper motors have 200 steps per revolution which would mean 1000 steps for 5 secs or 200 steps per second. That would mean 200 * 60 * 3 = 36,000 steps for 3 minutes (if my maths is correct)

...R

Here is the motor I have on the way.

This is the sheet for the driver I ordered. I went with the 8825 at 2.2 amp, over the 4988 with 1 amp.

I'm ok with more voltage, figured 12 wouldn't cut it, though I was curious how they managed it in the commercial units, boost board inside maybe.

Yeah, I think I wasn't doing the math right. This was the calculator that gave me the 5 revolution per seconds as the max. given the specs I used.
https://www.daycounter.com/Calculators/Stepper-Motor-Calculator.phtml

You will be lucky to get more than about 1.5 or 1.7 amps from a DRV8825. So it seems a waste buying a 2 amp motor.

It's never a good idea to use electronic components close to their maximum.

I don't know anything about stepper motor max speed calculation formulae

...R

Robin2:
You will be lucky to get more than about 1.5 or 1.7 amps from a DRV8825. So it seems a waste buying a 2 amp motor.

It's never a good idea to use electronic components close to their maximum.

I don't know anything about stepper motor max speed calculation formulae

...R

I just grabbed a couple parts to test proof of concept. They will serve as backups for my 3d printer. If this actually works like I want, I will Likely get better parts or better matched parts for this build.
I'm trying to find the small stepper and driver that came with my started kit, to test with until parts get here. Thanks for your help.

ericksaint:
I just grabbed a couple parts to test proof of concept.

That's fine.

...R

So parts came in. After a few hours of struggling with what turned out to be a junk breadboard, now in the trash, I'm in business. Seems that the Bounce example in the AccelStepper does almost exactly what I need out of the box. I've gotten it to run with the load of the water, at a speed fast enough for my needs without throwing the impeller. Except the timing is off. When I set it to 40000 steps it runs forward 30 seconds +/-, but when it does it's reverse it runs for about a minute 30 seconds. Then repeats. So I need to look into the library docs and see what's the best way to tackle that.

void loop()
{
    // If at the end of travel go to the other end
    // Reverse goes 1:30 until reset
    if (stepper.distanceToGo() == 0)
      stepper.moveTo(-stepper.currentPosition());
    

    stepper.run();
}

On a whim I tried to change the above to stepper.moveTo(-40000); but it just ran backwards for the 1:30 then stopped, instead of starting the forward move again.

Any tips? The whole code is below.

// Bounce.pde
// -*- mode: C++ -*-
//
// Make a single stepper bounce from one limit to another
//
// Copyright (C) 2012 Mike McCauley
// $Id: Random.pde,v 1.1 2011/01/05 01:51:01 mikem Exp mikem $

#include <AccelStepper.h>

// defines pins numbers
const int stepPin = 3;
const int dirPin = 4;

// Define a stepper and the pins it will use

AccelStepper stepper(AccelStepper::DRIVER, stepPin, dirPin);

void setup()
{  
  // Change these to suit your stepper if you want
  stepper.setMaxSpeed(1400); //5000max no load 1400max with water
  stepper.setAcceleration (500); //600max
  stepper.moveTo(40000); //40000 goes forward 30 seconds
 
}

void loop()
{
    // If at the end of travel go to the other end
    // Reverse goes 1:30 until reset
    if (stepper.distanceToGo() == 0)
      stepper.moveTo(-stepper.currentPosition());
    

    stepper.run();
}

This line makes it move 80,000 steps

stepper.moveTo(-stepper.currentPosition());

Think about it.

You probably want moveTo(0)

...R

Man. Light dawns on marble head. How did I overlook that? I was so happy to get an actual working result, wasn't looking closer enough. Perhaps I need to step back and get back to basics.

Thanks again for your help.

Small things can make huge impacts.....

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.