Maker Pro
Maker Pro

Measuring frequency with a 8-bit MCU

M

Mike Lantz

Jan 1, 1970
0
G'Day,

I want to measure a frequency from a Magnetic Pick-up sensor with a MCU.
There are many ways to use this signal and measure the period of it. I'm
just looking for some Do's and Don'ts that people have encountered and
things to just avoid.

Here are a few ideas that I can use to interface to the MCU with:

1) Use a Frequency to Voltage converter and use the built in ADC of the MCU.
2) Use a Voltage comparator and manipulate the signal to a TTL output and
measure it's period.
3) Clip the signal to within the nominal operational value of the MCU and
count the pulse with respect to time.

Accuracy is not required, this is just to give a general idea of the RPM.
The MCU will also be doing other things like controlling a LCD (Display RPM,
menu system), outputs (relays) and monitoring inputs (Keypad, open collector
sensors).

The MCU in use is the Motorola MC9S08GB60
 
J

Jan Homuth

Jan 1, 1970
0
Mike,
just an idea:

use a Schmitt Trigger, an OP amp and some resistors and capacitors to build:

a) Amplifier to condition the signal to 0..5V
b) low pass stage (R/C)
c) Schmitt Trigger input to get a reliable edge
(like the 7414 )
Then capture time between the rising edges.
(i.e external interrupt starts timer)

Assuming a combustion engine or electrical motor:
The motor usually runs anywhere between 0 and 12000 RPM = 200 rev/sec.
With the resulting 5 ms per rev at 12000 RPM the CPU has enough time to
reset the timer each time the interrupt occurs even at high RPM.

regards
/jan
 
G

Glenn Hamblin

Jan 1, 1970
0
What I've done in the past is use series resistor from the signal to
a counter input on the MCU. The protection diodes in the MCU will clip
the signal at the rails(+/-~.6V). Then create (or use an existing) periodic
interrupt to read and clear the counter. from there it's easy to calc
the frequncy.
 
S

Spehro Pefhany

Jan 1, 1970
0
What I've done in the past is use series resistor from the signal to
a counter input on the MCU. The protection diodes in the MCU will clip
the signal at the rails(+/-~.6V). Then create (or use an existing) periodic
interrupt to read and clear the counter. from there it's easy to calc
the frequncy.

Using the protection diodes in this way is not really to be
recommended- it can cause various problems, especially if the chip has
and uses an ADC.

Best regards,
Spehro Pefhany
 
G

Glenn Hamblin

Jan 1, 1970
0
Using the protection diodes in this way is not really to be
recommended- it can cause various problems, especially if the chip has
and uses an ADC.

Best regards,
Spehro Pefhany

I have been using this method sucsessfully for a long time and have not
noticed a problem. I imagine that if you allow a significant amount of
current into the rails and they are not properly bypassed or the PCB
is layed out poorly you would see problems. I have done this in systems
where the MCU is using 8,10, and 12 Bit ADC's with no problems and
thousands of units shipped.

Best regards,
Glenn
 
S

Spehro Pefhany

Jan 1, 1970
0
I have been using this method sucsessfully for a long time and have not
noticed a problem. I imagine that if you allow a significant amount of
current into the rails and they are not properly bypassed or the PCB
is layed out poorly you would see problems. I have done this in systems
where the MCU is using 8,10, and 12 Bit ADC's with no problems and
thousands of units shipped.

No, it's not that- some designs allow some of the current through the
protection diodes to spill into (especially) adjacent port pins which
can cause small offset voltages if you've got an ADC and significant
source impedance. You're also tickling the big parasitic SCR that
lives in all CMOS circuits (well, except SOI types, which I don't
think applies to any current commercial microcontrollers). This can
increase current consumption (possibly important in battery-powered
applications)... and all this while staying well within the data
sheet limits on current into/out of the input pins.

Best regards,
Spehro Pefhany
 
G

Glenn Hamblin

Jan 1, 1970
0
No, it's not that- some designs allow some of the current through the
protection diodes to spill into (especially) adjacent port pins which
can cause small offset voltages if you've got an ADC and significant
source impedance. You're also tickling the big parasitic SCR that
lives in all CMOS circuits (well, except SOI types, which I don't
think applies to any current commercial microcontrollers). This can
increase current consumption (possibly important in battery-powered
applications)... and all this while staying well within the data
sheet limits on current into/out of the input pins.

Best regards,
Spehro Pefhany

Point taken. And while it may not be an optimal method for some designs,
It is
well suited for many others. Especially when cost and space considerations
are
premium. BTW the range of input current I'm speaking of is nowhere near
the
limits in the data sheet. We're not talking mA's but 10's to 100's of uA.
I noticed no appreciable increase in circuit current when I removed the
original signal conditioning circuit (external diodes and inverter) for
cost
reasons (In fact I saved a couple mils). And this is a battery-powered app.
As with any design all of the tradeoffs need to be considered. I was simply
offering an idea based on my experience. I do appreciate your input as I'm
sure the thread originator does.

Best regards,
Glenn
 
Top