CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

Display RPM from an IR sensor to LCD

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
khwoo



Joined: 26 May 2009
Posts: 12

View user's profile Send private message

Display RPM from an IR sensor to LCD
PostPosted: Sun Jun 07, 2009 3:45 am     Reply with quote

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

View user's profile Send private message

PostPosted: Sun Jun 07, 2009 4:35 am     Reply with quote

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.... Wink
khwoo



Joined: 26 May 2009
Posts: 12

View user's profile Send private message

where and what to program?
PostPosted: Sun Jun 07, 2009 4:40 am     Reply with quote

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

View user's profile Send private message

PostPosted: Sun Jun 07, 2009 4:42 am     Reply with quote

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.... Wink


erm.. thanks for your reply. May I know what is ISR?
thanks.
mkuang



Joined: 14 Dec 2007
Posts: 257

View user's profile Send private message Send e-mail

PostPosted: Mon Jun 08, 2009 8:56 am     Reply with quote

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.... Wink


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

View user's profile Send private message

PostPosted: Mon Jun 08, 2009 12:44 pm     Reply with quote

Here are some threads (2 or 3 pages each) that discuss using the CCP
to measure the frequency of a signal.
http://www.ccsinfo.com/forum/viewtopic.php?t=29963
http://www.ccsinfo.com/forum/viewtopic.php?t=36852
You need to be at least an intermediate-level C programmer to
understand all of this.
khwoo



Joined: 26 May 2009
Posts: 12

View user's profile Send private message

PostPosted: Mon Jun 08, 2009 7:59 pm     Reply with quote

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.... Wink


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? Idea
Rohit de Sa



Joined: 09 Nov 2007
Posts: 282
Location: India

View user's profile Send private message Visit poster's website

PostPosted: Tue Jun 09, 2009 12:40 am     Reply with quote

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
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group