Skip to main content

Ted: That's great! So our starting point is something like this:

I think that will help to make this project a bit easier to implement.

But I think we need to clarify some operational details that I'm not sure I learned from the previous parts of this discussion. So let me ask some questions.

If a train is moving forward to begin with, the initial depression of the pedal will put it in neutral and it will stay that way until the pedal is released again. And if the train is initially in neutral, the first depression will put it either in forward or reverse depending on the part of the e-unit cycle that is currently engaged. There is no feedback on direction so we don't know what state the e-unit is in at the start. Do I have that correct?

Do you plan to have it in a known state to begin with? If starting in neutral, you can go forward or reverse as long as you hold the foot switch down. Let it up and the train returns to neutral. Is that the desired operating situation?

Also, will you need to be able to change the operating cycle to the opposite state? That is, if neutral is the normal starting state, will you need to be able to change it to the other way around; as in foot switch not depressed, train moving forward?

And remember, you only get one chance to create a good first depression.

Attachments

Images (1)
  • mceclip0
Last edited by Consolidated Leo

bi-slope breadboard

Here's a brute-force approach in action:

The normally-closed spring-loaded lever switch on the left is meant to simulate the pedal switch.  The circuit is powered by 5V DC.  The circuit drives a 5V DC relay module (about $1 on eBay, free shipping from Asia).  The COM and N.C. relay contacts would be used to drive the secondary circuit; the relay fires for about 0.2 sec when the pedal is pressed and again when released.  You can hear the relay firing or watch the red LED on the relay module turn on and off.

bi-slope timer with holdoff

This uses 3 garden-variety digital logic IC chips (maybe 25-50 cents each) and a dozen or so resistors/capacitors...so maybe $3 or so in parts including the 5V relay module.  The "trick" if anything is dealing with what I call the re-trigger holdoff requirement.  When pedal is pressed, the relay fires for 0.2 sec (settable by changing a resistor value).  But if the pedal is instantly released, you must wait some interval (settable by changing a resistor value) before firing the relay again.  This allows the secondary circuit to "digest" the first relay action so the subsequent relay action is recognized as a separate command.  This trigger holdoff is demonstrated in the video where the lever is quickly pressed/released.  The circuit queues up the release such that the second relay firing is delayed.  A related requirement is to inhibit multiple triggers which is shown in the video when quickly pressing/releasing the switch...yet only one pair of relay firings goes thru.

Going thru the circuit logic is tedious so I'll leave it at that and in any case it appears this is not an O-gauge train application (?).  There are some i's to dot and t's to cross if someone were to actually attempt to build this or commit to a PCB design from OshPark or wherever. 

This could be cobbled together using eBay $3 timer/relay modules and a handful of loose components (diodes, resistors, capacitors) but would be fairly bulky and run over $10.

Bottom line.  If an Arduino or similar is a viable option, that's what I recommend with this one! 

Attachments

Images (2)
  • bi-slope breadboard
  • bi-slope timer with holdoff
Last edited by stan2004

Correct.  Well, if you swap the resistor and capacitor, on power up the + supply provides the high logic level for the reset until the cap charges and holds it low from then on.

There's an issue with the simple R-C reset circuit wrt what happens when you instantly turn off power and you have this charged capacitor. Where does the capacitor discharge to?  For example, if you restore power too quickly (like in less than a second), that capacitor may not have discharged and hence there would be no reset.  But in practice, and to keep things simple, this should work for digital IC chips you'd buy today due to so-called input protection diodes that quickly and safely discharges the capacitor back into the power supply.

Last edited by stan2004

Wow Stan, that's amazing.  I'm not an EE and I've never built anything like this.  Is the white substrate called a "breadboard?"

In order to better describe the problem I started to depict a signal trace for the primary and secondary circuits showing the "on" and "off" in each as a square pulse from 0 to 1.  This got me thinking about the "resolution" of the system, i.e., minimum duration and re-trigger holdoff, etc.  It inspired this basic-like program which describes the logic/behavior I'm trying to achieve.

0010 REM A and B are variables representing the state of the footswitch.  Can be boolean or integer.

0020 REM there should also be global variables for the polling interval, relay open, and relay closed times.  Omitted for clarity.

0100 A = Poll(footswitch) : REM return value is either 0 or 1. Default state is closed so initially A=1

1000 REM ** Main routine **

1100 Wait 0.1 seconds : REM this time may need to be adjusted

1110 B = Poll(footswitch) : REM poll the footswitch again and store result in a different variable "B" the same type as "A"

1120 IF B=A THEN 1100 : REM no change detected in the state of the footswitch, so don't do anything with the relay.  Wait a little and poll again.

1200 REM Subroutine ** State of the footswitch has changed **

1210 A=B : REM update the stored reference variable with the "new" state of the footswitch

1220 Open the relay : REM relay is normally closed

1230 Wait 0.1 seconds : REM Keep it open for exactly 0.1 seconds to permit recognition by the target device.  (This time may need to be adjusted.)

1240 Close the Relay

1245 Wait 0.1 seconds: REM minimum time to keep the relay closed to permit acknowledgement by the target device (may need to be adjusted)

1250 GOTO 1110 : REM back to main routine- poll the footswitch again etc.

2000 END : REM note there is no exit from the loops and no returned value(s)

Obviously this is neither BASIC nor pseudocode, and I have no way to test the logic.  I'm just trying to describe to all of you what I want to happen.  Thanks for helping me puzzle through this!

For several years (before the Arduino phenomenon) DIY'ers routinely used BASIC-programmable microcontroller modules.  And I'm sure there's still a cadre of devotees still using them with great success.  IIRC one of the big players was Parallax with something like this:

basic stamp

So you'd apply some DC power.  Hook up to a terminal emulator program like Windows Hyperterm (or whatever it was called) and the 9-pin RS-232 serial port on a PC (before USB came along), and off you go.  In the example above, there is even the same white prototyping substrate or breadboarding area as you'd need to add a few discrete components to connect to the 5V relay module and the foot pedal.

But as I see it, your BASIC program as written would work just fine with my understanding of the application.  There would be some experimentation to adjust timing though I'd think some Parallax user group out there would have tips and tricks on how to use loops (FOR X=1 TO 100, NEXT X, or something like that if I remember BASIC!) or other programming constructs to achieve tune-able delays.  Then it's just a matter of how the Parallax BASIC implementation handles INPUT and OUTPUT to drive or read the level of the input and output signals at the breadboard area.

I was just looking and it appears there's been some activity in the Arduino community to implement BASIC though it appears it's more for curiosity sake than a practical solution for everyday use.

If this is a one-and-done project, and reading between the lines on your comfort zone, I don't think the discrete logic IC circuit I showed is the way to go - lots of wiring/soldering etc.  If you already have a Parallax BASIC Stamp and have used it, I'd think that would be the closest exit.  Otherwise it looks fairly spendy to buy one.  Hard to say if it's worth the investment in time (more so than $) if you've never touched or studied the Arduino approach. 

As I mentioned in a previous post, another approach is to use some TBD combination of eBay timer-relay and/or latching-relay modules and assemble them Lego like. 

relay modules

That is, you need 1 time-interval when pressing and releasing and a 2nd time-interval to delay multiple triggers so that the secondary circuit has time to recognize successive triggers.  Hence I'd think 2 timer relay modules.  Then to remember which state you're in to detect changes in the pedal, you need a 1-bit memory (e.g., a latching relay).  It might appear like a Rube Goldberg contraption but would minimize component-level assembly/soldering...and no writing Arduino code, BASIC, or what have you.  I'd think something between $10-$20 out-of-pocket if willing to wait on Asia eBay sellers.

Attachments

Images (2)
  • basic stamp
  • relay modules

Thanks Stan.  All of these solutions are out of my comfort zone, that's why I asked for help.  I know how to program in BASIC and have some experience in other languages.  But NOTHING with systems-on-a-chip like Basic Stamp, Arduino, Raspberry Pi, etc.  The cost of the Basic Stamp doesn't bother me, I was prepared to spend up to $200 to obtain a complete working device.  But where do you get an RS-232 interface these days, and what kind of software would you use to communicate through it?  Another thing I'm concerned about is the breadboard part where you wrote "a few resistors and capacitors."  That isn't too specific, and I wouldn't know where to begin.

Re: the modules, I don't care if the solution is "Rube Goldberg-esque" as long as it works.  I'll look into the ones you depicted in your post.  They're not expensive, but i'm still not sure how to hook them together, or whether they'll really do what I need.  Is the "bistable MCU" a one-bit storage system for the state of the footswitch in my example?  I'm not an EE so all of these terms are foreign to me.

I can't be the only one who has ever needed to lock and unlock a "latching" target circuit with a momentary pulse.  I guess when I posted, I was hoping that a circuit like this was commercially available.

Last edited by Ted S
Ted S posted:

... I was prepared to spend up to$200 to obtain a complete working device. 

I'm surprised you haven't been contacted by someone via private-email or whatever!  An Arduino aficianado ought to be able to whip this up (the programming part) in less than an hour.  The hardware would be maybe $10 for an Arduino module, a wall-wart DC power supply, and a few discrete components/connectors.

...But where do you get an RS-232 interface these days, and what kind of software would you use to communicate through it? 

There is an abundance of USB-to-RS-232 converter cables, dongles, or what have you for next to nothing.  Then you'd use a "terminal emulator" program.  I see that Hyperterm is no longer available for Windows 10 but there are "free" alternatives.  So when launching the Terminal Emulator program, it should allow you to set the "baud rate" of the adapter cable, then hit Carriage Return a couple of times and you should be talking to the BASIC command-line interpreter!

usb to db9 rs232 adapter cable

...Another thing I'm concerned about is the breadboard part where you wrote "a few resistors and capacitors."  That isn't too specific, and I wouldn't know where to begin.

Right.  It's just that these digital/microcomputer chips are electrically "fragile".  When attaching them to the real world like a foot-pedal switch with several feet of cable or what have you, you need to give some thought to protection from glitches, spikes, noise, and other nastiness.  Likewise, the digital signal are generally not robust enough to drive a relay which (as I understand it) you need to momentarily "open" the secondary circuit.  Hence, I suspect you'd need to add some "stuff".  But you're correct that this would need additional clarification albeit the actual cost would be modest - $1 or $2. 

...Is the "bistable MCU" a one-bit storage system for the state of the footswitch in my example?  I'm not an EE so all of these terms are foreign to me.

Right.  In the same way that you use the variables A and B in your BASIC program, you need memory to know which state you're in so that you know what to look for to interpret a change of state.

...I can't be the only one who has ever needed to lock and unlock a "latching" target circuit with a momentary pulse.  I guess when I posted, I was hoping that a circuit like this was commercially available.

Upon further reflection, I think the general concept has several applications in O-gauge trains.  I was thinking about some earlier OGR threads about things like two trains or trolleys that alternate running on the main loop and benefit from time-delays to make the action more realistic.

OK, while I still think the Arduino approach is the way to go, I'm assuming this is not in the cards.

Stand by - I ought to be able to cobble together some kind of relay/timer module concoction that does not require assembling and soldering a bucket of tiny electronic components.

Attachments

Images (1)
  • usb to db9 rs232 adapter cable
stan2004 posted:
to drive a relay which (as I understand it) you need to momentarily "open" the secondary circuit. 

I don't have the experience to say whether a relay is necessary or not.  I think you or someone on this thread suggested it and it sounds reasonable.  But, yes, the idea is that the secondary circuit (which is normally closed) opens briefly for a short but consistent window, and then closes again.

I bought a surplus SPDT footswitch and experimented by pressing it very slowly.  Unfortunately the one I bought is a common make-make switch, and what I need is a break-then-make "slow action" switch.  Even then, the duration of the open "window" would depend on how quickly the user pressed the switch down.  And it's very possible that if the switch were pressed or released rapidly, the window wouldn't remain open long enough to be recognized by the target device.  That's why I believe some type of timer circuit is needed, to ensure consistent operation.  Using a software approach also provides the needed adjustability.  Otherwise I suppose you would have to swap capacitors, resistors, etc., on a trial-and-error basis.

Really appreciate the help.  If I were to approach the engineering or computer science department at a local community college, do you suppose the dean could point me to an enterprising senior or grad student, who could build something like this for a fee?

Back in the 80s. I did. I had a question. Sent it to the college electronic dept. 

The instructor gave it to a student. Who called me and explained. Things. It was something for my Xmas train layout.

Now days. Who knows. The way things  are. Most students want the challenge. It's up to the instructor I would say. Unless. Now it has to go by way of the president.  Cause of possible liability.

Last edited by riki

So here is a potential starting point (to be clear this is NOT ready-for-primetime!) if pursuing the modular approach using modular relays.  This would be a compromise between the discrete electronic component approach and a programmable microcontroller (Arduino, Basic Stamp, etc.).

bislope relays

dual slope trigger with holdoff using ebay relay modules

In addition to the 2 relays modules from before, this used a generic basic 12V relay module and 1 garden variety 5-cent diode.

12v relay module

 And here it is in action:

As with the discrete component approach, it is too tedious to explain every signal connection.  The idea here is to simply present the eBay relay module approach which in this case does not involve soldering or handling a fistful of tiny electronic components.  As before the raw material cost would be under $10 if purchased from eBay/Asia.

Given your self-proclaimed comfort-zone, like the discrete component approach, I do NOT recommend you try this at home either!  

But I like your idea of approaching an educational institution.  For example, this would make a nice senior project if the student implemented several of the approaches with cost analysis, pros/cons, etc.  Or even if students are not allowed to operate soldering irons or touch electrical circuits because of liability or whatever, they ought to be able to simulate one or more methods and provide you with a high degree of confidence that it would work if physically built. 

Or, perhaps some clever mechanical engineering student could dream up a non-electrical solution where the foot-pedal is modified with some springs, cams, dashpots, or what have you to generate the 0.2 sec open circuit events when the pedal is pressed and again when released!

Attachments

Images (3)
  • bislope relays
  • dual slope trigger with holdoff using ebay relay modules
  • 12v relay module
Last edited by stan2004

Add Reply

Post

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

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