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

Car RPM using 877A

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








Car RPM using 877A
PostPosted: Sat Mar 22, 2008 9:59 am     Reply with quote

Hi.

I'm trying to make my own RPM for my car using PIC16F877A and timer1 with external osc. but isn't working. What am i doing wrong?
PS: i didn't tested on my car, just on PIC Simulator...the timer1 is not incrementing.

Code:

#include <16F877A.h>
#device ADC=16
#fuses HS,NOWDT,NOPROTECT,NOLVP
#use delay(clock=4000000)
#use rs232(baud=9600, bits=8, parity = N, xmit=PIN_C6, rcv=PIN_C7)
#include <stdlib.h>

void main() {
   long freqc_low;


   
   enable_interrupts(GLOBAL);
   enable_interrupts(INT_TIMER1);


   while (TRUE) {
 
      set_timer1(0);
      setup_timer_1(T1_EXTERNAL | T1_DIV_BY_2);
      /* Espera 1 segundo já que mais a frente multiplicamos por 60 */
      delay_ms( 10 );
      freqc_low=get_timer1();                 //get timer1 value as the least sign. 16bits of freq counter
      printf("Timer1: %LU\r\n",freqc_low);
      freqc_low=((freqc_low * 2)*60);
      printf("%LU Rpm\r\n",freqc_low);   //and print frequency


   }
}
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sat Mar 22, 2008 11:28 am     Reply with quote

Quote:
enable_interrupts(GLOBAL);
enable_interrupts(INT_TIMER1);

Your program does not have an interrupt service routine for Timer1.
If you enable interrupts without an interrupt service routine, the program
will crash when an interrupt occurs.

If you don't want to use interrupts, then delete those two lines.
Guest








PostPosted: Sat Mar 22, 2008 11:42 am     Reply with quote

Still not working.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sat Mar 22, 2008 11:55 am     Reply with quote

You're running this on some unspecified simulator. The simulator
probably doesn't have an external clock applied to the Timer1 input.
Or, the input frequency is too high for the 10 ms delay period.
I can't make your simulator work.
baltazar_aquino



Joined: 16 Mar 2008
Posts: 27

View user's profile Send private message

PostPosted: Sun Mar 23, 2008 11:36 am     Reply with quote

RPM measurement job is trivial for PIC. test it with real pulses not on simulator. By the way, what sensor/probe you are going to use?
Guest








PostPosted: Sun Mar 23, 2008 9:23 pm     Reply with quote

I'll use coil signal from ECU. I'm newbie with PIC programming, i know PC programming (Delphi, PHP, C++).

Is there any other easy way to measure RPM?
I got this code from net and not i'm understanding. When coil pulse is generated (0-1 or 1-0, depending of my PIC configuaration), timer1 ins inecrementend. After some time (i'm using 1 second) i get the pulse count and make some calculations.

But my problem is: my PIC is used for some others tasks and i can't wait 1 second on main routine to calculate RPM. Also, if i use less time (about 50ms) i think is not enough, since car low RPM's is really LOW.
umka



Joined: 28 Aug 2007
Posts: 99
Location: New Zealand

View user's profile Send private message

PostPosted: Sun Mar 23, 2008 9:36 pm     Reply with quote

no it counts the number of clock increments between pulses from the ecu.

this gives you the time between ecu pulses and therefore time taken to do one revolution.
Will_Esan



Joined: 17 Mar 2008
Posts: 7
Location: Norcross, GA

View user's profile Send private message

PostPosted: Mon Mar 24, 2008 2:13 am     Reply with quote

Quote:
I'll use coil signal from ECU. I'm newbie with PIC programming, i know PC programming (Delphi, PHP, C++).


Your programming experience counts to nothing until you have basic electronics knowledge.

Quote:
s there any other easy way to measure RPM?


Yes there are,
1. Buy one from store
2. Learn some electronics and use free hex files users have posted on web.

3. If you really want to build your own, then learn some electronics

There r lot of examples on web you even cant count, I made my own RPM meter back in school, very basic. If you are looking for readymade solution, the answer is keep looking.

In forums generally people get a guide line how to get through from problem they are facing from other forum members not the Solution.
If you need the guide line then you must be very specific about your problem. READ CCS MANUAL you will get answer about timer1 interrupt.
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