'R: Re: PULSE MEASURING'
Dr. Leonardo De Palo
I am novice in this list.
I have beginned to study and try to use a PIC 16C84 four weeks ago.
As a case study i would build a RPM LED indicator for a two time engine for
the moto (Aprilia).
The problem is similar as your 1 -2 millisecond measuring.
The engine i wont monitor , if running at 8.000 RPM have a period of 7.5
My approach is to use a 4Mhz quartz as main oscillator, then setting the
prescaler to divide by 256, and chekinh the FF-zero overflow you can reach
it every 0.032 millisecond.
Setting on RB0 the measuring signal, and set up the interrupt at level
change, you can count how many overflow there are between the interrupts.
Leonardo De Palo telesys.itleo.depalo
Da: ken <WELWYN.DEMON.CO.UK> ken
A: MITVMA.MIT.EDU < PICLISTMITVMA.MIT.EDU> PICLIST
Data: giovedl 2 aprile 1998 21.34
Oggetto: Re: PULSE MEASURING
>In article <dup4-wvb.iafrica.com.na>, Alastair 01BC3E08.F3687160
><IAFRICA.COM.NA> writes bizzyb
>>It looks as if the list is always divided into three types of users: those
>>do know, those who don't and those who don't care!
>>Anyway as one who doesn't know I'd like any help you've got to give,
>>I need to measure the width of a pulse which occurs at about 30Hz with a
>>16c(f)84, the pulse width is variable between 1ms and 2ms and I need as
>>resolution as possible(about 7bit should do) on the 1ms difference between
TONY NIXON 54964
|Leonardo, try this for your RPM counter. It should be accurate enough
for your purposes.
Use a PIC running at 8MHz and set up an Interrupt, it for a duration of 100uS.
A 16F84 - 10P will be ok for this project with some external drivers for
a multiplexed display. Use the circuit I sent you to let the PIC detect the
ignition pulses from the coil.
100uS loop time
8MHz clock = 2MHz
cycle time = 1/2MHz = 500nS
100uS/500nS = 200
prescaler set to divide by 4
preset tmr0 = 206
when = 0 = 100uS
Increment a COUNTER on each 100uS loop. This will need to be a two
Each time the points open (or close) save the count data in RAM. Then
reset the counter.
A loop outside the interrupt can be set, to say 0.5 seconds, to get the
RPM data for the display. Use this formula to calculate the current RPM.
124F80h divided by (Cylinders X Loops)
A 16 bit multiply routine for Cyls X Loops, and a 24 bit routine to
divide 124F80h by the result works well.
You will have to change the binary result into BCD then to a 7 segment
format to drive the multiplexed LED displays. Store the result into 4
RAM registers for the display update routines to use.
Using multiplexed displays will require a third timing loop to
control. All this is going to be tricky for a beginner.
When the RPM value gets too low, the Loop counter may overflow. You
will have to decide on a maximum value to allow this counter to get to
and then stop it incrementing. At 30 RPM for a single cylinder engine
the count will be 40,000 (9C40h).
Debounce the points input for 8 loops. This works well for an average
Take care with the power supply for your cct. The automotive
environment is not too friendly. Don't use the PIC with copper cored
spark plug leads or you will have problems. Use suppressed ones.
The above should read reasonably well to around 7500 RPM for a V8
which is not too bad. My old Henry the 8 will have a heart attack at
You may also need to average the RPM readings or just display '0' on
the units and/or tens digit to avoid jitter.
Ignore points change when debounce counter active.
Update 100uS Loop counter.
Update main loop counter
Update counters for display refresh.
Refresh display from display RAM when ready
Update Debounce counter
Wait until IRQ has set a timing value to update the RPM display
Calculate and convert RPM data for display data
Update display RAM
Hope this helps
PicNPoke Multimedia 16F84 Beginners PIC Tools.
**PLUS** - PicNPlay - PicNPlan - PicNPrep - PicNPost
PicNPort - DT Type Saver - *new* PicNQuiz.
Recent addition - DogBoneZ Component.
More... (looser matching)
- Last day of these posts
- In 1998
, 1999 only
- New search...