PDA

View Full Version : RPM counter



RUBiksCUbe
- 23rd November 2005, 20:11
Im working on an RPM counter for a motor that I need for a project but in order to actually count RPMs I need to get the program to run for a minute. Is there some command that will stop the PIC after a minute has passed?

milestag
- 23rd November 2005, 20:54
How about:

//Set up one of the PIC's hardware Timer/Counters as a Counter

//Pause 60000

//Read the value of the counter


What sort of RPM value do you expect? If it's fast, why not count for 15 seconds and multiply by 4, or count for 1 second and multiply by 60?

RUBiksCUbe
- 23rd November 2005, 21:11
Its a PC cooling fan so I was expecting it to be sort of high. How do I set up one of the hardware timers as a counter? I've never done anything with them before.

milestag
- 24th November 2005, 01:59
1. What chip are you using?

2. Read the datasheet. It will have a section on each Timer/Counter available on your particular PIC. It tells you exactly what values to write to each register to set up the timer as a counter and how to read/write the current value of the counter. You will also be able to set up one of the I/O pins as a trigger for the counter and select rising/falling edge for triggering. Read up on the prescaler, you may need to set that up too.

RUBiksCUbe
- 24th November 2005, 04:09
Im using an 18F252. Im looking through the datasheet and I found that Timer0 uses the T0CON register and on the pin diagram it says that T0CKI is pin 6 (PortA.4). How to the timers work? I've never done anything with them before and I'm not even sure what they do.

G8RPI
- 24th November 2005, 12:08
Hi see my eariler post,

http://www.picbasic.co.uk/forum/showpost.php?p=10458&postcount=6

for some example code.

Luciano
- 24th November 2005, 13:03
Hi,

A simple way to read fan RPM:

A 3-wire fan has a tach output, which usually outputs 1, 2, or 4 tach
pulses per revolution, depending on the fan model.

With the PicBasic "COUNT" you can count the pulses on the
tach output and with simple math calculate the fan speed.


Luciano

Charles Linquis
- 24th November 2005, 16:57
Additional information:

Fan tachs are open-collector. You have to pull them up to 5V or you won't see any signal. I recommend values from 4.7K - 10K.
Also, fans produce 2 pulses/revolution which means that a 3600 RPM fan will have a 120Hz signal on the tach line.
Don't plan on the duty cycle being exactly 50%.

RUBiksCUbe
- 24th November 2005, 17:08
Im using a case fan instead of a processor fan so it dosent have a tach line. I was going to use a processor fan but it wasnt big enough for my project. I basically just need the motor inside the fan, but I need to know how fast it is running at 9v before I can use it. I was looking around and I just found the COUNT command which should work perfectally.