Skip to main content

I am trying to build a basic circuit that can act like an on off switch.  I was going to use a 3904 transistor that when biased with +5V will conduct and energize an optical isolator such as a MOC3010.

 

This is very similar to the Lionel Motor driver boards for early TMCC.

 

Here is the hard part (for me). For the logic of how it needs to work:  There will be 2 DC control signal inputs.  If they are 0,0 or 1,1 the circuit would be armed and when a third temporary signal is presented a +5VDC offset such as a whistle signal, the logic would latch a bias signal for the 3904 transistor so that the MOC3010 will conduct (even when the +5VDC is removed).  When a second +5VDC signal is sent, the logic will turn off.  Repetitive cycle.

 

If this is too hard, it could be made such that when a 0,0 is present it would work.  Any other combination of 1,0, 0,1 and 1,1  would not allow the logic to work.  Thanks in advance.  G

Original Post

Replies sorted oldest to newest

ogr ggg logic

Exactly as GRJ says.  One implementation is as shown.  When signal 1 and 2 are both 0 or 1, then the XOR gate output is 0.  This line drives the Reset line of the flip-flop which allows it to toggle when 0.  So on each new "Offset" pulse, the flip-flop will toggle on and off.  If signal 1 and signal 2 do not match, then the XOR gate output is 1; this activates the Reset line of the flip-flop and immediately force the flip-flop OFF and it will not toggle with subsequent Offset pulses.  Obviously some clarification is needed on exactly what your voltage levels are.  There are other logic chip families with wider operating voltage range than the 2-6VDC 74HC family that GRJ mentions.  Also, if the "offset" pulses are noisy, you may need to condition it so you get only one clean edge for each activation pulse.  This may require a few more components.

Attachments

Images (1)
  • ogr ggg logic

John/Stan  Thank you.  The offset will be carried over track AC so up to 18VAC.  The signal will be the Whistle +5VDC.

 

The signal inputs will be DC up to 12-15VDC.  It also needs to with stand a power disruption (changing engine direction) but keep the last state.

 

Operating voltage for the chips could be regulated down to 5VDC or use a higher 15-18VDC. 

 

The signal inputs would be DC motor voltages.  The logic being that when the engine was in neutral,  I could sound a whistle signal and get a switching action.  So if I could rectify track AC to drive the circuit and use motor DC voltages and the 3-5VDC over track AC as the signals, this would work as long as it can handle the direction changes (short loss of power) with out changing state. George 

Originally Posted by GGG:

John/Stan  Thank you.  The offset will be carried over track AC so up to 18VAC.  The signal will be the Whistle +5VDC.

 

The signal inputs will be DC up to 12-15VDC.  It also needs to with stand a power disruption (changing engine direction) but keep the last state.

 

Operating voltage for the chips could be regulated down to 5VDC or use a higher 15-18VDC. 

 

The signal inputs would be DC motor voltages.  The logic being that when the engine was in neutral,  I could sound a whistle signal and get a switching action.  So if I could rectify track AC to drive the circuit and use motor DC voltages and the 3-5VDC over track AC as the signals, this would work as long as it can handle the direction changes (short loss of power) with out changing state. George 

So the thick plottens.  The circuit I showed will immediately clear/disable the output if the signal inputs are not matched.  Based on above, this is not what you want.  In other words, once you toggle the output to the state you want (by pressing the whistle button), you want that state to be remembered irrespective of changing signal inputs.  Is that correct?  After all, when you press DIRECTION button, the motors might stop at different times or maybe not stop at all if there's enough momentum in the flywheel.  This means the signal inputs might momentarily mismatch which you want to allow.

 

Now it's not clear why you want  the whistle button to toggle the flip-flop when both signal inputs are 1 (when both motors are being driven).  Aren't you saying above that you want the whistle button to work when the engine is in neutral?

 

Are you using some simple whistle detector circuit (like a R-C filter with a non-polarized C)?  If so, you definitely want a circuit with hysteresis so you only get one edge for each button press.  That is, you never get rid of all the line ripple so you might get the flip-flop toggling at 60 Hz when pressing or releasing the whistle button.  So if this is the case, a Schmitt trigger gate or a comparator IC with hysteresis will solve that for 25 cents.

 

Power loss is no problem.  It would just be a "large" capacitor on the power supply like 100uF.  The power loss memory is one reason to use a 2N3904 or whatever to buffer the drive to the MOC.  That is, if you directly drive the MOC from flip-flop output, then that power-loss capacitor would drive the MOC LED current during power loss which would drain it more quickly.  That is, for the type of circuit I think you need that MOC LED draws more than 10x the current of the logic circuit meaning the capacitor would be 10x larger and to no end since you wouldn't have AC power anyway to drive the MOC load.

 

You probably need to filter the DC motor voltages.  Share more specifics if you wish, but many motor drives as you well know are pulse-modulated.  Given the speed of logic circuits, you might happen to press the whistle button in the microsecond or whatever that both motor drive pulses are "OFF" or 0 and falsely allow the flip-flop to toggle.  But this is just a R-C so no worries there.

 

Also, it appears there's a reversing unit circuit involved.  Shouldn't you be able to pick off a signal that indicates the circuit is in the neutral position?  Likewise, if it's a logic-chip based circuit, then it must have the power loss ride-through capability and since your tack-on logic circuit draws negligible power (using CMOS ICs), then couldn't you use that power source?

 

Stan,  This is meant to toggle a PS-1 smoke unit or Constant Voltage lighting board AC power on and off when certain conditions are met.  Since I am dealing with PS-1 board in a tender, I intended to use the motor lead inputs as the XOR signal.  That way the circuit is also in the engine, vice the tender which would require additional harness wires.

 

For the QSI/PS-1 logic as the bottom board cycles from Reset to F-N-R-N-F...  The relay provide 0-0 voltage for one neutral but 1-1 (what ever track voltage DC is) for the next neutral, this pattern alternates as the motor relays cycle.  When in motion the motor leads are 1-0 or 0-1.

 

So when the engine is in neutral the circuit is armed.  If I press the Bell button I can toggle the smoke unit on and off.  When in motion the Bell button won't effect the smoke unit latch because of the XOR. 

 

One conflict is that above  14 pressing the whistle arms the coupler, and the next whistle fires it, so I shifted to a -5VDC trigger to change states using Bell.  This would allow the smoke to be turned on or off remotely, while the bell would start, the bell could be turned off using the whistle button in neutral or the bell button once the train is in motion with no effect on the smoke latch.

 

It could use the available DC from the PS-1 smoke board to power it, or I create a separate power source.  Hoping for a small package that can handle Voltage source of 18VDC and interrupt the 18VAC to the Auxiliary unit (smoke or CV Board).

 

You are correct for the diesel it would be easy to tap the jumper that provided bias to drive the relay making the XOR signals cleaner.  My primary focus is getting remote control for PS-1 Steam though.

 

It is such a pain to stop and take the engine off the track to throw the switch.  G

I controlled the smoke for one of my conversions in a slightly different way.  I simply sensed motor voltage (either polarity) and only run the smoke unit when the motor is running.  This was for a TMCC conversion where I didn't have a smoke control output as I had used the optional outputs for couplers.  This is the same circuit that I use for Rule-17 lighting and also controlling cab lights so they're off when running, and on when stopped.

 

Nothing like a moving target to keep things interesting....

 

I'm going to assume you don't want to invest the time/resources to implement this in an 8-pin microcontroller chip.  That would take the least space and even allow additional commands like B-B or B-B-B to trigger different functions as in PS2 conventional control.

 

So here's a revised stab at a discrete implementation.

 

ogr ggg logic 1

This requires 3 different 14-pin logic chips and a total parts cost of maybe $2-3.  There are missing details but this should move the ball into the red zone.  I now think I understand your control signals - so this would be what goes in the engine-side without the benefit of any existing logic signals from the Reversing Board in the tender.

 

I suggest running the logic off the fan regulator +5V via diode D1 and C1 to hold the voltage during Direction interruptions.  The circuit runs on ~4.5V and the logic state is held down to 2V or so during interruptions.  The motor contacts on signal 1 and signal 2 are attenuated to logic level and with the input resistors the input current is limited by internal clamping diodes in these chips.  After the U3 XOR gate, U2 pin 11 goes high only when signal 1 and signal 2 match (when the motor has no differential voltage across it).  The R2-C2 bell detector is the minimalist and commonly used low-pass filter to attenuate 60 Hz but pass track DC offset voltage.  So when there is a large enough negative DC offset, U2 input is pulled down and U2 pin 3 goes high.  U2 has Schmitt-trigger inputs so you should get only 1 pulse per Bell button press.  U2 pin 8 then pass the Bell button pulse to the flip-flop U1 only when the motor is not driven.  The Reset line on U1 pin 1 has an RC to reset (turn off) the output on initial power-up of the circuit.

 

Again, there are missing details but decide if the complexity, size, etc. of this approach is worth pursuing further. For example, by restricting the Bell button to toggle the flip-flop only when in neutral-before-Forward (or whichever the case is when both motor contacts are 0,0 then you can use just OR logic (2 diodes) rather than the XOR gate chip to qualify the Bell pulse.  This might save space.  That is, I can't imagine needing to turn smoke on and off very often during an operating session so requiring the engine to be in one of the two Neutral states doesn't seem overly restrictive (and you noted this as a possible option).

 

Of course if the plan is/was to build a handful of these, I'd go with surface mount logic chips where you can buy a single XOR gate in a smaller size and pin-count vs. the standard 14-pin chips where you get 4 XOR gates (but only need 1), or 2 flip-flops (but only need 1), etc.

Attachments

Images (1)
  • ogr ggg logic 1
Last edited by stan2004
Originally Posted by GGG:

It is such a pain to stop and take the engine off the track to throw the switch.  G

I feel your pain.  Yet another option is to put a reed switch (magnetic) on the "ceiling" of the engine and near the smoke unit and use a single flip-flop chip and a few components to toggle the smoke unit any time you wave a magnet near the smoke stack.  Put one of those tiny and powerful Neodymium magnet discs on a wooden dowel or whatever to create a magic wand and you're off to the races...

Stan, what chips are you using?  I got into using the Arduino, primarily because the IDE came up quickly and it has all the initialization logic already supplied.  I did take a run at the PIC, but even the boys at the factory couldn't figure out how to get the little eval board I got to work, so I got discouraged and shelved that project.  The other benefit of the Arduino is there's a host of people writing code and building add-on hardware for the platform.  Being as I plan on using anything with O-scale, I don't worry about the absolute smallest sized board for a project, usually there is sufficient space for circuits.

 

GRJ, if I was doing this and needed to build 5 units, I'd probably use a Microchip PIC but that's because I see an unused bag of them.  These days, software has gotten to the point where the "target" chip or whatever runs the idea or intellectual property doesn't matter.  So if "you" can quickly develop the application on an Arduino IDE platform and can port the code onto a stripped-down PCB with just an AVR and a few Rs and Cs then I'd suggest using an AVR.  In GGG's case I don't think he has the space for an Arduino development board or any other IDE platform board since he needs a handful of them and needs to tack on several "lumpy" components like a triac, relay, etc..  Cost is another factor - even the tiny Lilipad Arduino board is about $10 while any uC chip that has the capability to implement his design would be under a $1.

 

Here's a possibly relevant picture from an old thread.  For a fleet of passenger cars needing remote control lighting, I could have installed an Arduino board, Microchip PICstart board, Texas Instruments MSP430 Launchpad board, whatever.  But since "lumpy" auxiliary components were needed to handle AC-DC conversion, drop-out capacitance, infrared receiver, etc., off-the-shelf modules would have been too expensive and require extensive modification anyway. So I made custom PCBs with the exact hardware capabilities needed.  In this case I used an 8-pin PIC uC.

 

up-remote-1

 

My experience is that track-side or layout accessories are perfect candidates to dedicate an off-the-shelf IDE board.  But for rolling-stock or engines, it seems space, cost, and other logistical factors dictate using a custom PCB with just the relevant uC chip and ancillary components.  Again, that's been my experience and your mileage may vary!

 

 

Attachments

Images (1)
  • up-remote-1

Stan is there a website you recommend that I could read up on the pic approach, pcb manufacture, etc...  I don't have the background, but I think I have the capacity to learn:-)

 

I am assuming you have equipment to write the code, and program the pic?  You make the PCB or design and send to a factory to make?  G

Originally Posted by GGG:

Stan is there a website you recommend that I could read up on the pic approach, pcb manufacture, etc...  I don't have the background, but I think I have the capacity to learn:-)

 

GGG, I started with this in the last century so I don't know what's the modern way to learn.  I googled "getting started with Microchip PIC" and "getting started with PCB design" and got tons of relevant hits.  I see there are webinars, youtube videos, online forums, etc. - all things that didn't exist way back when.  This might be a good question for a new thread asking the guys who recently got into this what they used and worked for them. 

 

I am assuming you have equipment to write the code, and program the pic?  You make the PCB or design and send to a factory to make?

 

Right.  Most if not all uC chips that hobbyists would use now for this complexity of application can be programmed using low-cost tools.  In most cases the programming can be done with the Development Board that comes with a starter kit.  So out-of-pocket is well under $100.  For example, the kids at the local high-school robotics club bought the T.I. Launchpad development board for the 430 series uC chips for $4.30 and that included programming development software.

 

PCB is same way.  Some places give you "free" software to enter schematics and draw out the printed-wire board but then encodes the design data in a way that requires you to have them make the boards.  Other paid-for software allows you to have the boards made by any vendor.  Which is better depends on your circumstances.  To your point, in either case you send off an electronic design file and the boards come back in the mail in a few days.

 

Post

OGR Publishing, Inc., 1310 Eastside Centre Ct, Ste 6, Mountain Home, AR 72653
800-980-OGRR (6477)
www.ogaugerr.com

×
×
×
×
Link copied to your clipboard.
×
×