Greetings - I've have a design up and working in a similar manner. What I do is I have to monitor the state of a fanpack that has 6 individual fans w/ hall sense signals (1 for each). I connect these to a port, and set up an internal TIMER2 interrupt on 5ms intervals. When this interrupt occurs (every 5ms) I poll the hall sense port. I then XOR it with the previously read value. I keep count of how many times each signal changes state, and then after about 1 second I compare the counts to a fixed reference. (This is how I set the detection threshold). The 1 sec is arbitrary, but must be longer than a reasonable amount of samples. Your approach seems quite reasonable too! I use an external buffer inbetween the PCI16C63 and the fans on the port pins that didn't have an internal scmitt trigger. I used the external schmitt triggered pins when possible. They work quite well. Good luck. > -----Original Message----- > From: Dr. Leonardo De Palo [SMTP:leo.depalo@TELESYS.IT] > Sent: Friday, April 03, 1998 6:51 AM > To: PICLIST@MITVMA.MIT.EDU > Subject: PULSE MEASURING for RPM > > Dear Tony > > many thanks for your suggestion and the schematics. > > I have to clarify why you use the BC337, if we use RB0 for input, this > input > is Smith triggered and i think is not needed other active components. > > At the momentI will work only on monocylindrical two time engine. > > Then I have just build a prototype using a quartz of 4MHz and the > visible > output is obtainet using the RB1 to RB7 and RA0 to RA3 to drive > directly ten > LED, one for each 1000 RPM. This LED bar, seems semianalogical and > should > pleasure to see (and obiously more grossolane). But the real intent of > this > RPM is to manage a special valvle used by APRILIA to open/close the > escape > collector at certain RPM fixed and decided by the engineer of the > APRILIA. > With this project we would like to change the open/close valvle at > different > RPM using different laws. > > With this actual state the new timing should be revisited to obtain > the 100 > uS time from: > > 4 Mhz clock means 1 Mhz internal clock > cycle time = 1 MHz = 1.000 nS > Setting the tree bit of prescaler to zero we obtain a division by four > = > 250 uS > > and presetting TMR0 to abour 100 at FF/0 cross a should obtain 100 uS. > > My idea is to manage the event of FF/0 crossing using the interrupt, > and > also > use the interrupt to count the loop. > > When the program counter pass to 04H, testing the bit of INTCON reg. > The > routine will understand which of the two event i need to manage , loop > count > or FF/0 overflow. > > The main loop make the job of the calculation an switch on the LED. > > Do you agree with my poin of wiew? > > > > Many thank for your time. > > > Best Regards. > > > -----Messaggio originale----- > Da: TONY NIXON 54964 > A: PICLIST@MITVMA.MIT.EDU > Data: venerdl 3 aprile 1998 3.18 > Oggetto: Re: R: Re: PULSE MEASURING > > > >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 > >byte counter. > > > >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 > >engine. > > > >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 > >this RPM:-) > > > >You may also need to average the RPM readings or just display '0' on > >the units and/or tens digit to avoid jitter. > > > >IRQ Loop > > > >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 > > > > > >Main Loop > > > >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 > > > >Regards > > > >Tony > > > > > > > >PicNPoke Multimedia 16F84 Beginners PIC Tools. > > > >**PLUS** - PicNPlay - PicNPlan - PicNPrep - PicNPost > >PicNPort - DT Type Saver - *new* PicNQuiz. > >Recent addition - DogBoneZ Component. > > > >http://www.dontronics.com/picnpoke.html > << File: coil (3).gif >>