All About Circuits Forum  

Go Back   All About Circuits Forum > Software, Microcomputing, and Communications Forums > Embedded Systems and Microcontrollers

Notices

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.

Reply   Post New Thread
 
Thread Tools Display Modes
  #1  
Old 03-28-2008, 01:42 PM
Howesy Howesy is offline
New Member
 
Join Date: Mar 2008
Location: Worcestershire, UK
Posts: 4
Default 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.
Reply With Quote
  #2  
Old 03-28-2008, 02:32 PM
Søren Søren is offline
Senior Member
 
Join Date: Sep 2006
Location: Denmark
Posts: 273
Default

Hi,


Quote:
Originally Posted by Howesy View Post
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 <<<
Reply With Quote
  #3  
Old 03-28-2008, 04:19 PM
SgtWookie's Avatar
SgtWookie SgtWookie is offline
Expert Member
 
Join Date: Jul 2007
Location: In the vast midwest of the USA; CST
Posts: 22,032
Default

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
File Type: png 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.
Reply With Quote
  #4  
Old 03-29-2008, 12:49 PM
Howesy Howesy is offline
New Member
 
Join Date: Mar 2008
Location: Worcestershire, UK
Posts: 4
Default

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

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.
Reply With Quote
  #6  
Old 03-29-2008, 03:09 PM
Nomad Nomad is offline
Junior Member
 
Join Date: Oct 2007
Posts: 43
Default

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

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.
Reply With Quote
  #8  
Old 03-30-2008, 12:25 PM
Søren Søren is offline
Senior Member
 
Join Date: Sep 2006
Location: Denmark
Posts: 273
Default

Hi,

Quote:
Originally Posted by SgtWookie View Post
[...] 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 View Post
[...] 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 View Post
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 View Post
[...] 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 View Post
[...] 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 <<<
Reply With Quote
  #9  
Old 03-30-2008, 05:06 PM
thingmaker3's Avatar
thingmaker3 thingmaker3 is offline
Super Moderator
 
Join Date: May 2005
Location: Rural, Oregon GMT -8
Posts: 5,072
Blog Entries: 6
Default

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"
- Michael Faraday
Reply With Quote
  #10  
Old 04-23-2008, 02:15 PM
Howesy Howesy is offline
New Member
 
Join Date: Mar 2008
Location: Worcestershire, UK
Posts: 4
Default

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?
Reply With Quote
Reply   Post New Thread

Tags
, , ,


Similar Threads
Thread Thread Starter Forum Replies Last Post
Project: PIC 4-Digit Single-Chip 24 Hour Clock MMcLaren The Completed Projects Collection 21 12-12-2012 06:03 PM
HELP What PIC to use for my project icem Embedded Systems and Microcontrollers 10 02-03-2011 10:52 PM
Beginner help with DIY siren project. danger General Electronics Chat 7 10-12-2010 01:07 AM
PIC PROJECT RELATED SUGGESTION vir1505 Embedded Systems and Microcontrollers 0 02-24-2009 06:13 AM

Thread Tools
Display Modes

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 Jump


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


User-posted content, unless source quoted, is licensed under a Creative Commons Public Domain License.
Powered by vBulletin
Copyright ©2000 - 2014, vBulletin Solutions, Inc.