All About Circuits Forum Beginner PIC tachometer project
 Register Blogs FAQ Members List Today's Posts Search Today's Posts Mark Forums Read

 Embedded Systems and Microcontrollers Discussion forum for projects and working with embedded systems and microcontrollers (FPGAs, PICs, AVRs). Get help with hardware issues and embedded programming.

#1
03-28-2008, 01:42 PM
 Howesy New Member Join Date: Mar 2008 Location: Worcestershire, UK Posts: 4
Beginner PIC tachometer project

Hi,

I'm a beginner in electronics and have started playing around with PIC's. I'd like to start a project to complement my motorcycling hobby. I'd like to monitor the engine speed of my bike and record the peak rpm and average.

The tacho on my bike is controlled from the ecu which outputs a 10.5v square wave. My understanding is that this is at too high a voltage to be connected directly to a PIC which operates at 5v max.

Can anyhow explain the electronics I'd need between the ecu output and the PIC (a diagram would help!).

FYI. My bike is a Honda CBR1000RR and the PIC I'm using is a PIC18F4520.

Regards.
#2
03-28-2008, 02:32 PM
 Søren Senior Member Join Date: Sep 2006 Location: Denmark Posts: 273

Hi,

Quote:
 Originally Posted by Howesy The tacho on my bike is controlled from the ecu which outputs a 10.5v square wave. My understanding is that this is at too high a voltage to be connected directly to a PIC which operates at 5v max. Can anyhow explain the electronics I'd need between the ecu output and the PIC (a diagram would help!).
From the tacho output to the PIC I/O put a resistor of around 10k to 50k and put a zener diode (Vz = 4.7V to 4.9V) between the same PIC pin and ground (V_ss on the PIC) anode towards the PIC pin.

A diagram seems a bit overkill for 2 simple 2-terminal components
__________________
Regards,
Soeren

>>> Whatever works... Works <<<
#3
03-28-2008, 04:19 PM
 SgtWookie Expert Member Join Date: Jul 2007 Location: In the vast midwest of the USA; CST Posts: 22,032

A 10k resistor will allow just 1.05mA of current through itself with a 10.5v signal. That actually might be close to the maximum resistance limit for this application. I don't know how much current the PIC needs to see as an input signal, and in particular what the input capacitance is, which should be in the PIC's datasheet.

At low RPM's, the input capacitance will have a negligble impact, but at high RPM the RC time constant may be cause for concern. The Zener diode itself has some capacitance, which must also be taken into account.

See the attached circuit diagram and simulated O-scope trace. Soeren's proposed circuit is on the right. The output from his circuit is the green trace below. The slow fall time may be cause for concern if your PIC does not have Schmitt inputs, as it may cause unwanted oscillations and resultant heating. Usually, you want such signals to have very short rise and fall times.

I threw together the circuit on the left.
R1 limits the input current through the base of Q1 to under 1mA. R1 could actually be increased to 50k Ohms without impacting the output.
Q1 amplifies the current supplied via R1.
R2 limits current through Q1's collector to approximately 10mA.
C1 is a bypass capacitor; it ensures a steady supply of current for R2.
When Q1's collector voltage rises to 4.7, D1 acts as a shunt limiter to prevent the voltage from rising further.
The output signal (the yellow trace) is inverted from the original tach signal, but this should not present a problem. You'll see that the rise and fall times are much shorter than the simple resistor/Zener combination.
Attached Images
 TachDriver.PNG (62.3 KB, 226 views)
__________________
General info:
If you have a question, please start a thread/topic. I do not provide gratis assistance via PM nor E-mail, as that would violate the intent of this Board, which is sharing knowledge ... and deprives you of other knowledgeable input.
#4
03-29-2008, 12:49 PM
 Howesy New Member Join Date: Mar 2008 Location: Worcestershire, UK Posts: 4

Many thanks to you both. I'll give it a try and report back.
#5
03-29-2008, 02:53 PM
 Nomad Junior Member Join Date: Oct 2007 Posts: 43

most pic applications i've seen call for 4.7k or 10k as pull ups. the weak internal pull ups are 100k. I would lose the zener all together. use either a simple 2 resistor voltage divider, or the Sgt Wookie's circuit with the collector resistor r2 changed to 4.7k and going to the pics 5v supply instead of the vehicles 12v. no zener needed. nor the cap for that matter as your 5v supply should already have filtering caps, along with one or more at the pic itself.

Last edited by Nomad; 03-29-2008 at 03:04 PM.
#6
03-29-2008, 03:09 PM
 Nomad Junior Member Join Date: Oct 2007 Posts: 43

also if i'm remembering correctly that pic does have a couple inputs that are shmitt trigger.
#7
03-29-2008, 03:12 PM
 SgtWookie Expert Member Join Date: Jul 2007 Location: In the vast midwest of the USA; CST Posts: 22,032

Nomad's 2nd suggestion sounds better - that of losing the Zener and using the transistor with a 1k Ohm resistor to the PIC's power supply. A 1k pull-up resistor on the collector will limit maximum collector current to 5mA. Eliminating the Zener also removes it's capacitance, which will result in shorter rise and fall times and a more "square" input signal.
__________________
General info:
If you have a question, please start a thread/topic. I do not provide gratis assistance via PM nor E-mail, as that would violate the intent of this Board, which is sharing knowledge ... and deprives you of other knowledgeable input.
#8
03-30-2008, 12:25 PM
 Søren Senior Member Join Date: Sep 2006 Location: Denmark Posts: 273

Hi,

Quote:
 Originally Posted by SgtWookie [...] I don't know how much current the PIC needs to see as an input signal,[...]
But still you choose to (wrongly) assume that there's a problem?

Quote:
 Originally Posted by SgtWookie [...] at high RPM the RC time constant may be cause for concern.
No it won't. One thing is your blind faith in sims (which is cause for concern), but your total lack of a link to reality is even worse - you're indicating that a fall time of slightly above 2µs should present a problem in automotive ignition timing.

Quote:
 Originally Posted by SgtWookie See the attached circuit diagram and simulated O-scope trace. Soeren's proposed circuit is on the right. The output from his circuit is the green trace below. The slow fall time [..]
Time for yet a reality check - I seriously doubt that Howesy's Honda turns 4.800.000 (4.8 million) RPM as you seem to believe - however it might be equipped

Quote:
 Originally Posted by SgtWookie [...] cause for concern if your PIC does not have Schmitt inputs, as it may cause unwanted oscillations and resultant heating.
See, if you had some experience with PIC's, you would know. You are inventing problems that just aren't there, I really wonder why and what you're trying to prove.

Quote:
 Originally Posted by SgtWookie [...] Usually, you want such signals to have very short rise and fall times.
Really? So what I have learned during decades of involvement with automotive ignitions for high power motors, about the very transient ridden automotive electrical environment has suddenly changed?

In short: Don't use sims since they only really work well inside the fairy tale environment it creates. Don't use sims with data so far from real life specs. And finally... Get to know both PIC's, the problems with designing for the automotive environment and some sensible tutoring on engine RPM before you invent problems that isn't there and try to solve them with an overengineered circuit that has no transient dampening.
Or to put it even shorter: Keep your advice to something that you are knowledgable about, whatever that might be.

A simple voltage divider will be quite problematic as well, as the PIC will most likely commit seppuko on the first load dump transient it sees.
If any changes should be made to the no-nonsense resistor/zener circuit at all, it should be adding a slight bit of capacitance parallel to the zener.
__________________
Regards,
Soeren

>>> Whatever works... Works <<<
#9
03-30-2008, 05:06 PM
 thingmaker3 Super Moderator Join Date: May 2005 Location: Rural, Oregon GMT -8 Posts: 5,072 Blog Entries: 6

Debate is encouraged here. Confrontation is not. Let's keep the discussion on the circuitry. Confine attitudes and personal jabs to other websites - we don't do those here.
__________________
"I want to establish in your mind very clearly that you must not think I deny all that I do not admit. On the contrary, I think there are many things which may be true, and which I shall receive as such hereafter, though I do not as yet receive them; but that is not because there is any proof to the contrary, but that the proof in the affirmative is not yet sufficient for me"
#10
04-23-2008, 02:15 PM
 Howesy New Member Join Date: Mar 2008 Location: Worcestershire, UK Posts: 4

I've given the circuit a try (10K Resisitor and 4.7v Zener) and had no joy. With the resistor inline no pulses are recorded. If I bypass the resisitor then I get pulses being counted but it stops the tacho on my bike working.

Is there anyway around it?

 Tags beginner, pic, project, tachometer

 Similar Threads Thread Thread Starter Forum Replies Last Post MMcLaren The Completed Projects Collection 21 12-12-2012 06:03 PM icem Embedded Systems and Microcontrollers 10 02-03-2011 10:52 PM danger General Electronics Chat 7 10-12-2010 01:07 AM vir1505 Embedded Systems and Microcontrollers 0 02-24-2009 06:13 AM

 Thread Tools Display Modes Linear Mode

 Posting Rules You may not post new threads You may not post replies You may not post attachments You may not edit your posts BB code is On Smilies are On [IMG] code is On HTML code is Off Forum Rules
 Forum Jump User Control Panel Private Messages Subscriptions Who's Online Search Forums Forums Home Electronics Forums     General Electronics Chat     The Projects Forum     Homework Help     Electronics Resources Software, Microcomputing, and Communications Forums     Programmer's Corner     Embedded Systems and Microcontrollers     Computing and Networks     Radio and Communications Circuits and Projects     The Completed Projects Collection Abstract Forums     Math     Physics     General Science All About Circuits Commmunity Forums     Off-Topic     The Flea Market     Feedback and Suggestions

All times are GMT. The time now is 10:29 PM.