Go Down

Topic: Controlling 25 stepper motors (Read 411 times) previous topic - next topic

Ken-preston

Sep 16, 2018, 03:20 pm Last Edit: Sep 16, 2018, 03:26 pm by Ken-preston
Hi everyone! I'm trying to figure out what I should be using/doing/purchasing for my school project:

5x5 grid of motors so 25 motors total
Each motor only needs to rotate in 90 degree increments and only in one direction
None of the motors will have a load so strength/torque shouldn't be an issue

I'm considering 28BYJ-48 stepper motors from amazon as they're cheap and come with drivers, but I'd certainly consider better motors.

From searching the forums and other sites, I'm not sure if I should get a couple relay boards or would motor shields be a better choice. I'm pretty sure I need a 12v lithium battery to power all the motors separate from the Arduino and to avoid using a wall wart.

I currently have an Arduino Uno but can purchase something else if more appropriate.

I'm mainly concerned with the proper mechanical/electronic setup; I plan to choreograph the motors with code (I'm currently writing sketches in Processing to figure out the movements). The goal is to create larger grids (50 x 50) but for now a 5x5 grid will be a proof of concept.

If there's anything I need to explain more let me know! Thanks in advance!

Robin2

Each driver for the 28BYJ motor needs 4 Arduino I/O pins. An Uno has enough I/O pins for 4 drivers. A Mega has enough I/O pins for about 15 drivers. I'm sure you can see an immediate problem.

Also if you want all the motors to move at the same time with a high step rate then a 16MHz Arduino may not be fast enough.

If you describe the project you want to create it will be much easier to give useful advice.

...R
Two or three hours spent thinking and reading documentation solves most programming problems.

luni64

Instead of the "ULN2003 drivers" included at Amazon, try to get some DRV8825 or A4988 drivers instead. They are also available at Amazon for < $3 if you buy five. 


Those drivers have a convenient STP/DIR interface. Since all motors will move in the same direction  you can simply hook up all the DIR signals to GND or +5V. => you will need only 25  pins for the step signals. 

I suggest to use a Teensy 3.2 or Teensy 3.5 to handle the motors. Both have enough pins and much more computation power than a Uno or a Mega . You can use TeensyStep https://github.com/luni64/TeensyStep to controll the motors. It is currently limited to 10 simultaneuosly moved motors but I can open that to 25 motors if you need.

outsider

#3
Sep 16, 2018, 07:38 pm Last Edit: Sep 16, 2018, 08:28 pm by outsider
28BYJ-48s are unipolar motors, will the A4988 type drivers work? A tpic6B595 shift register can drive 2 28BYJ-48s using only 3 Arduino pins and can be daisy chained.
Here's a test sketch for one motor:
Code: [Select]

/* M28BYJ-48basic_SR.ino
   uses tpic6B595 shift register

   pin 7 to pin 8 on tpic6B595, pin 4 to pink,   coilA
       8 to pin 12,                 5    yellow, coilC
      12 to pin 13,                 6    orange, coilB
      11 to pin 3,                  7    blue,   coilD
      5V to pin 2                                        external 5V + to motor RED wire
   GND to pin 10                                   external 5V -  to tpic6B595 pins 11, 19
   Type a number in top of serial monitor for steps to go, & press [ENTER].
 */
uint32_t tStart,
         tEnd = 46627UL; // delay between steps, (microseconds),
                        // higher num, lower speed
const byte stepNr [4] = {0x01, 0x02, 0x04, 0x08},
           latchPin = 8,
           clockPin = 12,
           dataPin = 11;
byte stepCntr = 0;
long stg, // steps to go
     revCntr;
bool timing = false;

void setup()
{
  Serial.begin(9600);
  pinMode(latchPin, OUTPUT);
  pinMode(dataPin, OUTPUT); 
  pinMode(clockPin, OUTPUT);
  shiftOut(dataPin, clockPin, MSBFIRST, 0);
  digitalWrite(latchPin, HIGH);
  delay(100);
}

void loop()
{
  if(micros() - tStart > tEnd)
    timing = false;
  if (!timing && stg != 0)
  {
    stg < 0 ? stepCntr-- : stepCntr++; // sets direction
    bitClear(PORTB,0);
    //digitalWrite(latchPin, LOW);
    shiftOut(dataPin, clockPin, MSBFIRST, stepNr[stepCntr & 0x3]);
    bitSet(PORTB,0);
    //digitalWrite(latchPin, HIGH);
    stg < 0 ? stg++ : stg--; // adds to or subtracts from stg
                             // depending on direction
    tStart = micros(); timing = true;
///*                             
  if(stg % 2048 == 0)
    {
      revCntr++;
      Serial.print(revCntr); Serial.print("\t");
      Serial.println(stg);
      if(stg == 0)
        revCntr = 0;
      //delay(1000);
    }
//*/
  }

       
  if (Serial.available() > 0)
  {
    stg =  Serial.parseInt();
    Serial.println(stg);
  }
 
}

http://www.ti.com/lit/ds/symlink/tpic6b595.pdf

jremington

#4
Sep 16, 2018, 08:19 pm Last Edit: Sep 16, 2018, 08:23 pm by jremington
Quote
28BYJ-48s are unipolar motors, will the A4988 type drivers work?
Yes, just ignore the motor winding center tap. You may need to increase the motor supply voltage.

If you go that way, only one processor pin is required to control each motor. Since the motors are supposed to rotate in only one direction, the DIR input could be wired appropriately to Vcc or GND, and only the STEP input used.

Robin2

Yes, just ignore the motor winding center tap. You may need to increase the motor supply voltage.
Won't the driver be very confused about the amount of current flowing when the two coils are inter-connected?

...R
Two or three hours spent thinking and reading documentation solves most programming problems.

jremington

No, it works fine.  Try it and see.

As long as both coils are always powered (i.e. full step mode), the center tap of each coil is always at potential Vmotor/2. Transients may affect motion slightly, but I've never been able to see the effect.

Those in doubt can always break the connection between the two coils, as described here.

Ken-preston

Thanks for all the advice so far! I've only worked with modifying Arduino tutorials up till now, so this is pretty new territory for me. Now I'm looking at getting the A4988 drivers and a Teensy 3.5.

I'll try to add more detail about the project:
5x5 grid of motors (50 x 50 in the final plan), each one only moves in 90 degree increments, to a max of 360 degrees. Only one needs to move at a time (for now).

Basically, one motor will rotate, up to 360 degrees, over the span of a second or so, and then stop, and then another motor, anywhere in the grid, starts rotating for a second, stops, and so on.
That's pretty much it (this is just my part of the project - my partner's part involves using a camera to detect which motor is running, training a program to follow tiny movements).


Robin2

5x5 grid of motors (50 x 50 in the final plan), each one only moves in 90 degree increments, to a max of 360 degrees.
If you only need a max of 360° of motion and then reverse the direction back to 0° servos might be more suitable than stepper motors.

Most servos only move through about 180° but you can get ones that work over a larger range. Sail winch servos typically move through 3 revolutions with position control.

...R
Two or three hours spent thinking and reading documentation solves most programming problems.

Paul_KD7HB

I see some recommend a 1 amp power supply for one of those motors and running from 5 volts up to 12 volts. Does your scheme allow space for the power supply and the power wiring?

Paul

luni64

#10
Sep 17, 2018, 10:06 am Last Edit: Sep 17, 2018, 10:07 am by luni64
Now I'm looking at getting the A4988 drivers and a Teensy 3.5.
Very good idea..

Quote
Basically, one motor will rotate, up to 360 degrees, over the span of a second or so, and then stop, and then another motor, anywhere in the grid, starts rotating for a second, stops, and so on.
As long as you need to move one motor at a time only I'd connect the motors via two 16bit multiplexers. If your step frequency is not too high something like this https://www.amazon.com/Arduino-Breakout-CD74HC4067-Multiplexer-Demultiplexer/dp/B07DWFM22B should work.


Robin2

#11
Sep 17, 2018, 10:34 am Last Edit: Sep 17, 2018, 10:35 am by Robin2
I just remembered another important thing - how do you plan to know when each motor is at the ZERO or HOME position?

With a stepper motor the usual process at startup is to move the motor until it triggers a HOME switch. Those switches (whether optical or mechanical) will also need I/O pins.

Servos have the advantage that they include their own electronics and position sensing system.

...R
Two or three hours spent thinking and reading documentation solves most programming problems.

luni64

With a stepper motor the usual process at startup is to move the motor until it triggers a HOME switch. Those switches (whether optical or mechanical) will also need I/O pins.
If, during homing, you move one motor after the other you can combine all those sensor outputs ("OR them together") so you only need one input for the homing. Alternatively you could use another multiplexer for the sensor lines. This also requires only one additional input. 

Robin2

#13
Sep 17, 2018, 06:06 pm Last Edit: Sep 17, 2018, 06:07 pm by Robin2
If, during homing, you move one motor after the other you can combine all those sensor outputs ("OR them together") so you only need one input for the homing. Alternatively you could use another multiplexer for the sensor lines. This also requires only one additional input.
That is certainly possible.I like the idea of connecting them all to one I/O pin and homing them one at a time.

There is also the business of physically installing and connecting up all the detectors. None of that is needed withe servos.

...R
Two or three hours spent thinking and reading documentation solves most programming problems.

Go Up