Saturday, May 28, 2011

Switch controller

The initial project I'll be doing is a switch machine controller as outline in my last blog post Circuit design begins

With the requirements laid out there, I end up with 4 basic subsystems:
  • Power
  • Input controls
  • Timing
  • Output
Power

Most HO model railroad layouts have low voltage AC and 12V DC readily available. Most of the common switch machines run with 10V-12V (some accept both AC & DC others DC only). So, the design is around running from 12V DC just to keep things simple. What I'm designing will easily run with 10V-16V DC.

Many hobbyists and layouts though, may not have high quality 12VDC power. the snap style relay switches can often draw 3A while in use. This means that options for how much in the way of capacitors can easily be added is a plus.

Trying to keep in mind other possible uses as well, the Output stage might need to be able to run at higher voltages in certain situations. By laying out the runs carefully and allowing for an extra power connector, we can allow a couple runs to be cut to isolate the main circuits from the output so that we can allow higher voltages. An added plus is if I have room, allow for a 7812 or 78L12 to be added at the cut location so that we can regulate power our elves. This easily allows for 24V DC or greater for the output stage depending on the rest of the components chosen.

Finally, we may have multiple boards near the same area of the layout. Allowing for a power out connecter can simplify wiring. When we don't want that, not installing the connector saves money.

Input controls


Accepting either two wire or three wire input with voltage ranges from digital to +/- 12V DC could risk the circuit getting more complicated then needed. Thankfully, optocouplers are readily available that have a wide range of current & voltage. By using a DC optocoupler and a single 470 ohm resistor per input, gives us a wide range of input from less then 4V to well over 12V.

Using a DC coupler then I add a couple three position jumpers to select between two wire & three wire mode. By moving the jumpers, I can hook one coupler up in reverse with other to trigger on negative voltages for two wire mode. Three wire mode is same polarity, but to the third input.


Lastly, transistor output type optocouplers are vary insensitive to the input voltage. Just select the proper resistor and wiring, and you have either an inverting ot non-inverting circuit. In my case, I'm going with the inverting circuit since the timing stage likes to trigger on the falling edge.



Timing


We need at a minimum to either output a one shot pulse or debounce the input to clean it up. Just running the signal straight through I consider a debounce with a very short timeout. A 556 dual timer is handy for this, being a dual timer means a single chip handles both of the inputs and outputs. It's also forgiving on power requirements running on up to 16V DC.

For adjusting the timing, I'm just going to be using a simple RC without making it adjustable. Someone needing to make it adjustable can modify that easily, but we don't want to worry about calibrating trimpots or them changing in most cases.



For one-shot verses debounce, using a coupling capacitor with the input stage and an optional jumper or installing a wire instead lets me choose either easily.


We also want to make sure that both outputs aren't on at the same, so adding a jumper between the two half's of the 556 timer between the output of one and the reset of the other accomplishes this. By allowing a jumper, this becomes optional, and removing the jumper allows each side to be independent allowing for non-switchout uses, such as lighting control.


Output

As outlined in power, we want the output voltage to default to what's running the entire board or optionally it's own voltage. That's mostly a layout issue.

We also need to run two wire or three wire type output at anywhere between 20mA to 3A from 10V-12V DC. Two wire needs to reverse the outputs to apply negative voltage, while three wire has a common plus two wires that just get the required voltage as needed. Luckily, for a two wire arrangement, we normally only need low current, we don't need to worry about high current and reversing voltages at the same time. This allows us to avoid using an H-Bridge and simplify the design by using a resistor with a MOSFET or transistor.

The high current requirement with a relay does mean we need to worry about power spikes when we shut down the circuit or it's moved by the other half. That's one or two diodes more on each line to add that protection

Additional notes

Connectors! I personally love the euro-style screw connector that clamps down on the wire for things like this. It works easily and gives you a secure connection rated at 10A to 15A for the smaller parts. You have an added bonus that some of the connectors use a slightly larger hole size. If I lay it out for the larger hole and add an extra large pad around it, I also have something that's easy to solder a wire to for people trying to save money on connectors.

For the circuit board size, since more then one turnout is usually together and increasing the size won't greatly increase my board costs, I've decided that having two pairs of circuits on a single board makes a lot of sense. Each pair handles one turnout giving my design the ability to handle up to two turnouts or four separate outputs.

Sunday, May 22, 2011

Circuit board design begins

How time flies when you're having fun!

General design considerations
 
I've been busy designing a board for the train layout, along with getting parts I needed for prototyping . Considering what all I've accomplished on the design, I'm going to cover some of the tidbits & hints related to hobbyists getting parts for another post. As it is, I'll be splitting the thoughts behind the board design into more then one post so I don't feel limited by post length.

Since I hand previously decided I was liking PCB Artist and the capabilities of Advanced Circuits, I've been using their tool for laying out my circuit as I've been designing it.

For the hobbyist,  I've been keeping in mind:
  • Use through hole components. Many hobbyists won't have the skill or patience for surface mount work
  • Avoid specialty parts. The parts needs to be easy to find and inexpensive.
  • Avoid high tolerance parts. They are more expensive and the greater the usable values used, the better the chance they may have a usable part already.
  • Use discrete resistors instead of SIP modules. Hobbyists are more likely to have the normal resistors and it's easier to adjust the values
  • Try to reduce the number of different component values when possible. This makes assembly easier and might help lower costs by getting larger quantities on common values. I'll get more into this when I get back to getting parts.
  • Size is not an important factor. Cost & easy of assembly are much more important.
  • Think about modifications and build time options. This can make final design much more flexible and usable in other situations.
  • Stick to double sided boards when it comes to layout. I won't be saving money or effort by going to single sided since they will be manufactured for me. Having internal layers will make them more expensive and harder to modify if the internal layers need to be modified.
  • Plated through holes for ease of assembly and fewer problems. With the manufacturing facilities available, you won't save money skipping this. This would apply to home made boards only.
  • Solder mask to reduce the chance for shorts during assembly. Same thing as plated through holes above, but even more important.
  • Silk screening and labeling. If the PCB is being manufacture for you, why wouldn't you? In most cases you will save little to no money skipping this with the high amount of automation involved and the
  • Try to avoid having component leads too close together. Hobbyists can make solder shorts very easily.
  • Don't assume the components will be a specific size or lead spacing. Make sure there is elbow room. For example radial capacitors have different lead spacings and even size for the same value from different manufactures or old vs new parts. Even something as simple as bypass caps for TTL chips can vary from 0.1" to 0.4" spacing with 0.2" and 0.3" both being very common.
  • When in doubt, allow for excess capacity in specifications. For example, we know we need to expect 3A surges and maybe up to 5A surges. For example, that means the power connectors & runs should handle 3A to 5A of continuous current or more.
  • When in doubt, add stuff and mark it optional.
  • Don't be locked in on anything for now
Keeping these things in mind will help me make myself something that is more flexible then what I need right now at no significant additional cost. In small quantities, the size of the board isn't a factor for example, the size isn't a factor until you start doing high volume, and the price difference between a 2x3 and a 3x4 board isn't very big at all then anyways.

Project design considerations

The first project I want to work on will be a circuit board to assist in running the relays/motors used in turnouts/switch machine operations. For now, I'm keeping my father-in-law's requirements in mind, but as I work on the design I want to keep more general rules in mind.
  • Only need to worry about two position turnouts at this time. His design doesn't include anything other then two directions a train could go and other peoples designs will have many more of these then all the others combined. This keeps the circuit much simpler.
  • Need to be able to run two wire and three wire switch machines. He has a mix he will be using and having the option to not be worried about what type of switch machine goes where will help during the build and maintenance.
  • High current coil switch machines and slow motion switch motors. He's been accumulating parts for many years, most are used, all have been real cheap deals. So far, all of his coil/snap/relay style switches are three wire and the motor switches are two wire machines.
  • 10V-12V DC operation. His snap switches will work with AC or DC, but his motorized switches are DC only. By designing to DC only, I can keep the circuit simpler and then install low current or high current parts in the output stage. When in doubt, high current parts that can also run at low current.
  • Allow for higher voltages. We don't need it, but other people may need to drive a 24V relay or motor? If I can accommodate a modification that allows for this if the proper components are used without adding to the cost, I will!
  •  3A or more surge. Coils need a lot of current to work, but for a short period of time. most of the time you must limit powering them to 1 second or less to avoid damaging them. Fraction of a second works very well.
  • Many layouts might suffer from under powered DC power supplies after taking long wires into account or trying to use multiple cheap power supplies. That means allow for excess capacitors to help handle the high current surges. Cheap power supplies often can only handle 1.5A, but we need a 3A surge.
  • Low current motorized machines may need to be on for 8-15 seconds and are often on all the time.
  • Two wire or three wire inputs. Since both types of switches are common, might as well try to support either type of input if I can do that without driving the cost up. Three wire uses a common and two separate signal lines (one for each direction). Two wire either reverses how power is applied, or has a common on one line and then applies positive or negative voltage on the other line to select the direction (both effectively do the same, the difference is when multiple machines are in use and wired together). Two wire with one being a common can help reduce the amount of wiring needed.
  • Momentary vs. throw switches at the control panel. Snap style switch machines usually are connected to momentary switches or three position switches and the switch MUST go back to neutral usually within 1 second to avoid burning out they coil. Motorized switches are usually connected to throw switches (single or double pole, double or triple throw). What controls are used can sometimes depend on what is available at the time it is built. At the same time we need to protect the switch machine from mistakes if possible.
  • Switches bounce! Relays and motors tolerate that, but if we can debounce it, they will work that much better.
  • Don't require calibration beyond components being installed into the board. Trim pots are nice for somethings, but something going out of spec timing wise it not something they need to worry about. It is a plus if it can be adjustable for other uses, but initially fixed values that are easy replace if we want to change the timing is good enough.
  • Don't turn on both directions at the same time! This will either do nothing or risk damaging something even to the point of a risk for fire.
  • Future upgrade to DCC. While I'm not going to build in a DCC controller, we need to easily be able to connect to a DCC or digital controller of some sorts in the future. There are commercial DCC switch control units which may replace this or be hooked up to these boards in the future. KISS, and keep the cost down here! Maybe in a future design I can include DCC decoding if needed, but we don't need this currently. Not all DCC systems will use DCC switch machine controllers either. for this specific layout, he doesn't have a budget at this time for DCC other then working to convert the locomotives to DCC. Allowing for future DCC or digital controls though means that if we can accept either 5V or 12V DC low current on the input controls, we can future proof the design.
  • Turnouts often happen in groups or pairs. Since the cost of the circuit board isn't affected significantly by the size, allow for more then one switch machine driver on a single board. Allow for only populating half the board if only one switchout will be required.
  • Try to minimize the wiring needed from the control panel. Have you looked at the price of copper lately? Long runs from control panels can get expensive and train layouts can spread over a large area.
  • No moving parts. Those are more likely to wear out. I've seen too many bad micro-relays back in my days as a technician. Granted, those were used more then these will be, but relays still are more expensive then the options available using transistors or MOSFET's.
  • Train layouts are electrically noisy. I don't want to see what the EM spectrum looks like or the power spikes & noise on the wires. Wee need to operate in that environment and reduce our contribution to the problem when possible.
  • Probably be mounted directly to the train layout with screws, not in a box. This is a safety vs cost trade-off but we do need to account for that. This means allowing for #4 or #6 screws to be used, even wood screws to mount the board!
  •  Safety! Other then the risk of things blowing up when you first turn it on and test it out, we need to minimize the chances for short circuits and fires. Most model train layouts are very flammable and in the basement, attics, or spare rooms. In our case, it's in a basement and a lot of pine & plastic is being used. That last thing you want is a fire! This means in the long run I won't be building a high current power supply for example. We'll either build or buy multiple low current ones or buy a commercially made high currently supply with all the required safety features.

If you read over everything above, you'll notice I'm already thinking other people might be able to benefit from my design and work. That final decision and details will have to come later, but I am considering making more then we need to lower the per board cost and then see if I can sell the extras on eBay to recoup my costs. My father-in-law doesn't know it yet, but I'm covering all the initial prototyping and testing costs myself, including having the PCB's made. After all, electronics is my hobby and I'm the one wanting to go this route.

Enough for now. I think I've setup whats going through my head related  to the hows and whys of some of the design decisions. In my next post I'll go into the actual design and details I've been working on.

Wednesday, May 4, 2011

Tools research

Being a hobbyist puts specific restrictions on how I'll be working. I do have a monthly budget I can work with, but commercial design software is expensive. I also like commercial quality PCB's for any projects I do that need more then one or two built. I don't want to mess with the etching chemicals and I know from experience the benefits of solder masking, plated feed through holes, and fine runs running between pins without worrying about shorting.

I decided to see if I could kill two birds with one stone. I started searching the web for PCB manufacturing companies that seemed hobbyist friendly that had good design tools usable with them. Hobbyist friendly includes things like simple ordering, reasonably priced low volume production runs, reasonable delivery times & cost, plus Made In The USA! Here I have a choice, but I very quickly decided I was willing to ignore the overseas production facilities to improve my communication, delivery times, and delivery costs. Yes, it might cost a little bit more per piece, but I feel the benefits outweigh the for me personally.

I won't go into the details of all the searches and looking at websites, specs, etc. Since I was choosing a manufacturer and a tool together though, I did download and try out three different tools as part of trying things out from companies that looked good. One tool definitely worked better for me then the others, even if the parts library wasn't up to that of a full professional system. There was a lot of personal tastes in how the tools work and easy of use that was a deciding factor for me. Being hobby grade, I'll be limiting myself to through-hole components just to make things simpler, so a more limited component library isn't much of an issue for me. I don't want to be worrying about about soldering to pads or mass production that's for sure.

I've gone ahead and settled on one company based on the tools, pricing, location, and capabilities. Advanced Circuits in Colorado seems to have good capabilities, a reasonable tool, reasonable pricing, as well as support for commercial tools and production. While I'll be sticking to two layers and won't need their more advanced capabilities, I'm not stuck in an emergency. I don't ever expect to need a flexible PCB or 28 layer board, having very fast turn times on small runs along with fast delivery to me in the Midwest using ground shipping adds up to a nice combination for me personally.

Now, to play more with their design tools!