Running special clock with motor controller

Hi all.

Totally newbie here (at coding this kind of stuff): Fyi.
I have a project with an old clock that i just got from my father. It requires a special input to run - I hope you can help me here. This is the clock:

The clock is from an old power-plant and needs the following input:
220v (50Hz) for one of the clocks (i got that sorted :slight_smile:) , and then a 24v pulse each second for the other clock: that pulse need to change polarity, with each pulse:


Not sure about the width for each pulse, but lets go with 0,5 seconds.

I have bought following hardware:
ESP32
Motor controller
DC-DC step up converter (to get 24v from a 5v USB source).

My idea is that the motor-controller, will get the input from the ESP32: driving the "motor" forwards and then backwards , according to the above sketch: giving +24v for the first pulse, and then -24v for the second pulse and so on.
I Found this tutorial for driving a motor:

The setup will be similar I guess:

The question is how would I go about coding this into to ESP32? (I have newer coded this kind of thing before).
Also: this is running a clock - is the ESP32 accurate enough for this? (I guess that can be a upgrade for later, if I need an external clock for higher accuracy?).

(I have it successfully connected the ESP32 to my computer, and using the Arduino program - I got it to run a WiFi-scanning program, that is running at the moment).

For the curious about the function of the clock:
The 24v pulses was used to power one part of the clock very accurately (reference time).
The 220v (50Hz) was used on the other clock, to show if the powerplant needed to produce more or less power (the 50Hz will get lower or higher depending on the power available on the grid, thereby changing the speed of that clock).
The operator could then see if they were "behind" or "ahead" in terms of power production.
EDIT: the above explanation is from my father (he was a "low power technician" - he might be wrong or remember incorrectly - He got the clock a LONG time ago :slight_smile:

Kind Regards
Daniel

1 Like

изображение
from which planet is this clock?

const int enA = 9; //adjust your ESP pins
const int in1 = 8;
const int in2 = 7;

void setup() {
  pinMode(enA, OUTPUT);
  pinMode(in1, OUTPUT);
  pinMode(in2, OUTPUT);
}

void loop() {

  digitalWrite(in1, HIGH);
  digitalWrite(in2, LOW);
  digitalWrite(enA, HIGH);
  digitalWrite(enA, LOW);
  delay(1000);

  // Now change motor directions
  digitalWrite(in1, LOW);
  digitalWrite(in2, HIGH);
  digitalWrite(enA, HIGH);
  digitalWrite(enA, LOW);

  delay(1000); // not really precise. just to check of concept
}

void motofOff() { // Now turn off motors
  digitalWrite(in1, LOW);
  digitalWrite(in2, LOW);
}

Haha, it's old for sure :slight_smile: And a little weird that the big arms take 3 minutes to go one round
Thank you for the code - i will try that now :slight_smile:

i have seen similar clock in attic of ruined old telegraph station

No and yes.

By itself, it will drift by several seconds per day.

But if it can get internet access through wi-fi, it can get accurate time using the Network Time Protocol (NTP). This should remain extremely accurate, because it will re-synchronise itself that way every hour. This is the way that the clock on your smartphone/laptop stays accurate.

The library functions that come built-in with the ESP cores make this process very easy. Only a few lines of code are needed.

@kolaha 's suggested code will not keep time accurately, but it demonstrates how to operate the motor driver. By combining this code with the NTP functions, you should be able to get it working.

Here's example code for getting time from NTP:

https://werner.rothschopf.net/202011_arduino_esp8266_ntp_en.htm

2 Likes

I suggest a more likely use for the clock is to show the phase difference between a primary generator and a secondary generator for the times when more power was needed. The big dial shows the phase up to 180 degrees and when the generator was adjusted to zero phase, the big switch could be thrown to add the new generator to the output power and then maintain the zero phase of the second machine by watching the clock.

1 Like

FYI - Frequency (Hz) is not "power". I's a characteristic of AC power... Traditional AC clocks (like your 220VAC clock) use a synchronous motor that automatically lock-in to the line frequency. By keeping the average power line frequency perfect, everybody's clock at home remains perfect as long as there are no power outages.

I have a digital clock at home that works the same way. I know because it has a battery back-up and when I lose power for a couple of hours the time drifts-off by several minutes. Most digital clocks don't work that way... Usually they have an internal crystal oscillator (like a digital watch) so they don't depend on power line frequency, and they aren't as accurate. Mine obviously has some kind if inferior internal oscillator so it's better as long as power is on but worse when I lose power.

That is still done today

1 Like

What is the DC resistance of the motor coil?

Hi all.
Thanks for the replies.
Seems like the NTP would be a good idea.
I assume that would required quite some extra coding to make that work with the timing/duration of the 24v pulses? (i guess the ESP would have to "correct" the pulse length to make the seconds run faster/slower each hour to keep up?). Or does the NTP influence the "delay" values show in the above code? Or should that pulse timing simply be specified from the actual NTP clock/date (if that is possible - giving pulses, when the second changes)?

Perhaps my dad remembers incorrectly about the function of the clock - he seemed quite sure though, when I asked him (he worked as a low power technician at said powerplant).

It was a very common clock work in the old days. The small pointers are special.
One master unit keeps the time and send out pulses to all the perifere clocks. Look at railroad stations! There You could find clocks "everyware".

1 Like

Exactly - my dad told me that the power plant had a very accurate pendulum clock at the power plant, that provided the pulses to the clock (perhaps to multiple clocks around the plant).

I don't know :slight_smile: (are you worried about the power-requirement?)

You need to know the resistance in order to choose the right motor driver.

No, only a little.

I suspect the pulse length is not very important at all. As long as it is long enough to get the mechanical part of the clock to move correctly, that's good enough. What's important is the timing of the start of each pulse. They should be exactly 1s apart.

2 Likes

The NTP would replace the delay() in the code. The Arduino would check to see when the time has changed (which is every second) and begin the pulse at that moment, alternating between positive and negative pulses.

2 Likes

Sounds like the way to go then. Would the absence of WiFi prevent the program/clock from running though?
Would be nice if I could show my father the working clock at his place without WiFi connection.

Do I need that for such a low power system? And can I measure this with a multimeter to be sure before testing?
This is a picture of that system:

I assume the motor won't require more than the 12 watt available from the USB-brick (5v @ 2,4A - properly a little lower than 12w going trough the DC-DC step up - lets say 10w).

That would be most wise. There is an old English saying: "assume" makes an ASS out of U and ME.

I just measured 1,5 K Ohms across the wires going into the circuitry connected to the motor.
Can't see the wires connected directly to the motor though.