DIY ClockClock

Hi,

I'm looking to create a DIY version of the Clock Clock (https://clockclock.com/), and am after some much needed help in where to begin. (I have mucked around with Arduino, but not steppers or any large project - so let me know if I've bitten off more than I can chew... although I feel like large projects are the best place to learn the most).

There are 24 clocks, each with two stepper motors (one for each hand), and they will be driven in a similar manner to this https://content.instructables.com/ORIG/F7R/E67D/K9JI9Z4C/F7RE67DK9JI9Z4C.jpg?auto=webp&frame=1&width=1024&fit=bounds&md=43871eebf10f097326c95e594e0e5596. They would all need to move simultaneously.

My very basic approach at the moment is:

48x - 28BYJ-48 stepper motors, each with a single ULN2003 driver.

an Ardunio (mega or uno?)

48x - hall effect sensors to calibrate the position of the hands at startup.

48x - 74HC595N shift registers

a RTC module to hold the time

What is the easiest and cheapest way to control 48 stepper motors simultaneously with an Arduino uno/mega. I've read it could be possible with shift registers (74HC595N)? How would you go about this project?

At this stage I wouldn't worry about doing the visual effects, only showing the time. I thought it would be a simple process of storing the current step position of each hand (saying vertical up is 0), and then the future 'step' position of each hand in the next minute (ie stepper has 2048 steps, so a hand pointing at 6oclock would be position 1024, and hand pointing to 3 o'clock would be 512). And then every minute, moving each hand the required steps clockwise and updating the current and future position.

Basically is this possible with the Arduino? I was thinking an Arduino Uno, with 9 of its pins connected to 3 shift registers, each one being daisy chained to 7 other shift registers. Each shift register would be connected to 2 stepper drivers. This would give me 192 output pins, whilst only using 9 pins of the Arduino, which is the required number for the 192 (48*4) pins required for the stepper drivers... Is this possible, or will it somehow blow my Arduino?

Read this thread.
Trying to develop a 100x100mm 48-stepper (28BYJ-48) driver board that can be controlled with a small board, such as a Nano. Nothing else needed, apart from the supply.
Others are taking the big-board approach, with ULN2003 drivers.
Up scaling could be harder than you think, so start coding with one or two motors first.
Leo..

1 Like

Scrap the ULN2003s - obsolete IC, waste of (pardon the expression,) time! :grinning:

For these tiny steppers, a TPIC6B595 executes the function of a 74HC595 and drives two unipolar steppers. So 24 TPIC6B595s.

There do occasionally seem to be some problems using too many TPIC6B595s in a chain, so three chains of 8 may be a good idea. OTOH, you can use SPI to drive them if you use the same clock and data lines for all and buffer those two lines with a 74HC14.

A UNO is not a practical thing to assemble for serious projects - unless you have a "shield" which does the job in one. Use a Nano or if it does not need re-programming, a Pro Mini.

OK, this project clearly will need re-programming from (sic.) time to time - use a Nano. :sunglasses:

This much for a starter.

The TPIC6C595 power shift registers can drive 2 28BYJ-48s and replace the ULN2803s, and they are daisy chainable.

OOPS! Hey Paul. :stuck_out_tongue:

Thank you alot for the tips on where to start - I don't even really know where to begin. I will look into the TPIC6B595 and Nano. Thanks Paul and JCA34F. Will look into that thread as well Leo, thankyou.

Paul and JCA. To get a better idea of the solution using a TPIC6B595 and a nano. (I think SPI may be beyond my pay grade Paul...)

Say I were to just do one row of 4 motors, giving just 2 clocks...
I'd daisy chain 2 TPIC6B595 together, each one connected to two 2 28BYJ-48 stepper motors.

To step a 28BYJ-48 it requires 4 'pulses'. Each one would be a distinct 2 byte binary number, and then I would just step through each motor until it has reached the desired position? So my pseudo code to get two clocks at 12:00 to 6:30 and 9:30 respectively would be...

motor_steps = {0b1010, 0b0110, 0b0101, 0b1001}, // 'pulses' required for a 28BYJ-48 step 
                                                 /// (step sequence may be incorrect. but you get the idea.

curr_pos = {0,0,0,0} // initial positions
future_pos = {1024,512,1536, 0} // first clock at 6:30, second clock at 9:00

// whilst at least one of the steppers hasn't reached its destination
do while curr_pos[1] !=future_pos[1] || curr_pos[2] !=future_pos[2] || 
             curr_pos[3] !=future_pos[3] || curr_pos[4] !=future_pos[4] {
    shift = {0b 0000 0000 0000 0000} // a binary representation of the pulse for each motor
    for i = 1 to 4 {
        for j = 1 to 4 {
            if curr_pos[j] != future_pos[j] {
                // hasn't reached destination yet, so add the pulse
                shift << 4
                shift = shift & motor_steps[i]
            }
            else {
                // has reached destination, so no pulse
                shift << 4
            }
        }
        shiftOut(..., shift) // send binary representation to the pulses to the firstTPIC, for it to be 
                                  // rippled down the daisy chain
    }
    curr_pos[1] ++
    curr_pos[2] ++
    curr_pos[3] ++
    curr_pos[4] ++
}

The idea that this is scalable, with 3 sets of 8 TPIC, each TPIC controlling clock (two steppers). However will I run into overflow issues with the 'shift' in the above.... it will be 64 bits...

If you have the time, are you able to go through the SPI solution - because from what I have read that seems simpler, more eloquent, and quicker?

Also, why a Nano over a Uno? or is it that a Uno is more of a prototyping board, and a nano is for a final product?

The code to control 48 (or more) steppers is in the link I gave you.
Including coil drive sequence for full torque or low power, acceleration/deceleration and SPI.
Not the final version yet, but see if you can follow it so far.
Leo..

OP's link: https://clockclock.com/

And image:

cbeckingsale:
Also, why a Nano over a UNO? or is it that a UNO is more of a prototyping board, and a Nano is for a final product?

Pretty much the case. :sunglasses:

The UNO does not fit in a "solderless breadboard" or perfboard/ stripboard. It has sockets so you can plug in a "shield" or jumper leads, but is otherwise impractical to connect to a PCB.

You can solder wires to a Nano without its headers, or fit the headers and plug into a breadboard or perfboard, stripboard or your own PCB as a "daughterboard".

I was wondering, given that these are 5-wire unipolar motors with a gearbox, and there are other gears involved and only the light weight of the clock hands to move, I don't think it will be necessary to keep any of the motor coils engaged, to prevent slipping, between movements?

If so, maybe the component count of the driver circuit could be reduced by wiring the coils as a matrix? There will be 192 coil-end wires and 48 centre-tap wires.

If clocks were grouped into 3 clocks, ie. 6 motors, per group, with their centre-taps commoned, there would be 24 coil-ends to drive, which could be done with 3 tpic6b595. A 4th shift register, or 8 arduino pins, could drive 8 p-channel mosfets to drive the centre taps of the 8 groups.

This would slow down updating all 24 clocks by a factor of 8, but might still be fast enough. Thoughts? Would some diodes be needed, for example?

Uno is more of a prototyping board, and a nano is for a final product

Uno is for use with "shields". Shields are ready-made circuits, the same size and shape as Uno, that plug directly on top of the Uno. If you can find a shield that matches the requirements of your project, then great, buy an uno and that shield. I don't think you will find a shield that can drive 48 steppers and hall sensors.

For anything else, you will need to prototype and build your own circuit, on breadboard, stripboard or whatever. Now uno becomes a PITA. It won't plug into a breadboard or stripboard. Nano, Pro Micro, and all other more recent arduino designs, you may notice, have 2 rows of pins a on 0.1" grid, making them easier for both prototyping and final circuit build.

PaulRB:
Thoughts? Would some diodes be needed, for example?

You bet!

Here's a "toy" program I wrote years ago for one motor. It worked with a Nano. :stuck_out_tongue:

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

   pin 8 to pin 12 on tpic6B595, pin 4 to pink,   coilA
      12 to pin 13 "      "          5    yellow, coilC
      11 to pin 3  "      "          6    orange, coilB
                          "          7    blue,   coilD

   Type a number in top of serial monitor for steps to go, & press [ENTER].
*/
uint32_t tStart,
         tEnd = 4883UL; // delay between steps, (microseconds),
                        // ~ 6 RPM, higher num, lower speed
const byte stepNr [4] = {0x01, 0x02, 0x04, 0x08},
           latchPin = 8,
           clockPin = 12,
           dataPin = 11;

byte stepCntr = 0;
long stg = 2048; // steps to go
     
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 (Serial.available() > 0)
  {
    stg =  Serial.parseInt();
    Serial.println(stg);
  }
}

Paul__B:
You bet!

Yeah, probably 192 of them, making the circuit almost as complex as using 24 tpic chips. Perhaps not worth it, then.

Have a look at how old fashion master clocks , or factory clocks used to work.

The master clock sends out a pulse every 30sec and all the slave clocks click on in response to receiving it .
You could make all your slaves identical with stepper motors and a simple processor and drive the lot from your master processors
Send a long pulse at mid night to synchronise them all back to 12.

The system is more robust as if one clock fails the others keep working , you could even keep a spare .
The connection between clocks is “ multidrop” , just two cores .

However ... now a days clocks are so accurate , there is little need to sync them .

The 28BYJ-48s i am looking at buying come with the ULN2803 drivers, and the 74HC595 come out quite cheap. Is it seriously inadvisable to go down the track of daisy chaining 74HC595s and each one connected to two ULN2803, each driving a stepper? It's coming out cheaper at the moment - I guess it means that I have 48 components I don't necessarily need if it were to go straight for the TPIC chips.

Thanks for your replies re: the merits of Uno vs Nano - I'll purchase a couple of nanos to have a muck about with.

Hammy I will have a think about master/slave - however it seems that that could get prohibitively expensive?

I believe you will find they are ULN2003, vs 2803.
'595s driving two motors works, with the right variant. I have done a test with up to 6 TPIC6B595 driving 12 motors directly (no ULN2003 in between) with no issues. I would have tried more, but I had run out of sockets, to add more parts on the board I was using, and wires to reach more motors.
I don't know if 74HC595 driving ULN2003 to drive the motors will work the same. 1284P and 2560 driving ULN2003 work.

cbeckingsale:
I guess it means that I have 48 components I don't necessarily need if it were to go straight for the TPIC chips.

You said it! :grinning:

You also lose at least one volt of your 5 with the - basically obsolete - ULN2003.

Warning: The "1:64" gear ratio in the 28BYJ-48 stepper is not exact. They don't use a single pair of gears since having one gear 64 times the size of another makes for rather a large gear. The gear train has a bunch of odd ratios that multiply out to very near 1:64.

https://cookierobotics.com/042/

If you re-sync the count every time you pass zero it should be no problem. If you synchronize on start-up and travel many turns in one direction over the other you will gradually lose position.

Thanks all for weighing in - appreciate it.

Will try out with 5 motors and their drivers and 3 74HC595 shift registers and then see if that can be scaled up to a full row of 8 74HC595 shift registers and 16 motor+drivers. If that works I'll forge ahead with them and try build up 3 blocks of that. If not, will attempt the same but with 8 TPIC6B595s driving the 16 motors directly.