Posted by jeffguilfoil January 23, 2003
What your suggesting would certainly seem to work. I'm a real newbie
with this stuff, so the reason I selected the method I'm using is
because I knew it to exist. :) I definately appreciate the concern.

I picked my current method because I want to be able to measure the
RPM ASAP. As a result of the RPM I'm going to alter the A/F ratio by
modifying the air flow meter signal. I'm not certain where the
tolerance levels lie, so rather than tempt fate I'm hoping to make
the operation as fast as possible.

I'll take a read of your link and see what I find. I didn't find diy-
efi that usefull before, maybe I missed something.

Thanks,
Jeff --- In , Andrei Chichak <acpmiedm@t...> wrote:
> I'm just wondering why you would do this type of timing rather than
doing
> an RPM count and calculate the times?
>
> If you are trying to determine the positions to synchronize
injection or
> ignition pulses, I'm not sure you are on the right track at all.
There are
> quite a few web sites around dealing with injection/ignition that
you might
> want to look at. Start at www.diy-efi.org. Motorola, I seem to
remember,
> has an app note on doing injection using their modular counter time
module
> (CTM) if my memory is not failing. THere has been articles
published by
> Circuit Cellar www.circuitcellar.com that have these systems well
> described, and Al Lipper has a couple of systems written up that
use 8051s.
>
> Andrei
>
> At 02:24 AM 1/18/2003 +0000, you wrote:
> >I appologize for the late reply.
> >
> >I'm measuring the time between when the pulse goes high. ie. |-|_|
> >That time changes when the RPM changed on the CAS. Also, the peak
|-
> >| and vally |_| time changes perportionally with RPM. I took an
> >Oscilloscope to a CAS to be 100% sure that occurs.
> >
> >I hope I'm not making an incredibly daft mistake, so please correct
> >me if I'm wrong. :)
> >
> >--- In , Andrei Chichak <acpmiedm@t...>
wrote:
> > > Are you sure you want to measure PWM? A crank or cam sensor will
> >have a
> > > constant pulse width, the frequency varies with engine RPM.
> > >
> > > Andrei
> >
> >
> >
> >--------------------
> >
> >
> >
> >">http://docs.yahoo.com/info/terms/


Posted by Andrei Chichak January 21, 2003
I have a couple of the EFI332 boards assembled and use '332s in my daily
job, but I have seen app notes from a couple of manufacturers on doing
injection/ignition without using the TPU. One was from Seimens and the
other was for one of Moto's smaller processors (not the HC16 w/TPU), but do
you think I can find it??? NOOOOooo..

http://www.infineon.com/cmc_upload/migrated_files/document_files/Application_Notes/ap163502.pdf

Motorola also has some app notes for the HC08 as well.

Andrei

At 10:12 PM 1/20/2003 -0500, you wrote:
>"modular counter time module (CTM)"
>
>You are probably thinking of the TPU (Time Processing Unit) present on all
>MC68332 MCUs and many other Motorola MCUs of the modular MCU family.
>
>These little jewels have specific timer functions built in that detect
>crankshaft position and calculate the firing angle for ignition and fuel
>injection timing.
>
>The '332 was designed specifically for engine management, but is also a
>wonderful little general purpose MCU with lots and lots of horsepower.
>
> Bob Smith
>
>--- Avoid computer viruses, Practice safe hex ---
>
>-- Specializing in small, cost effective
> embedded control systems -- >Robert L. (Bob) Smith
>Smith Machine Works, Inc.
>9900 Lumlay Road
>Richmond, VA 23236 804/745-1065 >
>----- Original Message -----
>From: "Andrei Chichak" <>
>To: <>
>Sent: Monday, January 20, 2003 4:53 PM
>Subject: Re: [68HC12] Re: Measuring PWM /w input capture ECT - Got it
>working! > > I'm just wondering why you would do this type of timing rather than doing
> > an RPM count and calculate the times?
> >
> > If you are trying to determine the positions to synchronize injection or
> > ignition pulses, I'm not sure you are on the right track at all. There are
> > quite a few web sites around dealing with injection/ignition that you
>might
> > want to look at. Start at www.diy-efi.org. Motorola, I seem to remember,
> > has an app note on doing injection using their modular counter time module
> > (CTM) if my memory is not failing. THere has been articles published by
> > Circuit Cellar www.circuitcellar.com that have these systems well
> > described, and Al Lipper has a couple of systems written up that use
>8051s.
> >
> > Andrei
> >
> > At 02:24 AM 1/18/2003 +0000, you wrote:
> > >I appologize for the late reply.
> > >
> > >I'm measuring the time between when the pulse goes high. ie. |-|_|
> > >That time changes when the RPM changed on the CAS. Also, the peak |-
> > >| and vally |_| time changes perportionally with RPM. I took an
> > >Oscilloscope to a CAS to be 100% sure that occurs.
> > >
> > >I hope I'm not making an incredibly daft mistake, so please correct
> > >me if I'm wrong. :)
> > >
> > >--- In , Andrei Chichak <acpmiedm@t...> wrote:
> > > > Are you sure you want to measure PWM? A crank or cam sensor will
> > >have a
> > > > constant pulse width, the frequency varies with engine RPM.
> > > >
> > > > Andrei
> > >
> > >
> > >
> > >--------------------
> > >
> > >
> > >
> > >">http://docs.yahoo.com/info/terms/
> >
> >
> >
> > --------------------
> >
> >
> >
> > ">http://docs.yahoo.com/info/terms/
> >
> >
> >
>-------------------- >
>">http://docs.yahoo.com/info/terms/




Posted by Robert Smith January 20, 2003
"modular counter time module (CTM)"

You are probably thinking of the TPU (Time Processing Unit) present on all
MC68332 MCUs and many other Motorola MCUs of the modular MCU family.

These little jewels have specific timer functions built in that detect
crankshaft position and calculate the firing angle for ignition and fuel
injection timing.

The '332 was designed specifically for engine management, but is also a
wonderful little general purpose MCU with lots and lots of horsepower.

Bob Smith

--- Avoid computer viruses, Practice safe hex ---

-- Specializing in small, cost effective
embedded control systems -- Robert L. (Bob) Smith
Smith Machine Works, Inc.
9900 Lumlay Road
Richmond, VA 23236 804/745-1065
----- Original Message -----
From: "Andrei Chichak" <>
To: <>
Sent: Monday, January 20, 2003 4:53 PM
Subject: Re: [68HC12] Re: Measuring PWM /w input capture ECT - Got it
working! > I'm just wondering why you would do this type of timing rather than doing
> an RPM count and calculate the times?
>
> If you are trying to determine the positions to synchronize injection or
> ignition pulses, I'm not sure you are on the right track at all. There are
> quite a few web sites around dealing with injection/ignition that you
might
> want to look at. Start at www.diy-efi.org. Motorola, I seem to remember,
> has an app note on doing injection using their modular counter time module
> (CTM) if my memory is not failing. THere has been articles published by
> Circuit Cellar www.circuitcellar.com that have these systems well
> described, and Al Lipper has a couple of systems written up that use
8051s.
>
> Andrei
>
> At 02:24 AM 1/18/2003 +0000, you wrote:
> >I appologize for the late reply.
> >
> >I'm measuring the time between when the pulse goes high. ie. |-|_|
> >That time changes when the RPM changed on the CAS. Also, the peak |-
> >| and vally |_| time changes perportionally with RPM. I took an
> >Oscilloscope to a CAS to be 100% sure that occurs.
> >
> >I hope I'm not making an incredibly daft mistake, so please correct
> >me if I'm wrong. :)
> >
> >--- In , Andrei Chichak <acpmiedm@t...> wrote:
> > > Are you sure you want to measure PWM? A crank or cam sensor will
> >have a
> > > constant pulse width, the frequency varies with engine RPM.
> > >
> > > Andrei
> >
> >
> >
> >--------------------
> >
> >
> >
> >">http://docs.yahoo.com/info/terms/ >
> -------------------- >
> ">http://docs.yahoo.com/info/terms/ >





Posted by Andrei Chichak January 20, 2003
I'm just wondering why you would do this type of timing rather than doing
an RPM count and calculate the times?

If you are trying to determine the positions to synchronize injection or
ignition pulses, I'm not sure you are on the right track at all. There are
quite a few web sites around dealing with injection/ignition that you might
want to look at. Start at www.diy-efi.org. Motorola, I seem to remember,
has an app note on doing injection using their modular counter time module
(CTM) if my memory is not failing. THere has been articles published by
Circuit Cellar www.circuitcellar.com that have these systems well
described, and Al Lipper has a couple of systems written up that use 8051s.

Andrei

At 02:24 AM 1/18/2003 +0000, you wrote:
>I appologize for the late reply.
>
>I'm measuring the time between when the pulse goes high. ie. |-|_|
>That time changes when the RPM changed on the CAS. Also, the peak |-
>| and vally |_| time changes perportionally with RPM. I took an
>Oscilloscope to a CAS to be 100% sure that occurs.
>
>I hope I'm not making an incredibly daft mistake, so please correct
>me if I'm wrong. :)
>
>--- In , Andrei Chichak <acpmiedm@t...> wrote:
> > Are you sure you want to measure PWM? A crank or cam sensor will
>have a
> > constant pulse width, the frequency varies with engine RPM.
> >
> > Andrei >
>-------------------- >
>">http://docs.yahoo.com/info/terms/





Posted by jeffguilfoil January 17, 2003
I appologize for the late reply.

I'm measuring the time between when the pulse goes high. ie. |-|_|
That time changes when the RPM changed on the CAS. Also, the peak |-
| and vally |_| time changes perportionally with RPM. I took an
Oscilloscope to a CAS to be 100% sure that occurs.

I hope I'm not making an incredibly daft mistake, so please correct
me if I'm wrong. :)

--- In , Andrei Chichak <acpmiedm@t...> wrote:
> Are you sure you want to measure PWM? A crank or cam sensor will
have a
> constant pulse width, the frequency varies with engine RPM.
>
> Andrei





Posted by Stephen Mac Neil January 8, 2003
I thought it would be a input capture averaging the frequency of a couple of
samples to determine the frequency of the engine at any particular time.

Stephen
-----Original Message-----
From: Andrei Chichak [mailto:]
Sent: Tuesday, January 07, 2003 6:07 PM
To:
Subject: Re: [68HC12] Re: Measuring PWM /w input capture ECT - Got it
working! Are you sure you want to measure PWM? A crank or cam sensor will have a
constant pulse width, the frequency varies with engine RPM.

Andrei

--------------------



Posted by Andrei Chichak January 7, 2003
Are you sure you want to measure PWM? A crank or cam sensor will have a
constant pulse width, the frequency varies with engine RPM.

Andrei



Posted by jeffguilfoil January 3, 2003
I'm not exactly sure why, but I got my code to work!

Sincere thanks to zeta_alpha2002, Jonathan Masters and Bob Gardner
for the help.



Posted by Jonathan Masters January 3, 2003
Jeff,

I have a calculation of duty cycle using an A4 with and ADXL202
accelerometer device. These devices have a fixed period variable duty output
relative to applied force, maybe this code will help:

/* tc3 capture state values */
#define CAP_VALID ((char) (0x00)) /* made measurement, take it */
#define CAP_INVALID ((char) (0xff)) /* making measurement, do not disturb
*/
#define CAP_NON ((char) (0x01)) /* no measurement made */
#define CAP_NOSIG ((char) (0x02)) /* no signal received */

struct Capture
{
unsigned int lead;
unsigned int period;
unsigned int high;
char result;
} Accel;

/* int_tc3() -- here each time edge capture from accelerometer (vert) occurs
*/
void int_tc3(void)
{
if ((PORTT & 0x08) != 0)
{
/*
* Input bit is high
*/
Accel.period = TC3 - Accel.lead;
Accel.result = CAP_VALID; /* valid */
/* set leading edge point to current capture */
Accel.lead = TC3;
}
else
/*
* Input bit is low...
*/
/* we know leading edge point, calculate high time. Wait for next capture
for result */
Accel.high = TC3 - Accel.lead;
Accel.result = CAP_INVALID; /* invalid */
/* reset the interrupt flag */
TFLG1=0x08;
}

Your main routine can read the value for duty using the this typical call to
the following routine:
(long)duty=dutyval(Accel.high, Accel.period, 10000)

/* dutyval -- calculates the duty cycle (high/period) scaled by places */
long dutyval(high, period, places)
int high;
int period;
int places;
{
long h;
long p;
long r;

h=(long) high * (long) places;
p=(long) period;
r=h/p;

if (r < 0L || r > (long) (100*places))
return (-1);
else
return (r);
}

The timer initialization will typically need:

CLKCTL = 0x00; /* timer MCLK=4MHz */
TIOS = 0x00; /* All input captures */
TSCR = 0x80; /* enable timer */
TCTL4 = 0xc0; /* Timer 3 input capture, both edges */
TMSK1 = 0x08; /* TC3 enabled */
TMSK2 = 0x81; /* TOI enabled, prescale div 2 */

Hope this helps,

Jonathan Masters
----- Original Message -----
From: <>
To: <>
Sent: Friday, January 03, 2003 10:17 AM
Subject: [68HC12] Re: Measuring PWM /w input capture ECT (Please help) > I don't have code working yet, that's why I posted here. :) Judging
> from the way the CAS signal looks I would guess that it's mag pickup
> or something. A pulse is created every crankshaft rotation figure
> 7000RPM ~= 117hz. I'm reluctant to do the A/D method because my
> sample periods will be pretty short and I think doing it with assured
> accuracy is pretty much the input capture method. I'll give it a try
> if/when I rule out the input capture. Input capture should work, but
> I can't get it to! I starting to feel like a real idiot. :)
>
> --- In , "Stephen Mac Neil" <macneil@d...>
> wrote:
> > Do you have any code that can do that, I would be very interested
> in getting
> > the sub routine and examining that. Is that like a mag pickup input
> to the
> > unit, this crank sensor. What would be the sampling rate of the a/d
> what is
> > the frequency ranges of the input signal? I am working on something
> similar
> > but don't know if its the same or not.
> >
> > Stephen Mac Neil
> > -----Original Message-----
> > From: jeffguilfoil <jeffguilfoil@y...>
> > [mailto:jeffguilfoil@y...]
> > Sent: Tuesday, December 31, 2002 7:12 PM
> > To:
> > Subject: [68HC12] Re: Measuring PWM /w input capture ECT (Please
> help)
> >
> >
> > --- In , BobGardner@a... wrote:
> > > Hi Jeff. Why not just run the pwm into an rc lo pass filter, and
> > run that
> > > into an a/d input? The a/d reads the avg voltage of the pwn
> > waveform from the
> > > cap. This is exactly what you want, right?
> > >
> >
> > Thanks for the reply.
> >
> > Yes, I suppose the results using your technique are what I'm
> looking
> > for. I will be using a signal from a automobile crank angle
> sensor,
> > so the length of the highs changes perportionally with the length
> of
> > the lows. Do you see any problems with your suggested approach?
> The
> > only issue I see is what if the start of the sample doesn't land
> on
> > the same part of the pulse wave and the sample time is rather
> short
> > the value might quiet different. Thoughts?
> >
> > Jeff
> >
> >
> >
> >
> >
> >
> >
> > --------------------
> >
> >
> >
> > ">http://docs.yahoo.com/info/terms/





Posted by zeta_alpha2002 January 2, 2003
> ORG RAM_START

Wait a minute...Are your testing the codes in RAM? The settings I
wrote are using interrupts, so if your testing it in RAM how is IC3
interrupt being vectored?

I was just curious why you were having no luck so I wrote quickie
code to see why not and burn it into flash. Cannot seem to duplicate
your problem. I could only see an overflow if the frequency is less
than 245/22Hz because the counts I was getting was 32640. If you
double 32640 then it would be 65280 which is close to $FFFF. I used
an Adapt9S12DP256 with 16Mhz crystal. Pll not enabled.

Email me at and I will give you the routine
I used. You will have to burn it into flash though. The results is
dump out of SCI0 at 9600,8,N,1. Open a terminal window and press R
for the program to start dumping the result.

Are you perchance using D-BUG to test your code? If you are then
change the value at address $3E68 to the value of the IC3 interrupt
address routine.