Shop OBEX P1 Docs P2 Docs Learn Events
Help on figuring out where to start please... — Parallax Forums

Help on figuring out where to start please...

djh82ukdjh82uk Posts: 193
edited 2007-11-09 01:04 in Propeller 1
Hi guys

Ok, im trying to make a complete automation controller for a dcc model railway set. Now I don't have to control the train, just all the auxillary stuff.

Ok, I want to control the signal lights, the points and the brake modules (to stop the trains at the station/lights etc)

Now, there are going to be about 100 sensors, probably 15 sets of lights, 20 points and a load of brake modules.

Now I know that this is going to need quite a few props due to the number of variables and I/O, question is do I use just props, or props and sx's.

Now the way it is to work, say there is a stretch of track, a train has just come out of the shed and is sat at a red light, the track further up has another train on it, i want it to manage the lights, and change the junction points to route the trains. Say the train not at the red light, needs to go past the one at the light, i want it to change the track it is on, but also to check that one is clear.

Now the way I was thinking of doing it, was to have some props purely dedicated to checking the sensors, and each piece of track that is between either lights or points to be given a letter, a,b,c etc and each sensor on that section to be given a number, so you have A1, A2, A2, B1 and so on, so it should'nt miss a train if it is there.

say for each 50 sensors I have 2 props just to check this, one a master one a slave, the slave check 25, and send the info via serial to the master checker, which then checks it's own 25, and then sends the full 50 result down a serial bus that all other props are listenning to.

I was then thinking of a few props for managing lights and brake modules, a few props to manage points etc, but they all need to talk. So a light prop gets it's sensor registry, and runs it few some if thens, say i notices a train at A1 and another train at B2, a second later it notices the train at A1 is still at A1 as the light is red, but the other is now closer at B3, so it has to stop the train at B3, until the train at A1 is ready to go, it must then be diverted down another track.

Or would it be better to each prop modules cover the lights and points but for a smaller section of track?

Firstly I need to know the state of each sensor every few seconds which gets sent down the serial bus that the other modules listen to, perhaps then have another prop that knows all the positions of the points, and another that knows the status of each signal light. Then another prop to do all the figuring out? Which then sends it's commands down another serial bus. Which is answered by the control props, which actually change the lights, or move the points.

so... Any Ideas on the most efficient way?

pls see atatched really bad image for an idea
720 x 450 - 18K

Comments

  • djh82ukdjh82uk Posts: 193
    edited 2007-11-04 02:59
    Or do I compartmentalise it all?

    As in each smallish section (say A, B,) is handles by 2 props, and C and D is handled by another 2 props, and they only talk to each other about the status of the senors/lights/points that are on the border, so they would talk about B and C.

    So prop one has a train at B2 and prop 2 has a train at C2, so prop 1 switches a red light on, and prop 2 diverts the train at C2 onto another track that it knows is clear.

    if none are clear, then it makes a light red, and tells prop 1 that the train is still there, so prop one can move one of it's trains, making it clear for prop2's train.

    I think i need to make a set of rules of some sort, like which tracks have priority and so on.

    I know this is going to be complicated, but do you think it can be done?

    DJH
  • RaymanRayman Posts: 14,162
    edited 2007-11-04 03:14
    I'd think you could do it with just one Prop and a serial-to-parallel chip. Best way, I think for the Prop, is to use the I2C bus. There are plenty of 8 and 16 port expansion chips for I2C. The Prop already has an I2C bus on pins 28&29 to interface with the eeprom. So, you don't use any free pins...

    I have some notes here:
    http://www.rayslogic.com/propeller/Programming/i2c/i2c.htm
  • deSilvadeSilva Posts: 2,967
    edited 2007-11-04 10:57
    @djh82uk: I should support Rayman's opinion!

    (a) Cost and complexity:
    -The lowest cost solution will be to use one chip and many shift registers (PISO, POSI), as you have no strict timing requirements this will do: 10ms will look like eternity to your trains..
    -Using I2C will simplify in two ways: You are more flexible with the question I or O? You need just two wires (plus Vss and Vdd of course), and I2C is a bus whilest shift registers need daisy chaining. Cost considerations come in when you need 200 signals = 25 chips.. This will be $100 against $10...
    - Using multiple Props is the most fascinating solution, but also the most expensive one. I think you can do all by six additional Props alone, somewhat above $100 including EEPROM.

    The last solution will be preferable when you have more data to handle, also when timing becomes tighter, i.e. do some things within 100us rather than within 1ms. Also when you plan to use SPIN only, a single Propeller will soon run out of time controlling 200 signals and making decisions...

    The circuitry will be more complex with the 7 Props, but you can build it quite modular...

    (b) Never start with the architecture (though your pet concept be in your back mind) but with the functions: What shall be done, what input/output is needed? How fast?
    Then you come to resources: Is there something with 200 pins beeing polled each ms and displaying it to a monitor with 256 colors?
    Then you decide how to distribute the functions to the chosen components.

    Oh dear... Sorry for lecturing ..
  • AleAle Posts: 2,363
    edited 2007-11-04 11:28
    Everyone loves trains, how about some pics smile.gif

    go for some i/o expanders as told (simplest), and test with 25% or so of your signals. If you encounter problems... timing, well go for asm, then maybe a separation of tasks could be needed.
  • djh82ukdjh82uk Posts: 193
    edited 2007-11-04 13:25
    Hi

    Thanks guys

    it's my fathers train setup, he's been building it for 10 years, and now approaching retirement i want to help him get it set up really well.

    I can see the many merits of the i/o expanders, and I guess if timing does become an issue due to the sheer scale of it, I could just go with one prop for signals, one prop for sensors, and one prop for points, but still using the io expanders, and still keeping the cost acceptable.

    Can the io expanders do inputs ok?

    I will do some reading up on them

    Thanks all of you

    [noparse]:)[/noparse]
  • Fred HawkinsFred Hawkins Posts: 997
    edited 2007-11-04 15:47
    deSilva said...
    @djh82uk: I should support Rayman's opinion!

    (a) Cost and complexity:
    -The lowest cost solution will be to use one chip and many shift registers (PISO, POSI), as you have no strict timing requirements this will do: 10ms will look like eternity to your trains..
    Well almost no timing requirements -- it's a dcc system after all.· Which probably means at least sixteen pwm·control signals multiplexed onto the power supply. The timing needs to be fussy enough to drive a store-bought dcc engine.

    Edit: Looks like I am caught out as relentlessly old fashioned. DCC these days is byte data driven, not pwm. There's even a wiki for DCC http://www.dccwiki.com/Introduction_to_DCC



    Post Edited (Fred Hawkins) : 11/4/2007 6:44:33 PM GMT
  • rjo_rjo_ Posts: 1,825
    edited 2007-11-04 16:17
    djh,

    The best expander that I know of is the Prop itself. Your original idea is fine. Props only cost $12 and they all work exactly the same... You are talking about very slow processes, which at the end of the day all reduce to a small set of truth tables, which you can probably store in RAM on your master Prop. You don't need I2C; all you need is a way to convert your intermediate logic to some very simple set of signals... which can be passed directly from one cog on one Prop to another Cog on another Prop. Whatever comes most naturally to your brain is the best way to do it.

    To convert the entire thing to a physical model, you are going to need physical switching... which is pretty simple but you are going to have to decide how you want to implement it. I know that there are programmable switching boxes available for model trains, but it would be much more fun to implement it yourself. You need a minimal prop set up... There are guys here that can offer you a Prop only with an EEPROM hooked up and a standard USB connector... probably for less than $20. Or you could go with a series of proto boards, but the form factor is a little much for a model train setup.

    That's really all you need.

    Rich
  • djh82ukdjh82uk Posts: 193
    edited 2007-11-09 01:04
    Thanks guys

    Hopefully I can get some time to have a play with this on the weekend, just need to make a new bed for my cnc machine so I can make a board for it..

    DJH
Sign In or Register to comment.