The only concerns that I see are: 1) A train with multiple engines 2) So many cars that eventually a PIC down the line couldn't hold the resulting string before sending it along. A method could be for the master to send a number down the line, and each pic that gets it sends it along with a second number decremented through each PIC. When a PIC receives the two numbers with the second one being zero, it sends it's address back as the first number. Thus it knows which place it is in, and the address could define what type of car it was on: Master sends 0 0 Next PIC returns (address) 0 0 Master sends 1 1 Next pic sends 1 0 Next pic returns (address) 1 etc. A method to determine master status is to first test to see if their are PICs on either side of you. If there are both, then you are a slave (nyah nyah!). If only one exists, send a "I AM MASTER, HEAR ME ROAR!" signal with a number starting at zero. Each pic that gets that signal increments it. If a pic gets that signal from two masters (one on each side) it finds out who was fastest by comparing the numbers, and sending out two messages, one to the loser "You are a slave now, as lowly as I" and one to the winner, "Congratulations, you've won the battle of wits." Of course, in this case you'd need control characters (1 byte to precede all communications) One control says pass this data on, decrement and if it is zero reply. One control says pass this data on without changes One says pass this master contention on and increment the data One says pass this message on, "you are master" One says pass this message on, "you are not a master" But there are infinetly many other ways. The drawback with this one is the longer the train, the longer it takes to get all the info for the cars, much longer than your suggested method. -Adam Azrael wrote: > > I would appreciate any input from the more experienced PIC users out > there on the best way to tackle the following problem: > > Imagine you had a train, with a PIC chip (in this case a 16C505) in each > car. Each car has a value, say a number assigned to it. The train is an > indeterminate length and the goal is to find out what the value of each car > is and what order they are in. This all needs to be processed in the > Engine. > > My solution was for the engine to act as a master chip to run the show. > It would start by asking the car behind it if there was a car attached > behind it. This would continue down the train, one car asking the next until > it came to the caboose. At that point the caboose would take it's value and > transmit it to the car infront of it, which would append it's value to the > caboose's and trasnmit that. This would continue until it reaches the engine > where it would parse this giant string and then have the value of each car > and their order relative to it. > > I was planning to do this all with two serial ports per car, > input/output on each side of the car to determine a left and right side. If > anything is blatently wrong or could be done much better some other way I'm > open to suggestions and input. > > Thank you > > -Stu