Yeah, we've gotten pretty far off the path now... and at this point I'm hoping some of the folks that are geared to the technical haven't all dropped off. Technical stuff starts in a paragraph or two below...
I was looking into SD card readers and trying to find out how Arduino binary programs could be uploaded without having to use the IDE. While the SD cards would be a good way to transfer readable program parameters, the bootloader issue is unsettled. There's a whole lot on the net about doing this very thing but it is dated and there doesn't seem to be a concensus of what to use. I'll continue to try to figure that out, at least for myself. If anyone has any ideas about this, please step forward. It would be great to be able to load program changes without having to move things around to do it.
I can't help with the Wifi idea. I'm one of the uninitiated about how that works. But it's an interesting idea nonetheless.
I like the idea of SD cards to transfer programs, or some other nice, clean, approach, but at this point I don't have a good way to do that. My thoughts right now are to have the unit come pre-programed with the whole list of functions coming below and allow the user to choose which one by setting a set of DIP switches. I have decided to use an Arduino Nano type board here instead of the smaller and less expensive Pro Mini that I usually favor. This will leave a USB plug on the device that could be used to update the firmware on the unit if additional features are added later. The process of doing this would be pretty simple to folks in the know, but may be a deterrent to many. I expect that I would offer to do this for folks if they don't want to do it on their own. I'm thinking the best course right now is to make it "easily" reprogrammable if needed, but not too worry much about the average user having to flash the thing.
As for the Wifi, I would likely use something like an ESP8266 module which is a fantastically powerful little thing. One could actually use this chip as the uP if they wanted to, but I'm not quite comfortable doing that yet. If you want to learn a little about that try searching for "arduino ESP8266 webserver". There is a lot of info out there, though some is more useful than others. I picked up a dozen of these modules a couple years back when they were first gaining popularity, but haven't played with them in a while now. None the less they are powerful little things that cost less than $3 each.
Ok, back to the nuts and bolts...
Right now I'm looking at a basic hardware outline as follows: An arduino Nano type board will be the brains of the operation. Each module will have 2 inputs and 2 relays for output. A set of 8 Dip switches will be used to configure settings. There will be 5 Potentiometers, one for sensitivity adjustment, then a corse and fine adjustment for timing on each of the two circuits. These might be used to adjust special functions in some cases as well. Two push buttons will be used to set minimum and maximum limits for functions that require them (ex: X number of laps to trigger). Terminals will be provided to connect manual-override buttons, this way the user can use whatever style of button they like to match their control panel... or none at all if they like. A header will be provided to allow for later Wifi connection as well as for connection to other devices if a user wants to interface with the device, The header will provide signals for when a train is on the insulated rail, as well as if the connected accessory is on or off, ex the states of inputs and outputs. I'm considering placing an RGB LED for each potentiometer to give some feed back of the pot's position, ex green for zeroed, blue for middle, and red for end of travel. The pots I'm looking at are a 30 turn adjustment and have no stops, so you can keep turning forever, and I think it might be helpful for users to have some kind of feed back of how far they have turned it.
We're going to end up using quite a bit of I/O here to get everything done so I'm looking at using a 16 bit I2C port expander, giving us 14 more I/O pins than we'd otherwise have. I think the added functionality is worth an 80 cent part. All told I think I'm still under $10 in parts, not including the cost of the PCB. Through OSH Park PCB costs about one dollar per square inch in minimum of 100 sq" orders. I'd like to find a little less expensive option, but even if we end up at 4 or 5 dollars for the PCB I don't think it will hurt too badly. As a kit to be assembled the cost would still be easily in the price range I'm hoping for. I won't know how much of my time it takes to assemble these until I've done a few and have to base an assembled cost on that. I think it can still be done for around half the price of the detection units offered by the big players. It is also possible to drop the cost a bit by using some SMT parts, though not a ton. There really isn't much in the way of parts going on here besides buttons, pots, relays, and screw terminals, none of which can be reduced in size. It's also possible that I could produce my own circuit boards for a while and that might help drop the parts cost, but would produce a less refined looking product.
Anyway, at this point heres the features I'm planning for:
Please pardon my trying to keep things short, if you need better explanations of a function, just let me know.
1 channel means that each module can only do this option once, it takes both inputs and/or outputs to do. 2 channels means that each module can do this function for 2 separate accessories, each accessory needs only 1 in and out.
Functions:
Standard: 2 channels. Relay turns on whenever triggered, turns off when not triggered.
Delay turn-off: 2 channels. As with Standard, but remains on for adjustable time after trigger goes off.
One-Shot: 2 channels. Turns on for an adjustable amount of time the moment its triggered then shuts off, regardless if the trigger is still active. Turns on again the next time trigger is activated.
Timed Loop: 2 channels. Turns on when triggered remains on for an adjustable amount of time. iIf still triggered when time runs out timer is reset and the accessory remains on until the time runs out.
Alternating output: 2 channels. First trigger turns on relay, second trigger turns off relay, repeat.
Alternating Output (timed duration): 1 channel. First trigger turns on relay one for an adjustable amount of time. Second trigger turns on relay 2 for adjustable time. Repeat.
Enter-On, Exit-Off (mode 1): 1 Channel. Turns on when first trigger is activated. Remains on until second trigger has been activated AND deactivated? (Still working on this one. Al la PLCProf's suggestion early in the thread. Need more detail if this is the desired operation?)
Enter-On, Exit-Off (mode 2): 1 Channel. As above but with timer adjustment to remain on for a duration after the train passes.
Directional Activation (mode 1): 1 channel. when input 1 is triggered, then input 2 is triggered, turns on relay 1. when In 2 is triggered, then In 1, turns on relay 2. Mode 1 remains on until second trigger is deactivated.
Directional Activation (mode 2): As above, Mode 2 remains on for adjustable time (one-shot) from when train enters the second block.
Directional Activation (mode 3): As above, Mode 3 remains on for adjustable time after the train leaves the second block.
Directional Activation (mode 4): As above, Mode 4 remains on until a train passes in the opposite direction.
Trolly Stop: 2 channels. When triggered, turns off power to track for adjustable amount of time. Power remains on until next trigger.
Grade Crossing (mode 1): 1 channel. Begins flashing signal when train enters first insulated section. Remains flashing until train exits that section. stops flashing after adjustable time after the train leaves first section. Trains form opposite direction work the same way. result is the crossing begins flashing some time before the train arrives then turns off quickly after the train has passed, in either direction. Provides 3 outputs. One turns on while grade crossing is active, out 2 and 3 alternate on and off. out one can be used for gates and such, 2 and 3 connect to lights. Speed of flashing is adjustable.
Grade Crossing (mode 2): 1 channel. Same as above but only turns on relay for crossing signal, no flashing. For use with signals that have built in flashing circuits.
Every X Minutes (Triggered): 2 channels (probably). Output will only activate once in an adjustable amount of time. Once that time passes it will activate on the next trigger. (Adjustable in minutes and seconds.)
Every X Minutes (Cycle): 2 channels (probably). Output turns on for an adjustable amount of time once every X minutes and seconds. No input triggering needed.
Frequency options: (options available for all above functions, even though I don't think many of them benefit from it... but you never know what use someone might come up with for a grade crossing that only activates every 17th lap.)
Every Time: Every time the trigger is activated the output is activated.
X Number of Laps: output is only activated every X number of times the trigger is activated. Number X is programable by the user.
Random Number of Laps: Output is only activated after a random number of times the trigger is activated. User may adjust the minimum number and maximum number of laps that the random number will fall between.
Manual Control Button. Pressing the button will activate the output as if it's corresponding input was triggered. Any timers in use work as they would if the trigger input was activated.
These are what I have right now. Please feel free to offer other suggestions of comment however you like here, Still in the planning phase right now so making changes is easy. If I counted right we have 17 different functions so far. I have room for 32 with the design I'm working with right now. I plan on keeping at least one in reserve, for the 'wifi enabled' function.
Well, that's all for now. Hopefully I can get some idea what everyone thinks at this point.
JGL