Introduction: IoT Time Warp Dali Clock
Time flies when you are having fun, and drags when you're bored. Time is obviously relative: our perception of time changes with our state of mind, and it's only fair that clocks should be able to adjust to our experienced speed of time. IoT Time Warp Clock fixes that problem by giving you the power to control the speed of time! (at least for one clock)
The IoT Time Warp Dali Clock is a wireless controlled clock which lets you speed up, slow down or even stop time. It uses an Intel Edison hosting a web page on local WiFi network to control a hacked clock mechanism.
This project is inspired by Lunchtime Clock. Whereas Lunchtime Clock was coded to sneakily increase the lunchtime by 12 minutes, this is clock full of features to customize the time warping according to your needs:
- Wirelessly control the clock over WiFi
- Node.js locally hosted setting pages for controlling the clock from any device with a browser
- Analog display of clock face's time using socket.io
- Time can be slowed down, sped up, stopped or synchronized to the correct time
- Settings can be scheduled to run at a specific time
- A setting can be set to repeat weekly on specific days of the week
In the middle of the project, I realized that since I'm making a clock that lets you warp time, I could not miss a reference to Salvador Dali and went with the Dali Style Melting Clock instructable to make the clock body.
Step 1: Go Get Stuff
You'll need the following things to make this project:
- Intel Edison
- A vinyl LP record
- Sacrificial clock. Use an old one or you could buy the clock mechanism separately.
- L293D H-bridge IC
Step 2: Destroy a Classic
Choose an old vinyl LP record to work with. I chose an old unusable LP of music tracks from the cult Indian movie Sholay.
fungus amungus in his How to Make a Dali Style Melting Clock explains in detail how to make the melting Dali-esque clock using an oven. The only thing I did different was to use a hot air gun to heat and shape the record.
Keep heating the record till it is easily bent and then add wrinkles. It takes some effort as your nearest wrinkle will smoothen out when you try making a new one. At the end, give one edge a 90 degree sharp bend by holding it against a table edge and bending. This makes the part that sticks to the counter to which you will attach the clock to give a molten-clock effect.
The LP record cover can be hung on a wall after framing. It makes a great decorative piece.
Step 3: Sacrifice a Clock
Remove the clock machine/mechanism from the sacrificial clock. You can also buy them separately. The mechanism should be in working order.
Live life a bit dangerously and break the warranty seal on the mechanism. Pop it open and make a careful note of which gear is in which location.
Take out the PCB and find out where the 2 wires of the solenoid(coil of wire) connect to the PCB. Cut any traces connecting it to the rest of the PCB to isolate the solenoid from any circuitry.
Now solder 2 wires to the wires of the solenoid, preferably where it is soldered to the PCB. There is usually no space to bring the wires out so you will need to drill two holes to take out the wires.
Close the whole clock assembly. You can check your connections by connecting a AA battery to the 2 wires and then reversing the battery connection to make the clock tick one second.
Step 4: Solder the Circuit
The clock mechanism ticks one second whenever the voltage across the solenoid is reversed. So we'll need an H-bridge to reverse polarity every second.
In Lunchtime Clock instructable, randofo used an H-bridge made using 4 transistors. I initially tried making that but then I added 4 protection diodes to protect the precious Intel Edison. At that point I realized that I could simply use an L293D IC which has an H-bridge with back EMF protection instead of making a complicated one myself.
Just pick up a perfboard, cut it to size and solder an L293D with 2 wires going to clock, 2 to Edison's 5V and ground pin, 3 to Edison's digital pins 9, 10, 11. Solder all GNDs together and Vmot and VCC together to 5V. Follow the diagrams in the above step. I couldn't find Edison in Fritzig so used Arduino Uno to display the connections as the pins are exactly the same.
Step 5: Putting It All Together
Stic the modified clock mechanism with double sided tape and stuck it to the vinyl record. You can also use hot glue as used in the original instructable. Stick the perfboard PCB and Edison too using some double sided tape.
Connect all the wires to the Edison as shown in the diagram in previous step.
Connect a suitable wall wart to the Intel Edison to power it. We're done with the hardware part!
Step 6: Setting Up Intel Edison
Install an image on Intel Edison using steps provided on their site. Also Download Intel XDK IoT Edition and install it.
Download the attached code.
Open up the downloaded code in Intel XDK IoT Edition and upload it to the Edison. To upload, connect to Edison first. Then go to Settings and Sync system time and update daemon.
Connect the Edison to your WiFi. Steps on how to do it can be found here.
Step 7: Use It
The clock settings can be modified by using phone, tablet, laptop or any other device which has a browser and is connected to the same WiFi network as the Edison.
Find out your Edison's IP by typing 'edison.local/' in your browser. Just open up a browser and enter Edison's IP address followed by ':8008'. Say the edison's IP is 192.168.0.1, then type 192.168.0.1:8008 in your browser. I've found 'edison.local:8008' also works fine on PCs but not on handheld devices.
This will bring you to the Edison's Time Warp Settings page. As soon as you connect a device for the first time to Edison, the code will also pick up the device's time and use that as the current time. Edison picks up the current time from the internet on boot but this fails if the internet is down. This prevents the time-warp code from showing incorrect date and time. So the clock doesn't start ticking until and unless you connect a device to the Edison.
The time on the analog clock and system time should be the current time on the device you just connected for the first time. So set the clock using the time setting dial at the back of the clock mechanism to set it to your current time.
Step 8: Time Warp Page Elements
The main page of the Time Warp settings page has a large analog clock which shows what the Edison thinks should be displayed on the clock's face. If the two doesn't match, you need to stop the time for a minute and adjust the clock's time to the one showed in this page's analog clock.
Below this analog clock, a single line displays the system date time. This is the time which the Edison considers to be the current time. This is saved from the system time of the first device that connect to Edison's 8008 port. This will not change with time warping but the one on the analog clock above it will change according to the time warp setting.
There is a round add button at the bottom which lets you add a new setting.
The saved settings come in between the system time and add button. They work as an accordion menu and the settings can be clicked to expand them out one at a time. The settings have a short text description which is visible in the setting's collapsed state and provides all the details of the setting.
The activate slider button on the right side of each setting entry shows the state of the setting. If it is ON, the setting is active and will be used when its schedule comes up. If it is OFF, the schedule will never come into effect until it is turned ON. When a setting is ON and its duration of effect gets over(and it's not on repeat) the slider button will automatically turn OFF. When turning a setting to ON, if the setting start and end time clashes with another active setting's you'll receive an error and won't be able to turn it ON.
Step 9: Setting Options
A setting could modify the time in 4 ways:
- Speed Up: speeds up the clock. The clock will be gain time ahead of system time by the value in by.
- Slow Down: slows down the clock's speed. The clock will fall behind the system time by the value in by.
- Stop: stops the clock
- Synchronize: tries its best to match the time on clock's face(as shown in the big analog clock on top) to the system time(in single line below the analog clock). If the clock is ahead of the system time, it will slow down(or stop) the time and if the clock is behind, it speeds it up. It smartly chooses the best option of whether to speed up or slow down to match the system time. It cannot go faster than MIN_TICK value and cannot go slower than a complete stop(no reverse).
Each of these 4 options have other associated options:
at/in: at allows user to specify at what time the setting should start. When the system time will match this value, the setting will come into effect. in specifies in how much time we should start using this setting. We will wait for a time equal to the value entered for in before using it. On selecting in, 'hours' come written after the input box showing that this is not a specific time but a time duration, i.e. 22:10 means 22 hours 10 mins instead of 10:10 PM.
till/for: till takes the time when the setting should be stopped being used. for specifies for how long this setting should be used from the time it comes into effect. Again, 'hours' is displayed for for. After the setting's time is over, it gets disabled unless it is set to repeat.
by: this option only comes up for Speed Up and Slow Down. Stop and Synchronize don't have the by option. by defines by how much the value the time should be increased or decreased. It can be set to either a time duration by selecting hours from the dropdown or to % which sets it to the percentage of the time the setting will be alive. If a setting is in effect for 10 minutes, and by is 50%, then it equates to 5 minutes. Entering a value above 100% for Slow Down means by value is greater than the time the setting will be running and as clock cannot move in reverse, it will always stop.
Repeat checkbox lets us set the days of the week when the setting should repeat. Ticking Repeat slides out a set of 7 active buttons representing days of the week. Deselect the days you do not want the setting to repeat. Deselecting all the days will uncheck Repeat checkbox itself.
The Save Button will save the setting and update the setting description.
The Delete Button will delete the setting. Only an inactive setting can be deleted.
Note: A setting can only be edited if it isn't active, i.e. is set to OFF.
Step 10: Finished!
I used the android's alarm setting page as a reference guide for designing the UI, which was a pain to realize using my limited knowledge of JS and CSS. I used a lot of code from codepen.io such as to make the accordion menu, slider buttons, dropboxes, etc.
I had a lot more planned but could not get it done: I wanted a JS timeline to show all the active settings and their schedule visible on the timeline. I also wanted to implement unobtrusive and beautiful tooltips to display errors and messages(such as fields left blank or clash with another setting) instead of message boxes.
I also wanted to use a LiPo battery to provide backup in case of power failure. But whenever I connected a LiPo to J2 for powering Edison, it doesn't allow me to use GPIO pins to control the clock mechanism. If anyone knows why, please explain in comments.
That's all folks! Go ahead and warp time to your whims and fancy...