piclist 2001\01\22\090528a >
www.piclist.com/techref/microchip/devices.htm?key=16F
BY : Olin Lathrop email (remove spam text)

Strange, I never saw this post directly, only in Roman's response to it.

> I have a project I need to do for my main hobby interest Model
> I would like to build a speedometer for a section of track at the club.
> I have detetcors already installed that light an LED when a train passes
it.
> I figure I can space 2 of these a specified distance apart and use the
> outputs of the detectors to tell the PIC to start counting and stop
counting.
> Then let it do the math and display it on 2 Seven segment LED's.
> I have the chip/programer and enough hardware to power the chip. I also
have
> the LED's.
> This is where I fall on my face. I have looked for a couple of days now
for
> code to drive the LED's and a schematic on how to hook them up.
> I know this is asking alot since I am only a beginner here but you got to
> start somewhere!

This sounds like a great beginner project.

To measure the speed, you measure the time between the pulses and invert to
get the speed.  Of course there is a constant in there to convert to
furlongs/fortnight, rods/minute, or whatever speed units you want.  There
are lots of ways to measure time between pulses.  If you use a 16F876 (nice
chip to learn on), you could reset timer 1 on the first pulse and read the
value on the second.  There are more sophisticated ways, but for your
problem and expected time interval (50 to 500 mS?) that should be fine.

The conversion from time to speed will require a divide.  There are lots of
fixed point divide routines around.  Check the PIClist archives and the
Microchip app notes.

Driving the 7 segment displays will require a table.  Since you only want to
display 10 different digits, put the output bit pattern that produces each
digit as one entry of a table.

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

--