To get the signals into the PIC just tap into the wire between your detector and the +V side of each LED. Take this Lo-->Hi signal through 10K (quarter watt) resistors to inputs on the PIC To show the speed value you need 9 outputs - 7 connected through 220R resistors to each segment of the displays (wire the displays in parallel except for the 'common' connections). Use 2 other outputs through 1K resistors into the bases of 2 transistors which connect the common connections of the displays to 0V (1 to each). If multiple displays are required you need buffer chips and extra transistors to drive each pair of 7 seg displays. You should then look at using BCD to 7 seg drivers which connect directly to the PIC via just 3 outputs instead of 7 (but the code gets a bit more complicated for a beginner). Use portA pins 0-1 for the detector inputs (through 10K) Use portA pins 2-3 for the display transistors (through 1K) (portA pin 4 unused) Use portB pins 1-7 for the displays (through 220R) (portB pin 0 unused) - maybe use to change units? start: Your software waits for detector 1 to go Hi. Pause for about 5ms and check that it is still Hi If no then goto start, if yes then goto gettime gettime: It then turns off both displays and starts counting. endtime: count When the second detector goes Hi pause for about 5ms and check that it is still Hi If no then goto endtime, if yes then goto calctime calctime: counting and calculate the speed to display. Then break the number into tens and units. Look up the patterns for the 2 numbers and store them in 'shadow' registers showtime: After 'a short period' load the units pattern from its shadow to portB Switch the tens display off and the units display on. Your software checks for detector 1 to go Hi. Pause for about 5ms and check that it is still Hi If no then goto showtime2, if yes then goto gettime showtime2: After 'a short period' load the tens pattern from its shadow to portB Switch the units display off and the tens display on. Your software checks for detector 1 to go Hi. Pause for about 5ms and check that it is still Hi If no then goto showtime, if yes then goto gettime This is a solution which can have small timing errors due to actual response to detection occuring after built-in pauses and it will be fooled if the train is longer than the distance between the detectors, but it should be easy to do so that you get a result (a working system) quickly. Of course you'll want to tackle these problems with Mark#2 after your initial success, so a simple first solution should not be seen as demeaning but as being suitable to 'give you the bug' to go on. 'a short period' should be around 5ms which flashes each display 100 times a second - way too fast for the flicker to be visible. If you shorten the time you'll need to reduce the resistors a little to allow a larger current into the LEDs. If you lengthen the time the flicker will first become visible as ghosts, then as eye-straining pulses. Bye. > -----Original Message----- > From: Ray Russell [SMTP:RRuss45826@AOL.COM] > Sent: Monday, 22 January 2001 16:58 > To: PICLIST@MITVMA.MIT.EDU > Subject: 16F84 help needed. > > I am a rank begginer here so please help if you can. > I have a project I need to do for my main hobby interest Model > Railroading. > 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! > > Ray Russell > General Contractor > Norfolk & Western Railroad > > Pocahontas Division > Circa 1958 > Visit The Pocahontas Website at: > HREF="http://milliron.home.sprynet.com/Pocahontas/Pocahontas1.htm">Click > here: Pocahontas Home > OR > http://milliron.home.sprynet.com/Pocahontas/Pocahontas1.htm > > -- > http://www.piclist.com hint: PICList Posts must start with ONE topic: > [PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads > -- http://www.piclist.com#nomail Going offline? Don't AutoReply us! email listserv@mitvma.mit.edu with SET PICList DIGEST in the body