[Timothy] is honing his microcontroller skills with this electronic dice project. In addition to giving him an opportunity to work on some code, the use of an 8-pin chip provides a design challenge for driving the twelve pips and providing a user input.
The project started off with some $4 strings of LED Christmas lights. He promptly disassembled the strands, each yielding 100 LEDs. The microcontroller he chose to work with is a PIC 12F629. It’s DIP8 package provides six I/O pins to work with. When examined closely you will find that the pips on a die are always present in pairs with the exception of the center pip. This means that only four pins are needed to drive one die. You can see a pair of transistors above; one is a PNP, the other an NPN. These are both driven from the same uC line, which toggles between the pair of die. This accounts for 5 of the available pins, with the sixth monitoring the push button.
I like projects that use 8-pin chips. They always look so neat.
Few suggestions:
1. RA3 has internal pullup option and does not need an external pullup
2. 7 + 7 = 14 LEDs, drivable via charliplexing using 5 pins. This configuration would avoid the need for external transistors and resistors (max duty cucle will be small, and current is limited by PIC’s IO pins)
To the *plxing; you lose the brightness going this route.
Compared to the current route?
Exactly. Current one plexes 2 elements, charlie plexes 14 elements, or 7x dimmer
Not necessarily true, when charlie-plexing you can push higher currents through the leds to help make up for the difference in time spent off.
Almost all LED’s have an extra rating called pulse-current which usually specifies the duty cycle as well.
Besides pushing higher currents, the trade offs includes excluding the resistors (reducing parts count), increased wiring complexity and increased programming complexity.
It’s the last two that can cause problems. If I feel like being slick and use Charlieplexing in a project, I have to keep careful track of any changes in the wiring and write copious notes in my routines because six months later I’ll come back and go, “WTF was I thinking?”
To figure it out in the shortest amount of time usually involves copious amounts of caffeine, alcohol, or mind altering drugs or some combination of the three.
My body can only take so much abuse.
@SavannahLion:
I know what you mean about your body being abused. Mine’s been through the wringer – I’m surprised I can still do what I do.
As far as “WTH” feeling when going through old projects – I have had that before, even to the point of vocally criticizing code (and the programmer) to my colleagues, only to stumble across _my_ initials in the code. Oy!
I am currently reworking one of my first projects that I worked on after my strokes, a remote-controlled AC outlet. Besides being really ugly – my soldering skills weren’t quite back to snuff yet – it wasn’t put together well. I plan to use it for my Christmas lights on the office patio, just point the remote through the window and turn the lights on and off.
BTW: Thanks everyone for the comments, and thanks to Hack-A-Day for posting my project!
RA3 does not have a weak pull-up. Per the spec:
3.2.1 Each of the GPIO pins, except GP3, has a individually configurable weak internal pull-up.
So the 10k pull-up I included in the design is required. I tried it without the 10K pull-up, with the /GPPU bit in the CONFIG register set to both ‘1’ and ‘0’, and – it doesn’t work. Either it sees the button as always pressed, or there are spurious glitches on the line. And the ‘roll dice’ button doesn’t work.
As to the charlie-plexing – I could put RA2 on the anodes of one set of LEDs and the cathodes of the other set and then use that to select the die face. I’ll try that out on my next board. I’m making Christmas presents – heh – so there will be quite a few made.
Most of the resistors are on this board because I have to connect the PICKIT2 dongle to it for in-situ programming. When I get to the ‘production’ versions – IE: the ones I will use for gifts – the PICs will be pre-programmed and I won’t need the ISP header, socket and most of the resistors. If the charlie-plexing works, that will _really_ reduce the part count.
Thanks for the ideas!
These are the kind of hacks I love. Few pins, minimal parts, yet lots of I/O.
+1
…and in before the ‘back in my day we had to use 4017’s & 555’s, and we liked it’ crowd.
Repost for starters also this is a ridiculously old in terms of hacks.
By that I mean using an 8 pin microchip PICs to control 14 LEDs to create 2 dice.
Granted not using a 12F508( cost 58p per 1) but the 12F629(cost 1.08 per unit)…
It’s been on this site at least once before and is also in this famous PIC introductionary book http://www.amazon.co.uk/PIC-Microcontroller-Personal-Introductory-Course/dp/0750666641
I used the PIC 12F629 because it was what I had, other than a PIC 12F1840 which really would have been overkill. I like the 12F629 as it is versatile for a lot of different projects. Plus a little faster (8mhz), which allows me to do bit-banging I2C at around 80Khz.
I haven’t seen the other die projects out there – I previously did a single die version, which display two die values on one die by ‘flashing’ between the values. I guess the evolution of projects that use an I/O limited micro seem to follow similar paths.
I used to be a hw/sw engineer for various startups and larger companies – but have since been sidelined by 4 brain stem strokes. I can’t do fine soldering anymore, so I stick with through-hole components and DIP ICs instead of surface mount. I mostly just do these type of projects to keep my skills honed and not go stir-crazy in my forced retirement.
The most important thing to me is I have fun doing these projects – some small (like this) and some big. Can’t work anymore, so I might as well hack!
Good on you! There’s little new in this world, and this is genuine, ingenious hack – a quality piece amongst the flotsam of mediocracy. More please, TS!
Who cares whether it’s old or new. You made something cool and got it published on HAD. +1 from this old dog.
“pair of dice” or “toggles to the opposite die”
Very clean looking project though. :)
Next Project: Dodecahedron capable Bag-O-Dice in one.
?????
HA!
Send me the specs and I’ll see what I can do!
I’ve posted the code, if anyone is interested.
Cool, how about adding a shake sensor to this:
http://www.electrodragon.com/?product=vibration-switch-sensor-sw-18020p
Maybe – but I can add a shake sensor using a weighted spring and a contact post. Nice idea!
For you mikroC fans out there..
http://pastie.org/5127139
It’s for 12f683 (the only available Friday night).
Tnx Timothy, you saved my weekend.