I wanted to get back into bread boarding, what better way than to do another clock :)
I have a bunch of HP 12 pin bubble displays that I snagged up a while back and have had nothing to do with them. As I don't like to let my skills get rusty I decided to create this clock using an ATTiny84A micro controller and C. I wanted to stay away from the Arduino IDE.
I do plan to make a PCB for this project, but wanted to start out on a bread board. I am not yet sure if I want to take the minimalist approach or make it an easy to solder kit clock... we shall see.
So far so good.
Use Attiny84A (Done 02-09-2018)
Use HP 4 digit Bubble display (Done 02-09--2018)
DS1307 Communication (Done 02-12-2018)
Display acquired time on HP Bubble Display (Done 02-12-2018)
Set time externally (user buttons) (Not Done)
Option to display seconds (Not Done)
Stop watch function (Not Done)
Timer function (Not Done)
Alarm (Not Done)
External | Internal EEPROM storage for multiple alarms (Not Done)
We have a clock! turned out I was using the wrong address for the RTC.... have to remember its 0xD0 not 0x68.... coding all day at work then doing so at home... you miss a lot of little things..
This clock turned out much, much easier than my micro numitron clock project. Code wise, I ended up using the i2cMaster library from Peter Fleury i2cmaster library, its a bit banged assembly library that just works and its amazing!
Ok so now to the rastering or how we control the 74HC595's
The 595's in this setup are cascaded together, they both share the same CLOCK andLATCH pins, the first 595 gets the DATA pin from witch we feed it a 12 bit binary number, the first 595 also feeds the rest of the bits to the other 595 via Q7` (that's prime). The 595 can only hold 8 bits of data, so when this overflows ( you push 9 bits) if available it will push the 1st bit your MSB to the Q7` pin witch is then connected to DATA pin of the second 595 and so on and so on.
Here's how getting the digits displayed it structured.
[digit symbol] [display digit]
[8 bits ] [ 4 bits ] = total 12 bits.
this is all read out LSB first so the Anode positions go out first ie 0b1111... 0b1110.. etc since the Digits bits are Anodes we need to sink current so in order to turn a digit off, we simply write a 1 in its position.
looking at the photo ^, we see, as I have have arranged them in code. Pos 3, 2, 1, 0. so
so how do we raster them, if we were to send say all digits like so 0b0000, then the symbol that got sent out would display across all of the digits.. we don't want that. So our goal is to light each digit space one by one at a super fast pace, so it looks like they are all on at the same time.
Really all we are doing is just sending the bits we want really fast to the 595's. You can see this effect if you take your phone camera and point it at a screen or clock (digital) you will see the digits flicker, this is the rastering effect. the camera is fast enough that it can see the flicker where as usually past 60-120 hertz the human eye just sees a constant image. pretty cool.
I will leave the test code in the main program on the repo in case anyone is interested in looking at how I tested things. a quick note. For those of you not familiar with C
This statement will only run bar, unless #if is 1. this is a good way to comment out code for future testing or use, the compiler will not compile anything in the #if 0 statement into your final output. this can save lots of space if perhaps you have lots of debugging code in place.
Next up is a simple interface to set time, display seconds. etc. I need to setup an interrupt for the output of the DS1307, so we can flash one of the DP lights to indicate seconds.
OK, I love the Attiny series of micro controllers. I love Atmel. But their USI hardware always bites me in the butt..
So I have a spare MSP430G2553 sitting on my desk. I have already created the I2C master library for another project I was using this micro controller on. We shall see how this goes.
On the Atmel front, I have found a few library's that are pretty awesome for debugging etc. They are from the Tinysaur project, owowod library. This allows for a single RX pin to help with debugging. pretty sweet.
So I will be transferring most of the code over to a code composer project. We should have a clock shortly.
I will make another project log detailing the use of the 74HC595's and rastering etc.
This part proved a bit challenging, I was up until 2am last night trying to get my timing and what not right... not really any luck. Fast forward to tonight.
Isn't this usually how it goes, usually a conversation with yourself.
"Man! I just don't know why this stupid thing isn't working write.. I'm pretty sure my code is right.."
checks code for the 50th time, makes some changes, tries again, still not working right.
"mmm well that kind of looks like a 1... " for some unknown reason you look at the bottom of the bubble display only to find out that at 2am while in your half insane state you put the chip on the bread board backwards ....
"Oh ya, that will do it... "
Getting stuff on the board!
I will admit I am not one for writing reports or anything highly detailed but I am going to try this time,. really, hard to make this reproducible on your own..
Our micro controller of choice is an Attiny 84A, awesome little hunk of plastic that internally runs at 8Mhz (after you clear the divide by 8 fuse, more on that later.) A bunch of HP bubble displays that require you to raster the numbers in order to make a decent display, trust me 1Mhz is not fast enough.
So how do we control this display when the Attiny 84A only has, 12 pins 10 if you want to use I2C and even less since we need reset functionality.
Probably the electronic hobbyists best friend on a bread board. This thing can turn 3 pins into 8 and cascade into even more with other 595's, 8, 16, 24, 32 .. etc all with 3 pins. It can also act as an input device! Amazing! so we are going to use 74HC595's to control the display.
Again there are hundreds of tutorials on the 595's out there that I will not be going into detail, aside from some code. I am sure there are some C library's for its use as well, but I like doing things the hard way.. I will update the details when I finish the library for the 74HC595. It's rather simple.