At 01:27 PM 10/30/96 -0600, you wrote: >How about something less serious and more fun. I want to use PICs to >control my model railroad. In particular, I want to detect when there is a >car on the rails in a designated block so that the PIC can drive the >signalling system (LEDs). One rail is a continuous +12V DC and the other is >ground. All cars have metal wheels and draw varying amounts of current. >Locomotives have DC motors, passenger cars have lights, and cars without >motors or lights have a resistor across the wheels (to insure that they draw >some current). What would be the best way for a PIC to detect when this >current flow is present? Maybe a voltage comparator or something like that? OK this one is easy for DC control. Use a pair of diodes wired anode to cathode. The diode pair will generate a voltage drop when current is being drawn. Use this voltage as an input to an op-amp set up as a comparitor. When no car is present, the output goes to one rail, when a car is present, the output goes to the other rail. Use this as a digital input (can be directly to the PIC or to a shift register used to expand the PICs I/O). I have a URL at home to an example circuit that can be used or modified to do this. Note, if you don't detect all blocks, you still need the diodes so the train will not speed up when it enters the non-detected block. If you go to a DCC system (See below), a current transformer on the track feeder is all that is needed to get a detection. I found the URL: http://www.mcs.net/~teller/www/tractronics/articles/articles.html The article is the detect train article. The others are interesting also. > >Another question. I want to place a PIC in every locomotive and then >superimpose digital commands signals on the rails so that the locomotives >sitting on the rails can listen for the commands addressed to them and >respond accordingly. This will allow multiple locomotives to be controlled >independently of each other on the same section of track. The problem is >that a model railroad is an electrically noisy environment. Anyone who has >seen the occasional sparks that fly between wheels and dirty track would >visually see this problem area. What would be the best data transmission >method to use to minimize the effects of all this noise. RS232? Frequency >Shift Keying? Tone Link? Look at the DCC (Digital Command Control) specs from the NMRA. They detail a system that allows for this. There are commercialy available "decoders" for locomotives that control speed, direction, lights, etc. The cheapest one is about $30.00. You can build your own following the standard or buy them. The system to put the signals on the rails can also be built or bought. (I am working on one using a PIC16C73, and commercial decoders for the locomotives) Basically, DCC is a bipolar signal that sends bits along the rails. The bits are encoded based on pulse width. A zero is a 100us + pulse followed by a 100us - pulse. A one is a 58us + pulse followed by a 58us - pulse (starting polarity is not significant). The DCC signal sends both the power and the data to the locomotive and accessories. See http://users.vnet.net/paulrver/st_welco.html and look in the DCC Stadards and Recomended Prectices for more info. > >Another question. Will transmitting digital signals like this over the >rails cause RF interference. Won't the rails act like a huge antenna. I >don't want neighbors complaining about their TV going nuts or worse yet, >having the FCC get involved. Probably will cause some interference but I haven't had any problems yet, and I have run my prototype system on the floor in front of the TV. > >Thanks alot. DRC > >