[PIC] PIC12F683 Pulse Counter

Status
Not open for further replies.

OsirisB

Newbie level 2
Joined
Nov 27, 2013
Messages
2
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Visit site
Activity points
22
Hi Guys,
I have just joined this forum and am in need of some help.
>>I am building a project using the PIC12F683 to read in a 10V pulse *refer attachment for pulse
>> The program needs to read the number of pulses for a second, then multiply that by 60 to get rpm.
>>If then checks the condition of a variable (Temp).
>> If Temp=0 and rpm>300, then the pic will set a pin output to ground for a second.
>>Another condition (seperate from the previous) also monitors another pin to check if it has been set to ground, and then sets Temp=0.
>> The pic needs to reset everytime power is switched off and on.
>> Please note that pins GP1 and GP0 running condition is not HIGH or LOW, but no connection.
>> I have attached my code *please be gentle :-D


Code C - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
/*
  PIC12f683
  Clock set to 4Mhz
*/
 
unsigned int temp, PulseCount,rpm;
 
 
 
void main() {
CMCON0 = 7;    // Disable comparators
         //  543210
TRISIO = 0b00100010;  // GP1 --> Recieves GND Input from tact switch, GP5 --> 10V Pulse input for counting
                      // GP0 --> Pin set to GND when conditions are met
ANSEL = 0x00; // No analog inputs
GPIO=0;
PIE1 = 0b00000001 ;  // Enable TMR1IE
 
 
 
 temp=0;
 Pulsecount=0;
 rpm=0;
do {
  TMR1H = 0x00;
  TMR1L = 0x00;
  T1CON = 0b00000111;   // Enable Timer 1
  Delay_ms(1000);
  T1CON = 0b00000110;   // Disable Timer 1
  PulseCount = TMR1H;
  rpm= Pulsecount*60; //converts revolutions per second to revolutions per minute
       IF((rpm > 300) && (temp = 0)) {
            GPIO.GP0=0; //set the GP0 output from no connection to GND
            Temp=1;} //tracks the condition of pin GP0
            IF (GPIO.GP1=0) {//Checks if GP1 recieved GND input from no connection
              Temp=0;}
              
 
 } while(1);
 }

 

Attachments

  • 10V Output Pulse.jpg
    57.1 KB · Views: 96
  • circuit.jpg
    24.2 KB · Views: 94
Last edited by a moderator:

Thank you Jayanth...
I will insert a voltage divider in the circuit
 

Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…