Hi. im new into arduino. Can i connect more boards.?? ex. the mega2560 board. I need at least 1100 in/output ports. I need them for my model railroad. I intend to use them for all my switches. That vill be 1 servo, 1 pushbutton and 2 leds for ever switch i have. I have about 75 switches for now and more vill come. At the same time i wish to control all my signals. Therefore is is essential that i can control all switches and signals in the same program. Sincely Brian Gervin
Yes you can.
But damn, 1100 is A LOT! Take it step by step. Try to make it modular. And do you only want to control servo's with switches? If that's the case the different Arduino's don't need to talk to each other and it's just multiplying the same system multiple times.
If you want some sort of other control (and please explain it all to use if you want help) you can link them yes. But I would really think about some sort of bus. The default thing like I2C or SPI is only designed for short range (arduino's next to each other). But with things like RS485 it's easy to make a bus with 10m-20m between the Arduino's.
I have done some thinking.:-) and you have a point about dividing it in to minor modules. It is posible to do so. And the replacement of a board is therefor very esy done. The longest road out of the station is passing 13 switches. That give 52 ports used. Then i can turn a control led on and check that led in a other board. That control led i only have to check wether it is high or low. I dont think that gives me any problems. When the control led is high i can put the signals into a drive position (green light). It is also easy to put code into every board and easy to correct any fault.
So all in all many thanks for your input it was a great help for me. Thanks again... :-)
PS: but i still have to use a lot boards..... :-)
Modulair thinking makes things like this easier. That's one adventage of DCC digital driving and things like LocoNet, it's all modular so easy to expand.
But it's still unclear what you want to do with each turnout/switch. Do you just want servo control? Of do you want to be able to control multiple turnouts at once? Of do you need some sort of track security? What's the idea?
Make use of addressable modules. You can connect each module to the same TX pin of a serial port on the Mega (there are some limitations) or daisy chain them (as shown below).
+-------------+ +-------------+ +-------------+ +-------------+ | Mega TX |-->| RX MOD 1 TX |-->| RX MOD 2 TX |-->| RX MOD 3 TX | +-------------+ | | | | | | | 1 2 3 4 | | 1 2 3 4 | | 1 2 3 4 | +-------------+ +-------------+ +-------------+
The modules are output modules in this case. Your Mega will be the brain and tell the modules what to do.
Each module for this example has e.g. 4 outputs that you can use to control turnouts or mechanical signals or ... That way they can be placed close to what they need to control (short wires). You don't use Megas for this but something smaller.
The software in the module defines what it will do. In its simplest form where you switch something on or off (or turn a servo left or right to a given position) you can send data as a 16bit value
bit 0: on/left or off/right bit 1 and 2: output to control bit 3 to 15: board address
This would allow you to have 8192 boards on the bus each controlling 4 outputs with an on/off or left/right. Each module will receive the 16bit data but only react on it if the data contains the address that it knows.
This way you basically will not have 1100 cables going all over the show but a single cable to all modules and short cables to whatever you want to control.
Note that this only tries to explain the basic idea.
That's indeed a possibility. But it really depends on what the modules need to do. Do you really need one brain? Or might it just be easier to have self thinking blocks that can tel each other stuff when needed. All depends on what he wants. To just drive servo's of routes set with servo's you don't need a master brain...
And I would not run plain TTL serial under my layout. I would make it more durable by using RS485 or just by making it more low impedance etc.
My idea was that the modules have their own little brain. Tell it to throw a turnout left and it will do what is needed to throw that turnout left; it can activste a coil for a given duration or turn a servo (no idea what is needed for that).
The master brain that I mentioned earlier is only there for e.g. automation or read a button push to instruct multiple modules to throw certain turnouts to select a path to a certain track.
Personally I will probably use symmetrical signals but that was not what my reply was about. It was more to explain the idea of a modular approach. If an Arduino is involved, intelligent modules can also be used. I have 3 or 4 different article series describing complete systems without central brain and using simple digital electronics. One even using NANDs and so on using transistors.
You are absolutely right but I was just expanding your explanation. Just to give an idea you can do it multiple way's depending on the specifications.
And the center brain part is a great idea if you want some sort of overall control. But if you just want to switch one or a couple or turnouts with the flick of a switch it's a bit overkill.
Like I made a module to control servos for model railroad (for like switching turnouts etc). I just used push buttons as an input. Yeah, you still would need a lot of cables. I could have used some sort of bus to do that. But doing it this way it's an easy, stand alone, replacement for turnouts with coils.
And serial daisy chaining works but I thought I needed to mention the chance or error when used under a layout etc
I think a custom board with serial (RS232 or RS485) back to a master for sending commands/reporting status back would be ideal. Something 1284 based could support 12 Servos, 12 buttons, 3 shift register with current limit resistors for the 24 LEDs and still have 5 pins free for serial comms using 1 or both serial ports - maybe 1 to the master and the 2nd to other nearby boards so you could cut down on master to 'slave' wiring. Or maybe have the master controlling a bank of MAX7219s or similar for showing the commanded state of all the switches.
Yeah, a custom board makes thinks like that a lot easier.
I based it (and many others) on a Pro Mini just because they are so incredibly cheap. And it already has a bootloader (okay, changed them all to Optiboot), all external parts are already present and it's easy to stack (removable) on a PCB. Same for the Nano. Slightly more expensive and bigger but has the USB already on it.