View previous topic :: View next topic |
Author |
Message |
khwoo
Joined: 26 May 2009 Posts: 12
|
Display RPM from an IR sensor to LCD |
Posted: Sun Jun 07, 2009 3:45 am |
|
|
Hi all!
Can anyone help me in programming to display rpm in LCD from an IR sensor? I am using PIC16f877a.
Thanks. |
|
|
bungee-
Joined: 27 Jun 2007 Posts: 206
|
|
Posted: Sun Jun 07, 2009 4:35 am |
|
|
1. Put your questions in other part of forum.
2. We can, but you have to do your part of work too, and when in doubt post the question here...
So to help you on theoretical approach:
To measure an RPM you need to count time between pulses. That could be done with an ISR on input pin. Driving LCD is trivial.... |
|
|
khwoo
Joined: 26 May 2009 Posts: 12
|
where and what to program? |
Posted: Sun Jun 07, 2009 4:40 am |
|
|
Code: | #include <16F877A.H>
#fuses HS,NOWDT,NOPROTECT,NOLVP
#use delay(clock=20000000)
#include <lcd.c>
void main(){
lcd_init();
lcd_putc("\fMr Brian is\n");
lcd_putc("very HANDSOME^^");
} |
What and where to program for displaying rpm? How to put the formula of rpm in C? |
|
|
khwoo
Joined: 26 May 2009 Posts: 12
|
|
Posted: Sun Jun 07, 2009 4:42 am |
|
|
bungee- wrote: | 1. Put your questions in other part of forum.
2. We can, but you have to do your part of work too, and when in doubt post the question here...
So to help you on theoretical approach:
To measure an RPM you need to count time between pulses. That could be done with an ISR on input pin. Driving LCD is trivial.... |
erm.. thanks for your reply. May I know what is ISR?
thanks. |
|
|
mkuang
Joined: 14 Dec 2007 Posts: 257
|
|
Posted: Mon Jun 08, 2009 8:56 am |
|
|
khwoo wrote: | bungee- wrote: | 1. Put your questions in other part of forum.
2. We can, but you have to do your part of work too, and when in doubt post the question here...
So to help you on theoretical approach:
To measure an RPM you need to count time between pulses. That could be done with an ISR on input pin. Driving LCD is trivial.... |
erm.. thanks for your reply. May I know what is ISR?
thanks. |
ISR = Interrupt Service Routine.
To measure RPM you would likely use the Capture Compare Module (not sure whether your PIC has that function built in) to count the period/frequency of the incoming pulse and calibrate that to actual PPM.
In your examples folder there should be a file called EX_CCPMP.C showing you how to do it. |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
|
khwoo
Joined: 26 May 2009 Posts: 12
|
|
Posted: Mon Jun 08, 2009 7:59 pm |
|
|
mkuang wrote: | khwoo wrote: | bungee- wrote: | 1. Put your questions in other part of forum.
2. We can, but you have to do your part of work too, and when in doubt post the question here...
So to help you on theoretical approach:
To measure an RPM you need to count time between pulses. That could be done with an ISR on input pin. Driving LCD is trivial.... |
erm.. thanks for your reply. May I know what is ISR?
thanks. |
ISR = Interrupt Service Routine.
To measure RPM you would likely use the Capture Compare Module (not sure whether your PIC has that function built in) to count the period/frequency of the incoming pulse and calibrate that to actual PPM.
In your examples folder there should be a file called EX_CCPMP.C showing you how to do it. |
Okay, thanks for your idea. For the pic16f877a, I knew that timer1 can be used as a counter and is it by including the EX_CCPMP.c file, I am able to calculate rpm and display it? Do I need to type the rpm formula in the code? |
|
|
Rohit de Sa
Joined: 09 Nov 2007 Posts: 282 Location: India
|
|
Posted: Tue Jun 09, 2009 12:40 am |
|
|
Read the links given by PCM. Expanding a bit on that:
You have to use the 'Capture' part of the CCP module to measure frequency. The IR sensor should be designed in such a way that it outputs a pulse when activated.
The signal that you would get from a homebrew IR LED-IR phototransistor setup will <i>NOT</i> produce a proper pulse. You would probably need an opamp comparator or transistorized driver to do this - a 'voltage squarer' of sorts. Have a look here http://www.electro-tech-online.com/micro-controllers/28713-rpm-counter-project-started-pic16f877a.html
The Capture module can be configured to stop the timer when it detects a pulse. You can find the number of timer ticks between pulses, and obtain the time between them. This will allow you to calculate the frequency of the pulses. The Capture module has several configurable features like a built-in hardware averaging (basically a prescaler), edge triggering, etc.
Rohit |
|
|
|