PDA

View Full Version : freq counter 0-70hz pic16f877



picpower
- 9th January 2006, 16:57
hi

can anyone please help me, i'am making a speedometer for my electric bycycle, and need to messure pulses between 0-70hz and do some math to get the Km/h

i,am using pic16f877 with 16Mhz and pic basic pro.

maybe with interrupt, because i have to messure amps and volts at the same time, and at a low freq, the loop will take to long.


sorry for my bad english :-)

Acetronics2
- 9th January 2006, 17:41
Hi,PicPower

Why not use a simple F/V like LM 2907 or LM 331 and one of the PIC A/D's.

Moreover it will be easy to calibrate the speedo with a simple external pot !!!

Alain

picpower
- 9th January 2006, 17:45
hi

i dont want to make a digital signal to analog and then digital again.

and i have maked the pcb so it has to be done with the pic

Acetronics2
- 9th January 2006, 17:56
Hi, PicPw

so, The question is to know what else do yo do w/the PIC ...

If just Speed I and U and display implemented, a PicBasic interrupt ( RTFM : simple to do ... ) will be OK.

The question is also wich is your refresh rate ??? one I and U measure per second could be enough to be readable.

We do not know enough about your project to give valuable solutions ...

Alain

picpower
- 9th January 2006, 18:02
i only have to messure I and U and the speed.

it is possible to start timer0 when i receive a high pulse and stop the counter when the next high pulse is coming?

and can the pic do other things when the timer0 counts?

J. Mark Wolf
- 10th January 2006, 11:59
You can implement your speedometer easily with the PULSIN command.

You don't have to wait for a full revolution of you wheel.

Just install either magnets or reflective tape at equidistant intervals around your wheel and measure the time between any two magnets (or tape), keeping in mind that this measurement is only a fraction of a wheel revolution (and a fraction of a second). Handle the extrapolation in integer math.

I'm doing something similar with rotor tachometers and many other things on a helicopter. The software is written in a loop structure, such that all the measurements are taken and processed many times a second.

Acetronics2
- 10th January 2006, 12:31
i only have to messure I and U and the speed.

it is possible to start timer0 when i receive a high pulse and stop the counter when the next high pulse is coming?

and can the pic do other things when the timer0 counts?

Hi,PicPw

You can use the CCP in capture Mode ...

You could also use Timer 1 as a free running timer and read it periodically ...see Microchip datasheet Timer section for details.

There are many many ways to do it ...

Alain

Darrenmac
- 11th January 2006, 08:39
I too would like to get some pointers for a similar project. I want to decode CTCSS tones using a pic. These are pre defined tones lying between 50 and 300Hz. How would I go about having a lookup table of tones and comparing the incomming tone with one in the lookup table? this would have to be done very quickly, 100ms or better

arniepj
- 13th January 2006, 01:50
Attached is a program for counting pulses using Tmr1 set in the counter mode and Tmr0 set as an interrupt timer.The interrupt timer counts ticks,after 1 second Tmr1's accumulated count is serial outputed.

Acetronics2
- 13th January 2006, 09:14
good !!!

Alain