/secondary-clock-ESP8266

Driving secondary clock by ESP8266

Primary LanguageLua

Driving secondary clock by ESP8266

Check out this Youtube video to see the clock in work.

Secondary clock IPJ0612 driven by ESP8266

Intro

I have received this beautiful secondary clock IPJ0612 produced by Czech company Pragotron in 80's. Secondary here means that the clock is only a "display" and has to receive signals from a central clock to move by one minute. IPJ0612

The clock is driven by kind of a stepper motor, powered by 24V. It has two wires as input directly connected to the coil. For one half turn an impulse of 24V is required for the remaining half turn -24V are applied. IPJ0612

Electronics

We needed to use a circuit that can revert the voltage on its output. Two inputs are connected to ESP8266 GPIOs (GPIO0 and GPIO2). GPIO0 set to high makes 24V on output. Setting GPIO2 high causes -24V on output. A pull-up resistors are connected to GPIOs so that ESP8266 boots in desired 'normal operation' mode. A protection transistor (QX on the scheme) for accidental highs on both inputs has been added. The ESP8266 ESP-01 version is used.

We have used Eagle to draw the scheme and design the board. scheme board

To get the 3.3 voltage to power the ESP8266 a LM1085IT-3.3 TO220 regulator is used. In my implementation, I'm using step-down module as I had one spare at home (the component with annoying blue LED on the pictures below). It's sold on eBay and can be found as 3A 9V/12V/19V To 3.3V DC-DC USB Step Down Buck Power Supply Module For Car.

Programming

I am using NodeMCU Lua (https://github.com/nodemcu/nodemcu-firmware) to program the ESP8266. The programming in Lua is very easy so the core program can have less than 140 lines including the web server used to adjust the clock.

A NodeMCU custom builds tool can be used to compile the binary for ESP8266. Beside standard modules the following modules are used: cron, enduser_setup, rtctime, sntp. I have used the integer version of the firmware is used. Though float version should be fine too.

I am using ESP8266 Flasher to flash the binary.

To upload Lua files and files used by the web server the ESPlorer GUI can be used.

The program connects to the WIFI, regularly synchronizes time via NTP and sends 300ms to GPIO0 and GPIO1 alternately. To show correct time ESP needs to know what time the clock is showing at startup so it can set it to actual time. This can be adjusted in web browser as the ESP8266 is running a web server. Otherwise the clock assumes correct time is displayed and sends signals as time goes on.

It exposes also a telnet server so an OTA-like update of Lua codes can be performed.

web server

In my implementation am using only 18V to run the clock (a power adapter from an old printer). With 24V the signal could probably be shorter than 300ms so clock adjustment would be faster.

The source code is in the folder lua_code.

Assembly

A 3d printed holder (designed in SketchUp) and double face duck tape has been used to mount the board inside the clock. An STL file is usually used in the slicer software.

I have also designed a cap to cover the hole of the original connector (SketchUp file and STL file) - not shown on any of photos.