I've been chatting about this over on the RC51 forum. Thought I'd post over here, since the good folks of the ST community might find this interesting too. I'm never really sure which category to post into, so I'll stick it in the "General" section. Mods, please move this as appropriate.
I've undertaken a renewed interest in embedded micro-controllers lately. Over the past 20 years, I've puttered around with various MC's. I've worked with MC's such as - Intel 805x, Motorola 68xxx, 6502, and Zilog Z80. But never MicroChip PIC MC's. So, I wanted to educate myself on PIC MC's. This little project was simply a means to and end.... learn PIC16Fxxx microcontrollers, using a real-world application. And have something to show for it in the end.
It all started one day a few weeks ago. A buddy and I were talking (he has a Suzuki TL1000R)... he says "I wish I had a gear position indicator". I said "I think we can do that". So, after some research and development, I built him a GPI using a PIC16F88. Turned out to be a rather easy task. Since the Suzuki has a wire coming out of the transmission carrying a voltage ranging anywhere from 0 to 5 volts, depending on what gear it's in, I just used the PIC16F88's A/D converter to read the voltage, and convert it to a gear number. Once the gear number is known, it is a simple matter of displaying it on a seven segment LED, which is now velcro'd to the side of his instrument cluster.
Voila... Now he has a GPI, and I have a good bit of real world experience on PIC micro-controllers.
But noooooooo...that wasn't good enough, I was thinking.... Now I gotta have a GPI too.
So, I set out to build a GPI that'll work on my ST1300 and my RC51.
However, because Honda doesn't have a wire coming out of the transmission (like the Suzuki's do), a very different approach was required.
Here is the approach I took -
- Hondas have a vehicle speed sensor (mine do anyway), which emits a very nicely formed 5v digital square wave. The square wave's frequency varies in direct proportion with wheel speed, via a variable reluctance sensor coupled to one of the gears on the final output shaft (aka, counter-shaft).
- Hondas also have an Ignition Pulse Generator (IPG). The IPG emits a very nicely formed semi-square A/C signal. The frequency of the signal varies in direct proportion with engine speed, via a variable reluctance sensor coupled to the flywheel. There are exactly 12 pulses/cycles per crank shaft revolution.
- Hondas also have a neutral switch. When the bike is in neutral, the switch provides continuity to chassis ground.
- Hondas also have a clutch switch. When the clutch lever is pulled in, the switch provides continuity to chassis ground.
Given those four signals....
Using a PIC16F88 micro-controller, I've written code that essentially counts pulses, monitors the neutral & clutch switches, and outputs a result on a seven segment display. The micro-controller's on-board microprocessor, running at 4Mhz, does this over and over, very quickly (like a few hundred times per second). If the neutral switch is closed, I know to display a zero (my choice for indicating I'm in neutral). If the clutch switch is closed, I display a dash (my choice for indicating I'm between gears).
The core algorithm, essentially just counts pulses arriving from the speed sensor, and at the same time tallies up the number of ignition pulses that arrive for a given number of speed sensor pulses. Given this ratio of speed sensor pulses -to- ignition sensor pulses, it calculates which gear the bike is in, and displays that gear number on a seven segment display. Very easy, and very elegant.
I've also included an "Initialization routine" that allows me to put the code into "Learning" mode. The learning procedure essentially allows the user to tell the micro-controller, via interaction with a single pushbutton on the back of the display, how many gears the motorcycle has (cuz the ST1300 is a 5-speed, and the RC51 is a 6-speed). And then allows the code to "learn" how many IGN pulses per given set of speed sensor pulse for each gear. These learned values are then stored in nonvolatile EEPROM memory built into the micro-controller. Thus, this "learn" mode only needs to be performed once, upon initial installation of the GPI.
It took me a week or so to develop the code, and build a prototype. I just installed it on my ST, and took her for a spin (on a lunch break). I'm happy to report, it worked beautifully. Solidly indicates which gear I'm in at all speeds (up to legal limits, of course) and all engine RPM's.
I did do a fair bit of googling, to see if anyone else had done something like this. I found a few commercial offerings, but no home-brew stuff.
So, in case there are others out there with a propensity to do so, and are a little handy with a soldering iron... I thought I'd share the intellectual capital here. It's a pretty simple circuit. It only took me one night to build (once I had debugged it on a breadboard). With the exception of the micro-controller and the seven segment display, all the components are readily available at places like Radio Shack, Jameco, DigiKey, or Mouser. There's one IC (a PIC16F88 micro-controller), a seven segment display, three transistors, two diodes, a couple capacitors, a 5-volt regulator, and a hand full of resistors. The seven segment display turns out to be a critical component. The first one I used (out of the junk box) just wasn't bright enough to see on a sunny day. I eventually managed to find a super-bright red seven segment LED display at Kingbright (www.us.kingbright.com), and it is very visible in direct sun light.
I'll post a schematic, and source code for the micro-controller, in a few minutes.
Before anyone asks "Can you make me one", or "Will you sell me one"... I just wanna set expectations up front. This was just an experiment for me. Like I said, it was a means to an end. I built this thing using nothing more than a few junk box parts. I am in no position to start mass-producing GPI's. It is, however, my sincere hope that, by committing the intellectual capital to the public domain, and GPL'ing the source code, others will benefit. I also hope that other like-minded, talented, innovators out there will pick it up, improve/enhance/change it, and contribute those innovations back here to the community.
Here is a quick pic of the thing installed on my ST1300. The ST is sitting on the center stand, idling, in second gear (as can be seen on the display). The GPI display is velcro'd to the base of the handle bars, just back from the ignition switch.
Edit: 12/28/2008 -
Added updated circuit schematics & code for V1.3. Changes include the incorporation of a photo-cell, so that the seven segment display's intensity will automatically adjust according to ambient light conditions.
Edit: 2/8/2008 -
I've stocked up on all the components required to build the GPI. I can source individual parts and/or a complete builders kit.
I have 4 different types of builders kit. Each contains all the discrete components necessary to build a GPI, containing.... either;
1) External .8 inch LED display, with red acrylic display enclosure components, and ambient light sensor
2) External .8 inch LED display, with red acrylic display enclosure components, and no ambient light sensor
...... Note: see post #4 for an example of the prototype of the above two variations
3) In-dash .56 inch LED display (no display enclosure components), and ambient light sensor
4) In-dash .56 inch LED display (no display enclosure components), and no ambient light sensor
..... Note: see post # 154 and post # 161 for scoutdriver73's example of in-dash mounting.
All builders kits now include the custom printed circuit board (see post # 166 below). The kit contains a blank circuit board, and all the discrete components necessary to build the circuit. The microcontroller comes pre-programmed with the latest version of the code. You get to solder "everything" together, and integrate it into your bike. See post # 4 below for a document containing the steps taken to install it on my ST.
I stock only RED superbright seven segment LEDs from Kingbright. And only the two sizes noted above. If you want a different size and/or color, you are on your own.
PM, or email, me with your needs. Prices and availability may vary, depending on my suppliers & supplier costs.
The last of the remaining kits is gone. I do not plan to re-stock the kits. From this point forward, you're on your own for parts/components. Sorry.
› See More: ST1300 - Gear Position Indicator (Do It Yourself)