Hi guys,
I was hoping someone could be of assistance.
>>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
/*
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);
}
I was hoping someone could be of assistance.
>>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
/*
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
-
57.1 KB Views: 43
-
24.2 KB Views: 35