Skip to main content

I'm in the design and testing process of completely changing my postwar controls to arduino control. Accessories and switches I have figured out, but the throttle is giving me some trouble.

So my question is, what's the easiest way to go about using the PWM function of the board to control the variable voltage? I've looked at some IC-based voltage controllers but inverter styles seem to be few and far between. Or is there another easier way, and I'm just overthinking things?

Original Post

Replies sorted oldest to newest

For AC power control you probably want to use a triac.  You will need to detect the zero phase crossing of the AC signal to know when to fire the triac.  Here is an example of how to do it, although the example is for 120V AC power.

This will be a much easier project if you have a basic oscilloscope, so you can see the AC waveform and whether you're timing the triac control pulses correctly.

A more off-the-shelf solution would be to get a TMCC or Legacy system with a Powermaster, and control the Powermaster with serial commands sent from the Arduino to the command base.

Last edited by Professor Chaos
Jon1443 posted:

...

So my question is, what's the easiest way to go about using the PWM function of the board to control the variable voltage? 

No doubt someone in the Arduino community has worked this out, but if using the triac method as described in the link from the Professor you need to synchronize the "PWM function" to the 60 Hz line frequency.  If by throttle you also mean to support Whistle/Bell, the arguably easiest method is to fire the positive and negative polarities at different times - again synchronized to the 60 Hz zero-crossings.

The CW-80 schematics have been posted many times on OGR so that would show you the hardware side of the triac method driven by a microcontroller (though obviously not an Arduino microcontroller).  But if you're going to do the homework to design an Arduino-controlled throttle circuit, consider how MTH uses 4 FETs (10-cent transistors) instead of a triac in their TIU for the variable channels.  That is, the 4-FET configuration has more flexibility in when/how you turn the voltage on and off in each 60 Hz cycle.  It would be much software than the triac method and you won't find any published schematics of the TIU variable channel - but hardware concept is generic.  Just depends on whether someone else in the Arduino community has already done the homework and posted the how to.  Again, it comes down to expediency vs. building a better mousetrap.  That is, the 4-FET (or its cousins) would be the basis for something akin to the Z-4000 with a smooth sine output rather than chopped/ugly voltage signal from a triac controller.

I get laughed off the stage whenever I show this but I suggest it is food for thought.  If you already have an MTH Z-controller (which is a triac-based throttle with whistle/bell), how about an Arduino driving two 99-cent servos.  As you know there are servo functions in the Arduino library that use PWM outputs making the software trivial.  Here are two videos demonstrating the concept.  There's a bit more info on this hack in the O gauge archive here.

Throttle control:

Bell/whistle control:

99-cent eBay servo (free shipping from Asia):

Untitled

 

 

Attachments

Images (1)
  • Untitled

Ahh.  I like where you're going with this! 

So for the throttle portion you could indeed use a digital pot though this would mean solder re-work on the Z-controller circuit board.  I'm also imagining an opto-isolator might be involved to provide electrical isolation between the Arduino power supply and the Z-controller power supply.  That is, I'd have to do some homework to see if the electrical DC "ground" of the Z-controller is the same as an external Arduino.

Likewise, for the bell, whistle, and direction buttons, it might be as "easy" as an opto-coupler (with transistor output) since I'd think the Z-controller buttons are simply momentary pull-down switches.  So these could be controlled by any Arduino digital output.

Your method would still be just a few bucks in parts without the mechanical nuisance of mating the servos to the physical buttons/knobs of the Z-controller.

While rolling-your-own triac circuit seems simple in theory, there are i's to dot and t's to cross that I don't recommend to the weekend DIY'er.  So there are (at least) two inexpensive approaches to mating an Arduino to an off-the-shelf triac controller.

 

I'm amazed at the timing of this thread!

Just started doing some research on controlling the Z-1000 pot.  I've alrady opened the Z and can contribute that the 3 buttons (red,yellow,white) are all simple pushbuttons connected with a common ground.

I had thought about buying an arduino-controlled pot to replace the existing rotary pot... just need to extend the 3 pot wires to an external pot.... But that's where I'm not sure what is required!

My design would be to have speed-up and speed-down buttons connected as inputs to the arduino and a digital pot to replace the rotary pot in the Z.

I should have measured the value of the pot while I had the Z open, but forgot!  You have to unsolder the 3 pot wires to separate the boards to get to the PB pins on the circuit board.

Anxiously awaiting the next post.  PROF, I'm hoping for a suggestion on an android controlled pot!

 

Last edited by eddiem

I get laughed off the stage whenever I show this but I suggest it is food for thought.

Stan: The only reason people laugh at your idea about using servos to control the Z transformer is because it's so darn clever.

I don't know what got you to try this; most mechanical rigging is beyond the abilities of most of us mental midgets. But you put in the time and effort to match up the things that don't necessarily want to work well together and got it done! That's remarkable!

This is an interesting topic and now that we're down to eliminating the mechanical aspects of variable voltage control, I want to hear more.

Last edited by Consolidated Leo

The OP mentioned using the PWM outputs of the Arduino to drive the variation of voltage for his train layout.

I have been interested in the videos that are produced by Julian Ilett from the United Kingdom and a particular project of his called the Muppet 2. It has to do with driving 4 Mosfets in a particular arrangement that I don't fully understand but it sounds like it may be relevant.

 Here is a YouTube video that explains a part of what he is up to. There are more of these on his channel relating to the Muppet 2 project, buck converters, etc. Mosfets!

So with the likely demise of tmcc and dcs ..

 

I post this:

https://circuitdigest.com/micr...ng-arduino-and-triac

a fan is very similar to the ac motors in older flyer and Lionel trains.

using a 3 dollar pwm, you can control any can motor. Add a 2 dollar bluetooth , you’ll have a  Bluetooth controlled train . Everyone of your locos can have a separate IP address - You can get Arduino nano boards for $6. Don’t forget you may need a regulator to get the 3.3vdc the nano uses ( as opposed to the 5vdc).

Ive been kicking going this direction as for about 20 bucks ( maybe 40, ifyou don’t buy cheap eBay clones) you can covert a loco to become Bluetooth wireless controlled. You can also add sound , so a mp3 gets played for certain actions. 

 

 

 

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.
×
×