Microcontrollers - What would you do with an 8-pin processor?
I've been looking around for a good motorcycle intercom system and I've not been able to find one. Given that, I'm looking to maybe make one of my own.So I started looking around at microcontrollers to be the heart of the system. I'm looking to make something low cost so I'm looking at the cheap 8-bit processors. (I've also given some thought to higher performance 32-bit DSPs, but that's something else)I was surfing around the microchip.com site and looking at their low-end products. I was kind of stunned to see a six-pin processor. It has power, ground, and four I/Os. This got me thinking: what would I do with something of that caliber?Walking out to my motorcycle (this was before I broke my leg) I looked at the auxiliary brake light I have installed on it. Here's the features it has:
- Power-on voltage check
- Configurable pulsing on brake actuation
- The configuration is non-volatile
- Running light that pulses at ~ 50 to draw some attention from people's peripheral vision
From looking over the specs of the PIC10 line I couldn't find any with any EEPROM to store the configuration so I went up to the PIC12 line. These have a small amount (a few bytes) of EEPROM to meet the requirement of non-volatility.They also have an extra two I/Os bringing up the total to six in an eight-pin package.Now I have a few extra pins to play with.Here's what I came up with:The PIC12F1822 has 6 general purpose I/Os, a 4-channel ADC (Analog to Digital Converter) and 256-bytes of EEPROM.Here's the theory of operation:
- The power and battery voltage sense source is the license plate light that's on whenever the bike it turned on.
- The Voltage Regulator providers the 5V required to run the processor.
- All of the inputs (including the license plate line when it's used as an input) go through a voltage divider to get them down from their nominal 13.8V to the 5V that the processor expects.
- The license-plate line goes into an input that has the ADC to measure the voltage.
- Two outputs control a pair of NPN transistors that drive the strings of LEDs that do the hard work.
- Since the left- and right-side LEDs are individually switchable we can include turn signaling to the feature-set. This is controlled by the turn signal sense lines.
Operation details:
- On power-on we read the ADC to figure out the battery voltage. We blink the LEDs to indicate to the rider the read voltage. The calibration can be stored in the EEPROM to get things more accurate if you want.
- On power-up in the first 10 seconds we let the user "program" the brake light blink sequence by tapping the brakes a certain number of times. This gets stored in the EEPROM.
- When the brake light goes hot we start the blink sequence.
- When either turn signal goes hot we blink that side LEDs.
- If nothing else is going on we just blink both LEDs at a low duty cycle as just running lights.
Interestingly enough the guy that runs P3 lights (the one I re-engineered now) had the same idea with the turn signals. :-)Here's a rough bill of materials:
- Processor: $0.73
- Voltage regulator: $0.50
- Transistors: $1.00 (I'm guessing, tons to choose from)
- Resistors: $0.08 (I'm figuring $0.01 per, but they're cheaper)
- LEDs: 40 x $0.14 = $5.60 (20 per side)
- Wire: Nominal
Figure another dollar or two for the board and maybe five for the assembly and enclosures.Comes up to a bit less than $15.00 for the lot.Not bad. The P3 guy is charging almost $160.Of course you don't have to do the prototyping, testing, programming, assembly, marketing and everything else. It's actually a pretty good deal. If you have a motorcycle I think it's a good thing to have!No, I didn't open it up. I'm did this as a clean-room design as a thought experiment to see what I could use an 8-pin processor for.