20v motor shield for Arduino Nano

For my next adventure, I need a motor shield for an Arduino Nano. Building a DIY “programming” kit for my trains.

I have a couple of Arduino Nanos around the house. The other key components are a motor shield and a power supply for the motor shield. The trick here is that we don’t control the motor speed. Rather, we flip the direction pin at around 8kHz to create a frequency modulated square wave. This provides both signal and (once rectified) power to the trains.

The motor shield needs to be able to provide an output supply of 18-24v (ideally 20+), with preferably up to a couple of A current. If I were using this to drive the fully layout I’d need about 5-6A, but this is for programming only.

Can someone recommend a suitable motor shield and power supply? Searching “Motor shield” gave me 20 or so options, and I’m not sure the best way to cull them down.

Thanks

5 Likes

Two potential motor drivers within your desired range, 18 to 24V, 5 to 6A.
But …

Flipping direction at 8kHz, unsure how the motor driver would react to being driven like that at 5 to 6A. These motor drivers are not really designed for such a rapid change in direction and constant operation. Driving a DC motor in one direction using PWM to control motor speed is what they are designed to do. Changing direction now and then. Also some off time for the drive to allow the heat sink to cool down.

Possible what you need is a simple high voltage and current variable frequency square wave generator.

Anyway, dealing with those current and voltage levels requires careful planning.

Cheers
Jim

PS You may find they work ok doing what you want.

Needs heat sink for high current level.

7 Likes

Hey James and Andrew,

Excellent, there are a few drivers that may do the trick for your project. The links James added above for you should kick out the necessary power matching those specs (at high current they do tend to get quite warm however, although a beefy heatsink or fan should help keep them cool).

Given you’ve mentioned a direction pin using PWM, I suspect that you’re using some continuous rotation servo motors for your model train set up? If so, do you have the motor’s name or a link to it available? Should help give us a better idea of which driver would best suit in this case.

4 Likes

Thanks guys. I’ll take a look.

In terms of what I’m doing, the motor controller part of the project is described here. The square wave is for control signalling - it gets turned back into something plain variable-voltage DC before the motors see it.

Two key differences:

  • I’m running “G scale” rather than “HO” or “N” scale, so the system runs at 20-24v rather than 12v.
  • I primarily want this for the “programming track”, so can handle fewer amps. HO/N programming tracks often run at around 250mA. I need more headroom in case I’m testing lights, sound, etc, but I don’t need to power the motors more than a little. Peak 2A would be plenty.
5 Likes

Hey Andrew,

Ah yes, I see what you mean. Some high-value caps on your output to smooth out the voltage a bit may help keep your motors a little quieter and smoother. Although at a high frequency and with decent drivers it shouldn’t be an issue.

4 Likes

Hi Andrew,

Is there any reason you are opting for that method instead of the standard DIR toggle and PWM pins?

One of the failure modes I spotted: If the smoothing capacitor fails then any inertia attached to the motor will cause the current to increase A TON, pulling the stall current of the motor, potentially burning it out.

James has some excellent recommendations, but if you want to narrow them down yourself, grab the voltage level your motors operate at - add about 50% for fudge factor and back EMF, current is based on the stall current - going over is always good here as well. Then there are some features on top of that, switching frequency, current sensing capability, sleep modes to name a few

4 Likes

I like their wording, “in a clever misapplication of technology”. My concern about switching the direction at 8kHz is probably unfounded. Just never seen this type of application before, pretty clever.

If you only need a few amps there are many motor drivers that will work nicely, maybe not up to 20V. You really should have one with specs up to 30V to be safe. The back EMF could fry a driver board so, as they say, current sense is a must. Unsure if the boards I listed are suitable in that respect.

Hope your project is successful
Cheers
Jim

5 Likes

Again, thanks for your guidance.

Note that I’m not (strictly speaking) using the motor shield to drive a motor. The motor shield is being used to create a 8-10kHz square wave that is used to carry signal to “locomotive decoders”. However, the locomotive decoders do tap the square wave for power outputs for motors and other peripherals.

I already have a solution to power the main track; this is for a lightweight solution for a “programming track” (so I can have it permanently set up without carrying my main box back and forth between the layout & my computer). This means the current requirements are much lower (because I’m not driving trains, and only ever powering a single locomotive), but the motor shield must have a functioning current sensor. The current sensor is required because the back channel (from decoder to controller) is implemented by the decoder “pulsing” the locomotive motor - the controller reads the current fluctuations as signal.

7 Likes

So, with a clearer idea, I went looking to see what Core Electronics has to offer and compared it with the list:

6 Likes

Apparently one can pull this off with the standard motor shield (despite the “low” voltage), so I’m planning to try one of these and see how I go.

2 Likes

Hi Andrew
Correct me if I am wrong. The way I see it you want an AC signal as opposed to a one way PWM pulse right ???. I don’t think you need a motor shield. If you generate the required square wave then feed it into a power amplifier then to whatever you are going to use it on via a capacitor you will have an AC signal. That is it will swing above and below 0V. The capacitor will remove any DC component.

If you are going to rectify this square wave you will need schottky diodes as the components of the square wave will go well above the 8kHz fundamental and “ordinary” power diodes will be too slow and useless.
Cheers Bob

3 Likes

Hi All,

This DCC control idea is very novel. I found a couple of great pages that explains it much more clearly:

http://www.circuitous.ca/DCCvolts.html

In short, each rail has a square wave 180° out of phase with the other. This means the loco (theoretically) has full power available all the time, as there is always X volts between the rails. The encoded data is interpreted by a microncontroller (on board the loco), and the power from the rails is rectified and filtered on board the model loco. The microcontroller and rectifier combination make up a ‘DCC Decoder’.

The data is encoded in the time domain by varying the pulse width, as a differential signal:


Channels 1 and 2 in the images above are connected to a rail each. Because the signal is differential, and encoded in the time domain, rather than as the voltage, the data can be decoded independent of the direction a loco is facing on the track (ie, it doesn’t matter which channel is channel 1 and which is channel 2).

In order to do this, Andrew does not require the PWM features of a motor controller. He just needs to set it to full power/speed, and toggle the DIR pin. Any motor controller capable of at least 10kHz PWM should be capable of switching fast enough, and if anything, it might even be capable of handling more power when used this way as the load is being shared evenly across the mosfets rather than only on a single pair.

4 Likes

Now that I understand DCC a bit better, I’m not sure you need a motor shield at all for what you’re doing, at least not at this stage.

The motor shield is the ‘DCC Booster’. The Arduino is your ‘DCC Command Station’. I think you’re just trying to implement a ‘DCC Command Station’ at this stage? In this case, you probably don’t need anything more than your Arduino Nano for now.

If you do indeed need a booster, I reckon this one might be a good option too:

3 Likes

Hi All
AHHH. I think I can see what Andrew is up to. The term AC had me a bit fooled. It does not seem to be an AC signal at all but DC pulses to each track alternately which I supposed could be loosely termed AC but nothing ever goes negative WRT ground.

Rectification would be pretty simple. One diode from each track to a central point referenced to supply ground. Minimal filtering required at 8kHz and being mostly a square wave you only have to make up the small gap between rectified pulses so a couple of µF would probably do it.

The remarks about schottky diodes as mentioned above still stand.
Cheers Bob

6 Likes

I haven’t seen a decent block diagram for a basic DCC system anywhere, so I did one up, as best I understand it.

This is a schematic of about the simplest DCC system possible.

6 Likes

That’s roughly correct.

Note that “large scale” trains - which usually means 1:25 - 1:32 scale running on 45mm gauge track, often outdoors - are typically driven at around 20V (between 18V and 24V). Indoor layouts, such as HO and N, typically use 12V.

A “programming track” is a special track section with two notable characteristics:

  • currents involved are usually a lot lower than on a “main track”, as the track is used for setting “configuration variables” on the loco rather than driving trains.
  • the command station / booster needs a mechanism that will allow it to read variations in current draw on the programming track. The DCC decoder supports reading CV values by rapidly pulsing the motor. These current fluctuations are detected by the booster (and command station) and turned into data.

As I’m basically trying to create a cheap programming system, current sense is more important than overall power output. For main layout use, current sense would not be needed (except for short circuit detection) but overall power output would matter. Many G scale locos can pull over 1A per motor, plus extra for lights & sound.

5 Likes