top of page

COLORCLOCK

What time is it?

Amber o'clock-ish (?)

The outer ring cycles through the whole spectrum over 24 hours, the second to the outer ring cycles over one hour, the inner ring cycles over 1 minute and the central flower-looking light can be controlled by the participant. This photo was taken at 9:09 AM. Don't mind the dead button LED. This will be fixed 😅


No regrets

For a long time, I regretting getting my bachelor's in electrical rather than computer engineering. Often enough I have questions about software engineering concepts that might have been answered had I chosen a different major. However, while working on ColorClock, I've recognized that my degree gave me familiarity with electronic components and datasheets that I might not have gotten with a different undergraduate focus. Like when I realized that I shouldn't be powering the Ardunio with 12V directly, I immediately knew I needed an LM7805 linear voltage regulator. I swear I read somewhere at some point that 12V was okay! In any case, for the first time since I graduated, I sincerely have no regrets about my major.


A lot has happened since the last post, including completely resoldering a new circuit board followed by a very sad afternoon where I was ready to give up after burning another Arduino board. But it all came together in the end.


Here is the final wiring of the circuit board. Isn't it beautiful? 🥰


We did it!

A couple months ago we decided to schedule a live demo as motivation to get the project finished a few weeks before leaving. The looming date of the demo gave us the motivation to finish with exactly one weekend to spare to get ready 😵‍💫


Last weekend was the demo and it was a success! After scrambling to get it all wired up (which involved an embarrassing number of alligator clips), I threw together a slide deck that I presented to kick off the event. I added some of the slides at the end of this post for your enjoyment.

I discussed some of concepts of RGB LEDs, how a level shifter works, and went over the wiring of the circuit board. I was excited to play teacher again 👩‍🏫 Don't mind our camping boxes and living room workbench -- Photo courtesy of Stasi Silvares.


Bo and friend discussing the meaning behind the colors -- Photo courtesy of Stasi Silvares.


We'll be using solar to charge the batter that powers ColorClock ⚡️


The participant will be able to sit on the bench while viewing the light display and manipulating the controls 🎮


The final touches

This is our last weekend before we deliver and I'm thrilled that we are really just putting on the final touches. Although I learned today that last minute software changes can be quite risky.


I decided to change the initial colors for the the participant controlled central light, but because of my wonky logic for how the buttons interact with the colors, I got less than ideal results.


I reverted my software change and now it's working 🥳


It's actually happening!

We leave in less than a week 😶


 

Slide dump

Here are some of slides I put together for my ColorClock presentation.

The title block indicates Rev -, however this was actually Rev A.




I was cleaning up my code of magic numbers and added a few #define statements for the frequency values. But after uploading the program to the board I didn't understand why the the colors on the light were not changing at the correct rate. So I added a couple serial output debug prints saw that my frequency was not set properly.


Code

// Time constants
#define SECONDS_PER_MIN   60.0
#define MINUTES_PER_HOUR  60.0
#define SECONDS_PER_HOUR  SECONDS_PER_MIN * MINUTES_PER_HOUR 

// Cycle time for ColorClock object 0
// Should equal 0.00333____
#define CC0_CYCLE_TIME_HOURS 12.0 / SECONDS_PER_HOUR

//...

Serial.print("SECONDS_PER_HOUR:     ");
Serial.println(SECONDS_PER_HOUR);
Serial.print("CC0_CYCLE_TIME_HOURS: ");
Serial.println(CC0_CYCLE_TIME_HOURS);

Serial Output

I was expecting CC0_CYCLE_TIME_HOURS to print as 0.00333 or even 0.00. Why was it printing 12.00??


CC0_CYCLE_TIME_HOURS: 12.00
SECONDS_PER_HOUR:     3600.00

I figured out that it had something to do with my #define statement. I stared at the code for way too long before deciding to do away with the SECONDS_PER_HOUR constant and just hard code the values directly:


#define CC0_CYCLE_TIME_HOURS 12.0 / 3600.00

And this worked, so whatever. I just figured that the Arduino compiler is weird and doesn't treat preprocessor directives the same as gcc. I started writing this post to complain about the Arduino compiler, so to illustrate my point, I coded up the following simple program to compile on my desktop.


Code

#include <stdio.h>

#define SECONDS_PER_MIN   60.0
#define MINUTES_PER_HOUR  60.0
#define SECONDS_PER_HOUR  SECONDS_PER_MIN * MINUTES_PER_HOUR 

#define CC0_CYCLE_TIME_HOURS 12.0 / SECONDS_PER_HOUR

int main()
{
  printf("\nSECONDS_PER_HOUR:     %f", SECONDS_PER_HOUR);
  printf("\nCC0_CYCLE_TIME_HOURS: %f", CC0_CYCLE_TIME_HOURS);

  return 0;
}

But to my surprise, the console output displayed the same value as the Arduino serial out!


Console Output

SECONDS_PER_HOUR:     3600.000000
CC0_CYCLE_TIME_HOURS: 12.000000

The Problem

I stared at the code again and realized that the lack of parenthesis in the definition for SECONDS_PER_HOUR was the source of my problem. The #define macro is a simple find and replace, so what the compiler saw was:


#define SECONDS_PER_MIN   60.0
#define MINUTES_PER_HOUR  60.0

// The compiler sees:
// #define SECONDS_PER_HOUR  60.0 * 60.0
#define SECONDS_PER_HOUR  SECONDS_PER_MIN * MINUTES_PER_HOUR 

// The compiler sees:
// #define CC0_CYCLE_TIME_HOURS 12.0 / 60.0 * 60.0
#define CC0_CYCLE_TIME_HOURS 12.0 / SECONDS_PER_HOUR

The compiler was basically seeing 12 / 60  60 instead of 12 / (60  60). And because of order of operations, CC0_CYCLE_TIME_HOURS was indeed 12, not the 0.003333 that I was hoping for 🤦‍♀️


Lesson learned 😳

As a child, I could spend entire days engrossed in puzzles. My favorites were the Mind Benders series logic puzzles, where a set of clues were provided to determine matches with limited information, such as figuring out which child owned which pet. I found immense satisfaction in solving these problems and took comfort in the certainty that there was always one correct solution. My chosen career path reflects this passion for problem-solving. Today, the puzzles I tackle are far more complex, with numerous possible solutions, each varying in its degree of optimality.


The Circuit Board

My big puzzle for the week has been how to lay out the final circuit board. There wasn't enough time to have a board printed, so I'll be wiring and soldering everything manually. For the second version of ColorClock, I would like to design a printed circuit board (PCB) to simplify the soldering effort. All integrated component boards, e.g. level shifter, Arduino board, will be attached to the board with female headers, so if a component dies for some reason it can easily be swapped out without re-soldering.


I decided to go with a board that is connected much like a solderless prototyping breadboard, where each column of holes are electrically connected. This does limit the possible orientation of the modules, but it will make the final wiring a little easier given that it can be laid out nearly exactly the same as the solderless prototype.


This photo shows the underside of one of the ElectroCookie breadboards. The project will have two boards side-by-side to accommodate for all of the control electronics. The stand offs in the middle of the board are to raise it up off the bottom of the electronics enclosure.


🌈


This diagram illustrates the layout of the board, and is mostly to scale. The groups of wires extending beyond the breadboard's borders will be routed to external electronics, such as the participant buttons, power input, and light display. Although the wires are shown overlapping the modules in the diagram, they will actually be routed underneath the modules, as the modules will be elevated using female headers.


🌈


This diagram illustrates the soldering layout primarily for the wires and female headers.


The Box

The control panel enclosure will house the participant-facing buttons in addition to the control electronics for the installation, i.e. the breadboard discussed earlier in this post. I was planning on modeling and 3D printing the enclosure, but now I am contemplating making it out of wood and simply printing an enclosure for the breadboard that will sit inside the box. With regards to the enclosure as a whole, there are a few mechanical factors to consider, like how it will be mounted and accessed from the outside in case of malfunction.


The participant control panel will be located beneath the light display, which is mounted on a 45-degree wooden panel. The enclosure is designed as a diagonally cut rectangular prism to position the buttons vertically for easy access.


This is the initial 3D model I was planning on printing. The triangular holes in the front are for the arcade buttons that the participants can use to modify one of the LED strips. With this design, there is no way to access the enclosed electronics without unscrewing the cover from the wooden panel that it would be mounted to.


🌈


The little nubs at the bottom of the box are to stabilize the stand offs used to elevate the circuit board off the bottom of the box.


The Structure

My partner, Bo, has been working hard on the structure, experiencing a multitude of challenges, and has practically rebuilt the frame, piece by piece. Home Depot has become our second home 😅 I have such immense respect for his tenacity in constructing a sturdy frame to bring my vision to fruition.


We each spent most of the day working on our respective parts of ColorClock. I was mostly CAD-ing in the AC while he was sweating in the garage playing with power tools.


🌈


This is Bo's exasperated "I can't wait to burn this thing" look. I love him 😘


🌈


Me, for scale.


TODOs For This Week

  • Solder circuit board

  • Model circuit board enclosure

  • Modify software to output lower power at night


😬

©2022 by Rebecca Jennifer  Rashkin 🐰

bottom of page