It could be an evil robot!
I’ve completed quite a bit work on my beacon in the past two weeks.
I’ve re-written the code to work with the target PIC12f683, it turns out that 2Kb or prog memory and 128Kb Ram is way more than I needed. That was a nice surprise.
The re-write was completed using BoostC rather than MCC18 as BoostC as it’s the only complier I have for 12f pics. It took a while, but after reading the datasheets again it worked out ok. BoostC has a different set of defines to mcc18 and also uses macros to set/clear bits which seems a bit long winded.
I’ve modeled the rotation effect as what I call a bucket brigade. Each of the 8 LEDs in beacon is a “bucket”. The system starts off by “pouring” in a single buckets worth of light drop by drop into the first LED bucket, when the bucket is full it triggers a tap that opens in its bottom and starts dripping light out of this bucket LED and into the next which when full triggers it’s tap etc etc… This is rather poorly explained… The end result is light smoothly moving from LED to LED around the beacon and ends up with a max of two LED lit at any one point in time.
To maximize the brightness of the LED’s I wrote an interrupt driven PWM routine that “knows” which two buckets contain light and only multiplexes (charlieplex) those LEDs giving a duty cycle of 50%. The PIC runs of it’s internal oscillator at 8Mhz, the PWM interrupt runs uses timer 0 with a 2/1 prescaler giving an interrupt every 255uS (3921Hz) my PWM routine is 5 bit (32 steps) divided by two LEDs so each LED is refreshed at around 61Hz (3921/32/2).
I’ve also used one of my spare GPIOs as an input that when pulled low “turns off” the beacon. The input is pulled high by default which initiates the beacon with it’s slow spin up. The idea being that this pin could be used by an external controller to start and stop the beacon.
One important change this time using boost C was that I purchased a Pickit2 from my local electronics shop. As much as I liked using TinyBld, being able to program directly from MPLAB using ICSP is so much faster and easier than I had expected. It’s really nice to be able to program and verify in one step from MPLAB in a few seconds.
Pickit2 also has a In Circuit Debug facility too which is great, but requires an adapter which I don’t have and didn’t fancy paying 17 euros for. The ICD adaptor for these tiny pics is breakout board that contains a 14pin version of the target PIC using the extra pins for debugging, thus allowing you to use all of the 6 IO pins in your circuit. Larger PICs like the 18f2525 can be ICD’d using the same connections as the ICSP as long as you are careful to keep the 2 required pins free, not that hard when you have a 28 pin PIC.
I’ve built a prototype LED Driver circuit board. The idea was to make it as small as possible so I’m using surface mount components and a double sided board. I’m using a Zener diode regulator to as a simple space saving regulator. A 500mw 5v1 zener should keep VDD clamped to 5.1v irrespective of supply voltage (within reason) and as I only need around 20mA the Zener should be fine.
However as this is still a prototype I want to have a proper ICSP port on-board which kind of ruins the tiny-ness of the whole thing. 6 Pins at 0.1″ spacing is pretty large when working with SMD components!
Simple circuit design.
Double sided board layout created in Eagle CAD. Smallest
trace is 16mil with 12mil spacing on the ground pour. I had
While I was at it I made a new LED board that had the
two layers of LEDs at 45 degrees to each other. This
should make the rotation look smoother when using
a single colour.
New LED board constructed with blue 1206 LEDs top and bottom.
PIC is in SOIC package 0.05″ pin spacing.
- Need to make the circuit even smaller again to fit within a 4×2 LEGO brick. I’ll need to make better use of the back side of the PCB.
- Remove the button and replace with a connector pin.
- Try to reduce the size of the LED beacon connector. I’ll try using different parts.
- Get rid of the ICSP header, but add test pads to allow me to make a special programming jig.
- Build it all into a Lego brick.
Update: Prototype 2 is on it’s way.