HOME


Heroineclock

Highlights from the development of Heroine Clock, the longest lived shop creation of them all. It was an absolute mess, but worked.

The first purchase

You're probably going, what on Earth is this stupid thing?

Well it was seen as a way to get 144 lightbulbs for $5.

Unfortunately, the leads on the lightbulbs were too short. Not sure where to put it. The reason we're so interested in cheap lightbulbs is simple.

That's right. This 6" x 18" clock needs 52 light sources. It may one day allow humans to know the time without glasses. For 25 years we searched for clocks big enough to be see without glasses. No large clock existed commercially so our only resort was to have clocks everywhere in the dumpy apartment.

Then one day, was looking for ways to see if components were overheating without burning fingers. Commercial thermometers are too slow and expensive. Discovered a tiny thermister which could measure electronic parts quickly. With a microprocessor and a display this thermister could be a highly sensitive thermometer.

A large clock wouldn't be affordable if it couldn't perform some other function, however. Using the thermometer as the clock's second function would make it affordable.

The thermoclock would need to run on 6V battery power or AC power with automatic battery recharging. Looking at $40 for this thermoclock. Most of the cost is in the LEDs and microprocessor.

LED testing

Got 2 of the world's most expensive LEDs for testing. Radioshack charges $2 for a single LED which is only $0.10 in Hong Kong. After several tests including shaving off the lenses, the best position had both LED's facing each other and the lenses left intact.

The key was figuring out how to permanently mount LEDs in that position. Discovered fiberglass is resistant enough to heat to be used as a soldering surface.

With wax paper it's a very bright clock. Need a darker covering material than wax paper of course.

Lacking the money to make a fiberglass sheet for the entire clock, cut out 27 small fiberglass pieces to mount LEDs on. Went through a few respirators grinding those out. So much dust is coating the apartment now that breathing is like falling in love with members. Unlike french fry grease or cigarette smoke, fiberglass dust doesn't make you cough right away. You can breathe it for several minutes before dying.

Discovered using PNP transistors as current sinks is far more efficient than using NPN transistors as current sources. The switching voltage needs not be limited to the voltage of the gadget being powered with a PNP transistor, so switching a 2.2V LED with 5V is possible.

Major purchases

Some other projects in the shop reached a point where they required themometer testing to go any further so now our full attention is on HeroineClock.

Finding enough money for the LEDs was a real problem. Though bright, the test LED's were at the upper end of LED brightness. No-one in the US has LED's that bright for less than $2. The dollar collapsed in 2004 and semiconductor devices, which all must be imported, have become super expensive.

So spent $22 and got 72 of the cheapest superbright LED's available outside Taiwan. They're not as bright as the test LED's but usable.

Then came placement of the LED's in the most optimum position for illuminating the display. Take a look.

The supply voltage was soldered and the fiberglass pieces installed.

Massive soldering

Speaking of heroines, finally put together a heroine lightning bolt suitable for laminating rocket engines and power supplies and making clock icons out of.

The largest LED manufacturing project in the US since 0 A.D. took place. An army of American welders went through a massive amount of wire and solder, erecting this monster of electronics. Aren't you glad you don't need to build this.

All the LEDs fire up for the first time. On top of the LEDs, we've layered wax paper, tinted foil, and acrylic plastic, which gives the clock a nice smooth face despite the uneaven wood.

Comparison with the RadioShack clock from 9 years ago. You can barely see the RadioShack clock on the left even with the tinted foil on HeroineClock.

Without the tinted foil HeroineClock is blinding. Unfortunately these LEDs use an enourmous amount of power. The dream of running HeroineClock on batteries is all but impossible. Secondly it doesn't look like the microcontroller has enough memory to do everything. Not sure how they intend the 68hc11 to be used since none of them have more than 512 bytes of flash.

Introducing the PIC 16F877

We obtained some free alternative microcontrollers before beginning HeroineClock. These were just in case the 68HC11 ran out of memory like it did. Even the 18 pin DIPs have 3x the memory of the 68HC11. The 44 pin PLCCs used in HeroineClock have 14k of flash, 28 times the memory of the 68HC11. There's no way these'll run out of memory.

Unfortunately these microcontrollers have no serial port programming. Instead you must bit bang several pins from a parallel port to program them. After all those years of getting away from manual bit banging, we've evolved to a part which requires manual bit banging again.

The 16f877 lives

All the problems in parallel port programming from years ago came back. The signals from the parallel port are far from accurate enough to program the 16F87. The good news is, further research revealed the 16F87 assembler has macros to make it easier to program. As far as programming it in C, forget it. The C compiler is $1000. A commercial programming circuit is another $100.

You're probably going, what on Earth is this stupid circuit board for?

Here's the schematic in case you want to see how far biology majors are going to stay alive.

This is the amount of circuitry required to program the 16F87 if you can't afford $100. The programmer can burn a program into the flash while the 16F87 is installed in the circuit, merely by plugging in a 5 connector header. Fortunately, once you build one you can use the same programmer on any number of CPU's.

Two capacitors, a complimentary transistor pair, and an op-amp are involved in generating 14V, 5V, and 0V for the reset pin. The 16F87 requires 14V to go into programming mode, 5V to go into runtime mode, and 0V to reset.

Now half of this could have been done with a line driver but this was with the available spare parts only. Spare N MOSFETS, Xena diodes, and pullup resistors condition the parallel port's 3.3V signals to rock solid 5V square waves. Complimentary BJTs drive the charge pump to generate 14V. Years of analog knowledge went into that circuit.

The enemy.

After several weeks of banging on that thing, managed to get it to take a small program. The program puts 1010101 on some of the pins. Just doing that takes 8 lines of code, twice as many as it did on the 68HC11, but this is still an extremely powerful addition to our microprocessor war chest.

Things learned about electronics:

1) Verify mode on the 16F87 doesn't work. There's a defect in the part.

2) Although the 16F87 can run at 20Mhz, running it at 1Mhz conserves an enourmous amount of power.

3) The 16F87 won't work at all from an AC adaptor without a decoupling capacitor.

4) The sleep command on the 16F87 automatically times out after 1 second so you need to nest the sleep in an infinite loop.

5) Running the 16F87 on less than 4V causes it to reset every second, brown out protection they say.

6) The 23P06 MOSFET, designed in the 80's, has significant voltage drops compared to new MOSFETs. Can't afford a new MOSFET.

7) The LM317 voltage regulator imposes a minimum 2.5V drop.

8) 50 superbright LED's consume 10W. You wouldn't think LED's needed that much power.

HeroineClock main board with heat sinks.

HeroineClock vs. Maglight with the bare LED's showing.

16f877 lessons

So unless you call clrwdt every 18ms the 16F87 automatically resets. It's one of many things which make the 16F87 for experts only.

Also PORTA, PORTC, and PORTE don't work as inputs because some other features override them. It's a matter of searching through the documentation to find all the things tied to those pins. Rewired the switches to PORTD.

1120 bytes of software later, the 16F87 was telling time for the first time.

If all she had to do was tell time she would be done. Unfortunately the thermometer is going to take some doing. Thermisters have a 3rd order polynomial relation between temperature and resistance. Heroineclock also has a problem with overheating.

Now for something nihilistic.

Comparison of a new Weller tip to one which was ground down through many resharpenings until nothing was left. Weller tips seem to melt faster than Archer tips, but Archer tips are no longer sold. Weller tips have a thin laminate of steel over a copper core. After a few minutes the laminate wears out and they melt down in a matter of days. These tips are $2.50 a piece.

Thermal problems

The maximum temperature rating for a TIP31 transistor is 300'F and the maximum temperature rating for a LM317 is 257'F. Currently the LM317 hits 150'F and the TIP31 hits 175'F. Got rid of the MOSFET and put in an old fashioned TIP31 because the MOSFET couldn't be turned off all the way. This reduced the parallel shift flash slightly but not completely.

Finally got the music synthesizer working for HeroineClock's alarm. The music synthesizer has a 5 octave range with rests and complete timing control. The 16F87 has enough horsepower to run the clock, thermometer, and oscillate the speaker 2000 times a second.

Listen to the alarm sound.

HeroineClock needs to run at 20Mhz to do all these things. Kind of nihilistic how hand soldered boards today can run as fast as a Powerbook in 1993.

Final assembly

When HeroineClock was finished, the total firmware was 2633 bytes, leaving 11kbytes free. The 16F87 has so much memory we decided to allow selection of the alarm song from a library of different songs. Programming more alarm songs is going to continue forever.

Lessons learned today about the 16F877.

1) The reset pin must be connected to a low pass filter to avoid resetting from electrostatic discharge.

2) The low voltage programming pin must be connected to ground to avoid going into programming mode from electrostatic discharge.

3) Using capacitors to try to denoise the thermistor is worthless. It seems to create more noise.

4) Using capacitors to try to debounce buttons is worthless. You need to debounce buttons in software.

5) The A/D converter needs a long delay between conversions to recharge the sample-and-hold capacitor.

6) It's easier to use linear interpolation with a temperature table than solve the Steinhart-Hart equation to read a thermistor.

Some of these can be solved by changing the configuration register but that's in itself another operation.

The fully assembled faceplate is ready. It consists of a sheet of acryllic plastic to give a nice smooth surface, a sheet of windowshade foil to darken the inside, and a sheet of wax paper to diffuse the LED lights. This combination proved most effective and affordable in previous tests.

The LED panel with forward facing speaker and icons is finished. In keeping with our desire to make the ultimate clock, details like the loudness of the speaker and the icons were finally addressed here. Only a forward facing speaker would give loudness where it was needed most and Heroineclock has it. Only bright, backlit icons would be seen in the dark and Heroineclock has them.

The speaker mount was truly custom. It allows easy removal of the speaker for maintenance yet holds it in solidly.

The fully enclosed HeroineClock lives for the first time.

The electronics are enclosed in clear plastic for the world to see yet holes in the plastic allow adjustment of different parameters.

The heatsinks on the final board are elite, custom manufactured to fit in the remaining space. This board puts out an enourmous amount of heat powering 10W of LED's so developing heat sinks that were compact yet effective enough was a real challenge.

The backlit icons are lot more visible in real life than they are on camera. The alarm and pm icons go off but the heroine icon stays on at all times. The icons are laser printed on transparencies, two layers deep.

HeroineClock is still readable without glasses. She succeeds at the most important design requirement for the most part.

The thing which got Heroineclock from idea to funding was the multipurposing as a thermometer and clock. Heroineclock finally shows the current temperature. Especially convenient, HeroineClock has an auto mode where the time and temperature alternate every 5 seconds, just like a car dealership.

Heroineclock is more accurate than some commercial thermometers. The trick is to first convert the resistance to a temperature, then average many temperatures. She has a 255 byte lookup table for the A/D converter but don't expect to use HeroineClock in Layton any time soon. The lookup table only goes down to 32`F.

The probe is a bare thermister on a fiberglass rod, allowing it to measure small objects. Used lead-free solder but still wouldn't put it on your mouth. The probe runs between 1k and 20k and the cable has 1 ohm of resistance; nevertheless, the probe still seems susceptible to interference if left near a computer.

HeroineClock would be perfect if she could run on batteries but a $30 NiCad battery pack would only last 10 minutes. The current power supply is a mess of computer cables, stripped of the fan for silence. It gets real hot. The input voltage was eventually upgraded to 12V. It's so hard to make cheap semiconductors work at lower voltages that 12V has been the most convenient voltage for everything.

As expected, HeroineClock bathes the entire room in red light. Heroineclock's red floodlight and Heroine 2200's aluminum shine give you a red/white sunburn.

HeroineClock strikes a pose.

HeroineClock has current time, temp, alternating time/temp, and test modes. In test mode all the LEDs turn on to test for defects. All the time setting modes are one-touch so unlike normal clocks, there's no holding down multiple buttons in different combinations to set the time. The autorepeat while setting times is 1/8 seconds, unlike normal clocks, so the minutes can be set quickly. The 1/8 sec autorepeat is custom for us, since most people max out at 1/2 second autorepeats before they get confused.

The alarm switch is a toggle switch, easy to turn off without complete consciousness. There is no snooze since the we don't like being reawakened over and over. Finally, all the button presses trigger audio cues, making it very ergonomic.

Another look at the heroine icon.

Battery Backup installation

Battery backup is extremely important to Heroineclock, as we learned. She needs to be unplugged a lot and there are also a lot of AC line fluctuations.

The trick is to connect the battery and AC power to the same node through diodes, ensuring the AC voltage is higher than the battery voltage. The battery node powers the CPU and speaker but not the display. The display would drain the battery instantly, but the alarm still works on battery power.

Both go through the same voltage regulator so during a power failure, CPU always gets the same voltage. Unlike most clocks, Heroineclock has no battery sentinel, which conserves a lot of battery power. A battery sentinel would require drawing a small amount of current from the battery constantly to bias a comparator.

The battery dies rapidly even though it just powers the CPU. We estimate it to have 30 minutes before the CPU resets. The main problem is the clockspeed running at 20Mhz. Any slower and the CPU wouldn't be able to do all the things it needs to do.

The bill

HeroineClock required around $100 in parts and one-time experiments. It should be noted that BRG Precision makes custom LED clocks but charges $300 for a 7" version. There are $70 kits for building 4" LED clocks. None of the options have as many custom features as HeroineClock and our time certainly isn't worth $300.


(C) 1997-2021 Starving, flat broke Programmers
Hosted all these years by Sourceforge