Main Site Documentation

Motorcycle Instrumentation Project - FEZ Panda II


As the topic name suggests I have started with a project to do my own custom instrumentation for my motorcycle.

The display unit itself is an HTC Touch Pro with Windows Mobile 6.1. Comms between the phone and the Panda II will be via Bluetooth.

So far I have already done the code for reading temperature, voltage and the Neutral state, all with the help of code I found on TinyCLR. The circuit example for the temp sensor I actually found on a Arduino related site and I researched voltage divider circuits on the net to bring the operating voltage down to safe levels for the analog pins to handle.

Now, my electronics skills are quite basic as well as my knowlegde of FEZ and the FEZ api’s.

The problem I am now facing is how to read the motorcycle’s engine RPM (speed should be closely based on the same principle). I have searched for FEZ related cases but couldn’t find anything helpful.

I would be picking up the RPM signal from where it goes into the existing tachometer.

  1. How would I go about connecting this safely to something like an interrupt pin on the Panda?
  2. Could I use code like William’s code as per the topic PulseIn() ?

Any and all help will be greatly appreciated.


Welcome to the forum!

What kind of signal goes to the tachometer, is it an analog signal? What is the maximum voltage?


Thanks for the welcome and the prompt reply.

I’m not 100% sure on the type of signal but do think it is analog.

According to the wiring diagram the tacho input comes directly from the ignition control module.

Then according to troubleshooting / testing the signal peak voltage should not be less than 10.5V

Unfortunaely I don’t have a peak voltage tester but just a standard one. I would assume the peak voltage would be pretty much the same as the normal system voltage which would be in the 13 to 14 volt range.

Could I then merely use a voltage divider?

Would I need some kind of filtering or smoothing too?


The RPM is likely a pulse stream with one pulse for every revolution of the crank OR one pulse every time a sparkplug fires (which you need to divide by the number of cylinders).

You can use different techniques to measure it:

  1. Measure the duration of a pulse and work out how many per minute it would be.
  2. Measure the number of pulses during a specifc time and calculate how many there would be in a minute.
  3. Pump the pulse stream into an RC (Resistor/Capacitor) circuit and measure the voltage, which will be proportional to the pulse rate. It may be that your bike already does this and give an analog output, but it is hard to say without putting an oscilloscope on it.

You’re probably seeing 10V because of the pulse stream - not a linear analog value.

I suggest passing the signal through an opto-coupler first. An engine is a harsh thing and you want to isolate it from the sensitive Panda electronics.

Once you have a digital signal, you can use an Interrupt pin.When the pulse starts, the interrupt will fire. Record the start tick count that is passed with the interrupt event. Now wait for the next pulse and record the time again - and calculate the difference in time. This is method 1 above.

To try and determine if your signal is analog or digital, put an LED with a 1k resistor on it. If it flashes faster or slower based on RPM, it is a digital pulse stream. If it glows brighter or dimmer, it is an analog signal.

I must say that it will be good if you could determine the type of signal and max voltages before connecting it to anything to avoid damage.


Thanks realiser!

If it is a pulse stream then hopefully it will be one for every crank rotation which will make timing them just that slight bit easier. I will most likely then use the second technique you mentioned and count a few pulses before making calculations.

At the 10500 rpm redline there will be 175 pulses per minute which will be 5.714 ms per pulse. Even if is a pulse for every sparkplug firing then it will only be 350 pulses per minute and 2.857 ms per pulse as the engine is a v-twin.

But I must admit the third technique sounds rather tempting to try and I probably will try it to satisfy my curiosity. I don’t have an oscilloscope but definitely try your suggestion to use an LED to see if it’s a pulse stream or not.

And yes, I will most definitely not connect anything to the Panda before I’m sure of wht I’m dealing with. And will also use your advise on using the opto-coupler.

I would probably only get to do my testing tomorrow aftenoon or on Sunday as I need to go and buy a new battery for the bike tomorrow morning. Earlier this week the battery decided to die on me.


It turns out the bike’s battery didn’t die but was just flat for some odd reason. After a few hours of charge yesterday the bike started quite easily and charging voltage seemed fine. The battery held the charge and this morning the bike started fine again.

So I managed to connect an LED to the RPM signal and it is flashing. Quite fast at idle and goes solid but brighter as you rev it up.

So, if I understand right I still need an opto-coupler even with this pulse signal?

What type of opto-coupler would be sufficient as I see there are different type?

How would I then add the opto-coupler into the circuit?

I don’t suppose there is another way of determining max voltage other than using a peak voltage meter?


The blinking led is a good sign. Probably 1 pulse per revolution so the faster the idle the faster the blinking. At about 25 pulses per second your eyes will just see the stream as solid. This is about
1500 RPM.

PC817 or AN25 are popular choices for optos.

The opto coupler is basically an LED and photo transistor inside. You’ll drive the LED like you did your visible led and get the signal from the transistor.

On the transistor side, put a 10k resistor from 3V to the collector and connect the emitter to ground. Now take a signal from the collector to the Panda. This is an open collector so the resistor pulls the signal up to 3v and your rpm signal will pull it to 0v. Your signal will be inverted but it shouldn’t matter… Just count falling edges.

Use the interrupt pin and work out the time difference between pulses. Make sure you only count high to low transitions.


Thanks! This will give my project a major boost being able to read the RPM.

Fortunately I work right next door to a fairly large electronics suppliers. So as soon as I have a few minutes to spare I’ll walk over and see if they have either of these two optos you mentioned. Depending on time this evening I might even be able to start playing with it.

Unfortunately they don’t stock any FEZ (or even Arduino) related components. The only guys here in South Africa that do stock it is like 600km away but you can order online and have your stuff a day or two later. So I’m working on the local company to get them interested in stocking the FEZ and Arduino stuff. Just about all the local students buy their stuff from them.

So my next big thing is to get my hands on a ZX-Bluetooth module as it seems to be the easiest to use to add Bluetooth to the Panda II


Excellent! Another South African. There are a few of us lurking about here.

Give Netram a try for a Fez. They are in Durban but they can get a board to you overnight by courier.

Contact me at fez at globalpro dot co dot za to chat.


Awesome! Yeah it’s great to have found another South African.

I did in fact receive my Panda II from Netram last week Monday. I actually sent them an e-mail last night to hear about the possibility of them getting in something like the ZX-Bluetooth component.