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 support@ccsinfo.com

measuring motor RPM.

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







measuring motor RPM.
PostPosted: Tue Jul 01, 2003 3:33 am     Reply with quote

I am trying to use a motor that has a reed switch to indicate motor speed. I'm using a 16F877 with the INT_EXT on a H_TO_L edge trigger (the switch pulls it low) to count the pulses but the count is not consistent. I've set the port_b_pullups(TRUE), and output_float(PIN_B0). I'm suspect that the switch is bouncing. I would like have the counting done in the background (INT_EXT) without eating up clock cycles in a delay_x call. I would appreciate any suggestions.

Bob
___________________________
This message was ported from CCS's old forum
Original Post ID: 144515678
jal
Guest







Re: measuring motor RPM.
PostPosted: Tue Jul 01, 2003 10:40 am     Reply with quote

:=I am trying to use a motor that has a reed switch to indicate motor speed. I'm using a 16F877 with the INT_EXT on a H_TO_L edge trigger (the switch pulls it low) to count the pulses but the count is not consistent. I've set the port_b_pullups(TRUE), and output_float(PIN_B0). I'm suspect that the switch is bouncing. I would like have the counting done in the background (INT_EXT) without eating up clock cycles in a delay_x call. I would appreciate any suggestions.
:=
:=Bob

Hi Bob,

You can try a couple of things but in order to get good results I think you may need to look at a debounce circuit and/or possibly switching to an optical sensor rather than a mechanical switch. There are some pretty cheap optical sensors (either reflective or transmission), that would not have this type of bounce problem.

Once you get a decent signal from your sensor, you can compute motor RPM either by measuring the time between two pulses or by accumulating over a fixed time period. If the motor rpm is high then you can just connect the RPM sensor to one of the PIC inputs that can function as a clock pin for one of the onchip hardware counters. Wait for a second and read RPM!

If you need to determine the RPM very quickly, measuring the time between pulses is the best method and you can either use the external interrupt or use the capture mode of one of the CCP modules.

Good luck,
Jim

___________________________
This message was ported from CCS's old forum
Original Post ID: 144515687
Neutone



Joined: 08 Sep 2003
Posts: 839
Location: Houston

View user's profile Send private message

Debouncing an input
PostPosted: Tue Jul 01, 2003 11:07 am     Reply with quote

:=I am trying to use a motor that has a reed switch to indicate motor speed. I'm using a 16F877 with the INT_EXT on a H_TO_L edge trigger (the switch pulls it low) to count the pulses but the count is not consistent. I've set the port_b_pullups(TRUE), and output_float(PIN_B0). I'm suspect that the switch is bouncing. I would like have the counting done in the background (INT_EXT) without eating up clock cycles in a delay_x call. I would appreciate any suggestions.
:=
:=Bob

A different spin on the problem. I don't like to waist time in a delay loop either. The following code is written to be part of a process loop. Total time and code size is very small. When an input changes it takes 30 passes through the loop to accept the change. This is adjustable to meet the application needs. Noise rejection is very good.

if ( input(PIN_C0)
{ if ( ++debounce_counter_Sleeping > 15
{ Sleeping = 1
debounce_counter_Sleeping = 15;
}
}
else
{ if ( --debounce_counter_Sleeping < -15
{ Sleeping = 0
debounce_counter_Sleeping = -15;
}
}
___________________________
This message was ported from CCS's old forum
Original Post ID: 144515688
Luke
Guest







Re: measuring motor RPM.
PostPosted: Tue Jul 01, 2003 1:20 pm     Reply with quote

:=I am trying to use a motor that has a reed switch to indicate motor speed. I'm using a 16F877 with the INT_EXT on a H_TO_L edge trigger (the switch pulls it low) to count the pulses but the count is not consistent. I've set the port_b_pullups(TRUE), and output_float(PIN_B0). I'm suspect that the switch is bouncing. I would like have the counting done in the background (INT_EXT) without eating up clock cycles in a delay_x call. I would appreciate any suggestions.
:=
:=Bob

I got a similar problem with a mechanical relay. First of all I determined the period of the bouncing with an oscilloscope. After that I designed a RC low-pass filter and I put it between the relay and the PIC input. If you can not estimate the bouncing period you can design your filter so that the maximum relay switching frequency is not cut-off by the filter. Good luck.
___________________________
This message was ported from CCS's old forum
Original Post ID: 144515691
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