Skip to main content

Originally that engine (an early 2000s rs-3) only had a single powered truck. But I’ve collected a lot of spare parts, so it now has two powered trucks.

Now, with some conventional locos I’ve modified to have dual powered trucks, I’ve been able to get better low speed performance and torque by running the 2 can motors in series. But I haven’t been able to get that to work when they’re hooked up to one of these PWM motor controllers. If they’re in series, only one of them will turn. So I have to run them in parallel.

Last edited by jwetzel1492

@jwetzel1492 - For your speed control, did you add any acceleration limit?  That is to say, if you chose 45 mph right off the bat, did you target "45 mph" on the motors immediately (via PID)?  I know MTH has a constant acceleration limit but I was thinking of something more meaningful that would simulate less acceleration at low speeds. (ds/dt = f(s)) instead of (ds/dt = c) or even (ds/dt = f(t));  Unfortunately, my desired customizable f(s) doesn't have a closed form integral solution unless I can come up with something along the lines of (ds/dt = 1/f(s)) so that (f(s)ds = dt).

Anthony

@A. Wells - In my code, there are 2 systems before we get to actually controlling the motor speed:

1. Control Model
2. PID Controller

Control Model Inputs:
- Throttle
- Reverser
- Brake

Control Model Outputs:
- Engine RPMs (which is used by my sound algorithm)
- Desired Wheel RPMs
- Smoke percentage

PID Inputs:
- Desired Wheel RPMs
- Measured Wheel RPMs

PID Outputs:
- Speed value that is sent to the motor driver

I've implemented a couple different "Control Models".  The simplest is the ToyControlModel.  It only uses the Throttle and Reverser, and the Engine RPMs and DesiredWheelRPMs are just linear with respect to Throttle.  It's just like using a conventional transformer.  (Except that it goes through the PID controller too, so there's speed control, and the PID takes care of the non-linearity of the motor driver and can motors.)  The PID does smooth out the acceleration, but it can still make pretty quick changes in speed.

But I've also implemented a SimulatorControlModel.  While I've never driven a real locomotive, I have some experience with Train Simulator, and a background in physics.  So the SimulatorControlModel tries to model some of the hardware inside a real locomotive, as well as some of the physics.  So it's modeling:
- Rate for the prime mover to spin up
- reverser and how much power the traction motors can deliver
- braking
- rolling resistance
- air resistance
- how much smoke should be generated for a given engine rpm

I'm learning as I go and I'm sure some of my equations aren't perfect, but I'm trying to get it to generally behave like a real train.

Last edited by jwetzel1492

@jwetzel1492

That's way outside of my league! I'm approaching the movement from an aesthetics point of view...not whether it models the physical motion aspects of a real train.  My patience would be gone in a matter of a few minutes if I was to take on that task.

I have previous motion control work where I just use a time based S curve for motor control (start point, stop point) which worked surprisingly well even with an 8 bit microcontroller.  As mentioned earlier, I introduced feedback based on the current speed of the locomotive.  I've since modified the concept and introduced time into the feedback: (ds/dt = f(s,t) or ds/dt = f(s)g(t)).  In my case, g(t) is a constant c which is the number of times per second I update the motor speed.  So, once again, I'm off the hook on any elaborate separation of variable or partial integration.  I may not have mentioned f(s) is a cubic bezier curve (aka polynomials).  This allows me to update the curve to my hearts content based only on four points.  Quick changes in speed only happen at higher speeds in my logic and the maximum speed change is also limited.  (This may have to be adjusted for negative speed changes.)

I have three speeds that I track: actual speed, current target speed, final target speed.  On paper, I have made notes to use any difference between the actual speed and the target speed to induce labor/drift sound and, like you, to use the actual speed for rpm.  (I have no plans to introduce sound into the system any time soon.)

The one thing that concerned me with your set-up is that you only have 4 detents/indexes per axial revolution.  Doesn't this result in jerking at low speed?

Anthony

@A. Wells The 4 detents per rev hasn't been a big issue.  At it's slowest, my engine axles are doing about 90 rpms.  So a magnet goes past my Hall detector about every 160ms.  And I run a low-pass filter over the measured rpms before using them.  If the train is on straight track, the measured rpms stay pretty close to constant.

My biggest issue right now is I'm stretching the limits of the gearing/traction of these particular powered trucks.  I'd love to run even slower, but then bends in the track or other random friction can cause the can motors to come to a halt.  (And faster than even a PID can compensate for.)

One of my next projects is to put my boards in an RMT Beep.  The low-speed gearing on those is spectacular.  (But I'll have to do some miniaturization on my protoboard.  Very limited space inside a Beep.  I might not be able to fit a tachometer inside a Beep either.  But again, their low gearing might make a PID controller unnecessary.)

Update:  I finished miniaturizing my circuits.  Had some custom PCBs made (by jlcpcb.com) and got everything tucked into the body shell nicely.

Here's a video of my first run with everything 100% functional.  My son was cracking me up with his reactions to it.  

Major features:

- Controllable over WiFi
- Tachometer and speed control
- Smoke system
- LED directional lights
- Digital sounds

The speed control does a really good job of keeping constant speed on curves and up the hills. It speeds up a bit going down my 4% grade hill though. The controller/motor are getting set down to the minimum possible power that won't stop the engine, but even at that amount, gravity takes over and causes some acceleration. If I let the PID controller go any lower, it would jerk to a stop though. The only real solution would be lower gears in the trucks.

I'm releasing the firmware open-source: https://github.com/joelwetzel/MQTT-Locomotive I don't expect anyone else to ever build one - it's quite a project - but if anyone is curious... have fun! I'll probably post the PCB and wiring diagrams at some point too.

Last edited by jwetzel1492

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