2022

Saturday, December 17, 2022

Build Your Own Binary Clock: Design Changes and Electronics Review (part 2)

Description

Want to make an Arduino project a bit more complicated than blink? In today's episode of House of Hacks, Harley starts a project on how to make a binary clock. This project will use an Arduino and be presented in three parts. Today, the first part will be the overall design and software. In future videos, the second part will be building the circuit and getting it operational and the third part will be finishing it off with an enclosure.

Additional resources

If you want to build your own, here are the parts I used (all affiliate links):

If you just want a commercially made one like I have, they’re available on Amazon: https://amzn.to/3eGXFVD (Affiliate link)

Arduino Foundations book: https://amzn.to/37WMV3U (Affiliate link)

Music licenses

Music under Creative Commons License By Attribution 4.0 by Kevin MacLeod at http://incompetech.com.

Contents

Transcript

Introduction

Interested in making a binary clock inspired by this?

You're at the right place! This video is the next one in the series on how to make a binary clock.

Wow, it's really been a while since I've, started this project, and there are some good reasons for the delay, which I'll get into later. But in this video, I'll show the parts I've received since the last video and review the design with some changes I've thought of since then.

Imagine, Design, Build

When putting any project together there are three big stages: imagine, design and build.

Each stage is iterative and there's a bit of gray area, sometimes quite a bit, between where one stops and the next one begins. And sometimes you find problems in the stage you're working on that requires you to scrap it and go back to the previous stage. It's really just part of the creative process.

Well that happened to me on this project and I'll talk about that and some of the changes that I've made.

Welcome to the House of Hacks!

If we're just meeting, I'm Harley. Welcome to the House of Hacks where I make things out of different materials and show you how you can do that too. Around here any type of media is fair game, from things as basic as wood to as virtual as software.

In this project, I plan on using electronics, software, wood and some resin. But you know, plans change and when it's all said and done we'll see how things ultimately turn out.

Project review

This is the second in a series of videos about how to make a binary clock. I picked up this clock at a conference a number of years ago and thought it'd make a basis of a really cool project.

In a previous video I talked about the requirements, how to read it and the overall design. Since that last video, I ordered and received the electronics parts that will make up this project.

Arduino Micro specs

This is the Arduino I'm going to use. It's the micro version and has several things going for it. It doesn't have as many pins as the larger versions but it has more than enough for the purposes of this project. It's really compact and it's designed to be soldered into a project.

DS-1307 specs

And this is the clock module. It's a DS-1307. We can see here the battery holder and it's designed to keep accurate time. The way it works is you set the time and it will then tell you the time whenever you ask for it.

One of the nice things about this, besides the battery backup, is it outputs in BCD, so we don't have to do any conversion in our code.

This module actually has a number of features we're not going to be using such as tracking the date in addition to the time and a square wave generator. And it also has some memory that you can store small amounts of data in.

I2C bus overview

It communicates over what's called an I2C or I-squared-C bus. There are different ways of pronouncing this, none of which are really the "right" way.

route, route
data, data
neither, neither
gif, gif

But whatever it's called, this is a communication standard that allows multiple devices to communicate over just two wires.

It can be as simple as this project where there is one main controller, also called the master that initiates the communications, and one that responds to the controller, also called a slave. But it has a possibility to be something more complicated with multiple masters and multiple slaves.

In any case, regardless of how many exist, the masters always control the conversation and the slaves just respond.

74595 operation overview

These are the 74595 chips that we'll be using to light up the LEDs. Technically they're called 8-bit shift registers and use something called serial-in/parallel-out. That sounds a bit confusing but it's really not too hard if we break it down.

  • "8-bit" just means there are 8 outputs that are either on or off.
  • "Shift" means we put things in one end and they come out the other.

    Kind of like a line at the grocery store. You shift closer to the register as you move from the end of the line to the front.

  • "Register" means it remembers its value without having to do anything special.

    It gets written to and remembers that until it's written to again kind of like a check register if you're old enough to remember those things. It's really just a type of computer memory.

  • "Serial-in/parallel-out" means you put in one thing at a time and you get multiple things out.

    In this case, we put in one bit at a time and the output is eight bits at a time.

These chips connect to the Arduino with just three pins: that's the serial-in part. The three input pins are called the latch, data and clock.

First the latch pin says "get ready, we're about to make some changes." We set it whenever we want to change the contents of the register. We then use the data and clock pins to actually set values and then unset the latch when we're all done. When unset, the values put in on the data pin is transferred to the eight output pins.

The data pin says this is one value to display. It can be thought of as high or low, or on or off, or one or zero.

Finally, the clock pin says take the value off the data pin right now. This is because there can be a transition time when the data may not be fully on or fully off and we really want to make sure that the data value that we're using is the value we want to use before setting it on the chip.

One of the cool features of this chip is they can be daisy-chained together. If eight values are sent to a chip it fills up all the output pins. As more values are sent to it, each of the values at the end are sent to an overflow output pin. This overflow pin can be connected to the data pin of another shift register and the clock and latch lines connected to both. This means you could connect two of these chips together and clock in 16 data values or you could connect three and clock in 24 data values or however many groups of eight you want to put in. All through the same three pins on the Arduino.

Miscellaneous parts

And last of all, there are some miscellaneous things: the LEDs and resistors that will be used to actually display the time, the rotary encoder that will set the time and the project board that will connect everything together.

There may be some other things needed as this comes together but those are the major components.

Where I've been

I have some design changes to talk about but first let me say a bit about where I've been and why there haven't been as many videos in the past year as in previous years. Besides the whole dumpster fire that was 2020 in the world in general, there were several personal things that happened for me personally in 2020. One was really sad and the other is really pretty exciting. But both took time and emotional energy away from making videos.

The sad one was the passing of my Mom. It was quite unexpected and, as these things go, relatively quick.

One day she felt like she had the flu and was taking it easy. The next day the neighbor found her unconscious on the floor. Instead of the flu, she had a systemic infection that she just couldn't recover from. She never regained consciousness, which in the long term, I think is really probably for the best. There wasn't any long drawn-out painful period of decline as happens with some diseases. It was just, you know, one day she was herself and the next day she was gone.

But, we miss you Mom.

Arduino Foundations

And the one that's a bit more upbeat is I actually wrote a book called "Arduino Foundations." It's all about the things you need to know to start working with Arduinos. It's really kind of the pre-steps to your first project and it's broken down into three main sections.

The first section is about the hardware and electrical side of things. Answering questions like:

  • What is an Arduino and why would I use it?
  • How does it differ from other computers I'm familiar with?
  • What's voltage and amperage and watts and current?

    This section also talks about the tools needed to get started with an Arduino.

Next is a softer section going over what software is and the different things that make up a program particularly on an Arduino. All the basic commands are discussed and how memory is used.

And finally there's a setup and configuration section. In this section, I talk about how to set up a computer to work with an Arduino and how to select which model of Arduino to use from all the different options available.

If this sounds interesting to you, it's available on Amazon with a link down in the description.

Design changes

Now, let's revisit the design for this project for a minute.

In the first video, I talked about the need for 20 bits for all the output. Seven bits are needed for the seconds section, 7 bits for the minutes section and 6 bits for the hours section. In my prototype, I sent those in a single stream and that made for some messy code since the values weren't broken up into clean 8-bit values that are used by the 8-bit shift registers and internally in the memory of the Arduino. To clean up the code, I changed it to instead control each of the 595s individually, instead of chaining them together. This made the code much easier to read at the cost of using nine Arduino pins instead of just three.

After the video, as I thought about it some more, I realized that originally my idea to put all the unused bits at the end of the daisy chain was an unneeded constraint. There really was no reason for all the unused bits to be bunched up together. They could easily be spread out. This insight allows clean easy to read code and still daisy chain the shift registers together using only three pins on the Arduino. It's simply a matter of connecting the LEDs to the shift registers in a slightly different pattern.

This is a great example of the iterative nature of making things. Sometimes it's not our first or even second idea that sticks.

And this demonstrates the value of prototyping. By putting something together quickly, that's intended to be temporary, we can see the problems and work on better solutions without having a huge time or materials investment.

If you missed the first video in this series it can be seen up here and the next video will be down here when I get it released.

As always, go make something.

Perfection isn't required, fun is!