View previous topic :: View next topic |
Author |
Message |
Bob Schellenberg Guest
|
measuring motor RPM. |
Posted: Tue Jul 01, 2003 3:33 am |
|
|
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 |
|
![](templates/subSilver/images/spacer.gif) |
jal Guest
|
Re: measuring motor RPM. |
Posted: Tue Jul 01, 2003 10:40 am |
|
|
:=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 |
|
![](templates/subSilver/images/spacer.gif) |
Neutone
Joined: 08 Sep 2003 Posts: 839 Location: Houston
|
Debouncing an input |
Posted: Tue Jul 01, 2003 11:07 am |
|
|
:=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 |
|
![](templates/subSilver/images/spacer.gif) |
Luke Guest
|
Re: measuring motor RPM. |
Posted: Tue Jul 01, 2003 1:20 pm |
|
|
:=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 |
|
![](templates/subSilver/images/spacer.gif) |
|