Searching \ for '[PIC]: Measuring a decreasing frequency.' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: www.piclist.com/techref/microchip/devices.htm?key=pic
Search entire site for: 'Measuring a decreasing frequency.'.

Exact match. Not showing close matches.
PICList Thread
'[PIC]: Measuring a decreasing frequency.'
2000\08\10@181104 by Jeff Scharpf

flavicon
face
Greetings,
I'm using a PIC16F876, and would like to measure time from a steady state frequency to 0. To clarify, I have a motor that will be running somewhere from 500 to 10000 HZ (RPM, but I will convert the RPM to HZ using a 60 slot wheel and LED pickup).
I will be stopping this motor quickly, and wish to measure the time required to stop. This total time will be somewhere around 50 milliseconds. In order to measure this, I was thinking of monitoring the frequency, then when it started to drop, set a timer, then waited for it to reach 0 or even a slow enough frequency to call it 0. This is my first project using a PIC, and I've messed around with one enough to be able to use TMR0 and basic I/0.
Does this PIC have the capability to do what I need? Are there enough TIMERS/COUNTERS to do this? Any ideas would be greatly appreciated.

Thanks,

Jeffrey Scharpf
Senior Engineering Technician
Milwaukee Electric Tool Corporation
Technical Center
Brookfield, Wisconsin, 53005
(262) 783-8681
_______________________________________________________
Are you a Techie? Get Your Free Tech Email Address Now!
Many to choose from! Visit http://www.TechEmail.com

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]: PIC only [EE]: engineering [OT]: off topic [AD]: advertisements

2000\08\11@063326 by Olin Lathrop

flavicon
face
> I'm using a PIC16F876, and would like to measure time from a steady state
frequency to 0. To clarify, I have a motor that will be running somewhere
from 500 to 10000 HZ (RPM, but I will convert the RPM to HZ using a 60 slot
wheel and LED pickup).
> I will be stopping this motor quickly, and wish to measure the time
required to stop. This total time will be somewhere around 50 milliseconds.
In order to measure this, I was thinking of monitoring the frequency, then
when it started to drop, set a timer,
> Does this PIC have the capability to do what I need? Are there enough
TIMERS/COUNTERS to do this? Any ideas would be greatly appreciated.

Yes, the 16F876 can do this because it as a CCP module.  The capture feature
is well suited to measuring the period of a pulse train.  I've done these
kind of tachometer applications a number of times using CCP modules in
capture mode.

The trickiest part is dealing with long periods that exceed the 16 bit timer
1 wrap period.  You have to sample timer 1 more often than it could possibly
wrap.  When you do this, you accumulate an additional delta since the last
pulse in a separate variable, then reset your saved timer 1 start value for
this interval.  When the capture happens, subtract the saved timer 1 start
value and add the accumulated delta.  Now you've got the period which you
can use directly or invert to get the frequency.

That's the basic strategy, but there are lots of details to work out, and
some shortcuts.  For example, you don't really need to sample both bytes of
timer 1 when just compensating for wrap arounds.  The high byte is enough,
but you have to think carefully about how your saved start time is adjusted.
Also keep in mind that if you do an unsigned subtract of a new timer value
minus an old value, you get the positive delta regardless of whether the
number wrapped in between  -  as long as there weren't more than 65535
ticks.


*****************************************************************
Olin Lathrop, embedded systems consultant in Devens Massachusetts
(978) 772-3129, spam_OUTolinTakeThisOuTspamcognivis.com, http://www.cognivis.com

--
http://www.piclist.com hint: The list server can filter out subtopics
(like ads or off topics) for you. See http://www.piclist.com/#topics

2000\08\11@111157 by Jeff Scharpf

flavicon
face
On Fri, 11 August 2000, Olin Lathrop wrote:
Olin,

Thank you very much for your response. I will look at the strategy you have shown. Would you by any chance happen to have any sample source code to start me out? I am relatively new, and any help would be appreciated.
Thank you for your response.

Jeff


{Quote hidden}

Jeffrey Scharpf
Senior Engineering Technician
Milwaukee Electric Tool Corporation
Technical Center
Brookfield, Wisconsin, 53005
(262) 783-8681
_______________________________________________________
Are you a Techie? Get Your Free Tech Email Address Now!
Many to choose from! Visit http://www.TechEmail.com

--
http://www.piclist.com hint: The list server can filter out subtopics
(like ads or off topics) for you. See http://www.piclist.com/#topics

2000\08\11@120608 by Olin Lathrop

flavicon
face
part 1 771 bytes content-type:text/plain; (decoded 7bit)

>>
Thank you very much for your response. I will look at the strategy you have
shown. Would you by any chance happen to have any sample source code to
start me out? I am relatively new, and any help would be appreciated.
<<

OK, I've attached some code, but it probably won't help as much as you
think.  I use a lot of macros for subroutine linkage, bank switching, and
the like which of course you won't find in the assembler documentation.
Also, every tachometer implementation I've done has its own unique custom
issues.  The one I included the code snippet for is trying to measure the
speed of a gasoline engine, but also determine whether the engine should be
assume to be off or not.

Anyway, for what it's worth...


part 2 15046 bytes content-type:application/octet-stream; (decode)

part 3 335 bytes

*****************************************************************
Olin Lathrop, embedded systems consultant in Devens Massachusetts
(978) 772-3129, olinspamKILLspamcognivis.com, http://www.cognivis.com

--
http://www.piclist.com hint: The list server can filter out subtopics
(like ads or off topics) for you. See http://www.piclist.com/#topics

More... (looser matching)
- Last day of these posts
- In 2000 , 2001 only
- Today
- New search...