Rev counter with JRK controllers

I’m going to be doing a hobby project of putting r-pi’s in G scale locomotives to automate running my garden railroad.

Locomotives have 1-4 motors in them (usually 2 or 4 motors) which go up to 18v and .7 amps per motor (so up to 2.8 amps in one locomotive without hitting stall current which can of course be much higher current requirement).

First is there any reason one speed controller couldn’t be used to run 4 motors at once (I’m pretty certain the answer is no but just want to check with others who might have experience)

Second question is there any way using either the jrk or jrk’s with feedback (via usb control) to know how many rpm’s the motors are running or get controller stats (voltage or something else) that could help me determine the speed the locomotive is moving? From what I can tell the jrk’s don’t support bemf at all let alone being able to use one motor controller to get bemf on up to 4 motors on the same circuit.


Hello, Brandon.

The jrk 21v3 would have trouble running your motors because it can only provide 3 A continuously and you would very close to that limit. It would probably be better to use two or four jrk 21v3s, or if you are able to power your motors from a voltage lower voltage instead of 18 V, you could use one jrk 12v12.

If you can attach a tachometer or encoder to one of your motors that produces a square wave where the frequency is correlated to the motor’s speed, then you could use the jrk’s frequency feedback mode. This mode will allow your system to know how fast the train is moving, but it will also change the behavior of the jrk so that the jrk always tries to maintain the target speed that you set. For example, when the train goes up a hill the jrk will supply more power to the motors to maintain the speed. Maybe you would want that. The speed can be changed on the fly by sending Set Target commands to the jrk.

If that’s the route you want to go, let me know and I can give you advice on choosing the right tachometer.

Unfortunately, we don’t sell any controllers that support back EMF.


Hi David, Thanks for the quick reply.

What is a safe max continuous current that should be used with the 2jrk 21v3’s and would a heat sink add much if any headroom? Also does one not have to worry about stall current going over this limit due to overload protection on the jrk’s?

I have been looking at a sort of tachometer/rev counter for location awareness (I have placed waterproof rfid tags every ~ 10’ under the tracks and the locomotives have rfid readers under their belly – I’ve already solved this step on a test track and it works perfectly) but I did want higher accuracy so I had been looking at ways of measuring this either by a laser diode to count rail ties or an axle counter (though adding any sort of hardware to the axle in the locomotives would be quite difficult to do based on the way the gear boxes are done). If there’s some sort of encoder that can be placed in-line with the dc motors that can somehow detect when a motor(s) make a full rotation that would be perfect, though I wasn’t aware of something that did that, isn’t that along the lines of bemf (that’s just outside my knowledge level)?

For constant speed that’s not bad to have as an option but locomotives don’t operate like that in the real world, but that might be useful for very slow movement of the locomotives that can be hard to find that ‘sweet spot’ for 1-2mph movement.

I do have about 30 locomotives I’ll be converting to r-pi and this setup so the least amount of ‘custom work’ in the gearboxes for trying to attach a sensor onto worm gears or something else would be the most ideal setup. If there’s some black box encoder that does the trick to count motor rotations and works with a jrk that would be perfect. Second best would something that the r-pi can read back (there’s plenty of gpio pins on the r-pi) and I could go with simple jrk’s that offer more max voltage and current and write the software on the r-pi to adjust the jrk accordingly.



The maximum continuous current that a single jrk 21v3 can provide is about 3 A. The motor driver we use on there has a max of 5 A, so heat sinking can help you get toward that limit, but we haven’t characterized how close you can get. Anecdotally, we have seen customers use the jrk 21v3 for higher current applications without heat sinking and not have problems, so the internal protection on the MC33926 seems to be pretty good. Therefore, as long as you don’t grossly exceed the limits you can gradually test the jrk and see how much you can get out of it.

Measuring back EMF and using encoders are two very different things. To set up an encoder, you need additional hardware that can sense the rotation of the motor. To set up back EMF, you need a more advanced circuit for driving the motor. Here are some examples of encoders:

What is r-pi? Is it raspberry pi?


Yes, r-pi = raspberry-pi.

I see what you mean now by encoders, I was thinking you meant more digital based encoders that would sit between the speed controller and motor(s) and do something like bemf. I’m not sure I could find a way to attach a physical encoder to the motor mounts. I re-examined some locomotives and a few do have axles that stick out of the motor blocks but most models don’t and there isn’t anywhere I could add a pot or encoder to the axle inside of the blocks without a lot of trouble.

I did a quick look for some sort of inline bemf circuit but I didn’t have luck in the short time I was looking.

Knowing that a physical encoder would give the most accurate results, bemf a bit less accurate, and just knowing the voltage I’d set a simple jrk to, does the simple jrk give any sort of feedback like current use or voltage that would give me any vague idea what the speed controller is doing? This of course would be the ‘least reliable’ method but I could always place rfid tags 1’ apart and use that more for knowing speed if a simple jrk or jrk with feedback could indicate if the motor is spinning at all or stalled out. If it gave a fuzzy stat on motion, even if not accurate, that would be enough for me if I don’t have to custom modify 30+ locomotives for adding encoders.

Thanks again for your time and knowledge.

Yes, the jrk can give you a measurement of the current the motors are drawing, but not the motor power supply voltage.


Current feedback is only on the feedback model correct? Does the simple controller give any stats about motor(s) power consumption or any other motor stats?

We have two models of jrks: the Pololu Jrk 12v12 USB Motor Controller with Feedback and the Pololu Jrk 12v12 USB Motor Controller with Feedback. As the names imply, both models support feedback (analog or tachometer). Both models also support a simpler mode (Feedback Mode = None) where you can control the duty cycle of the motor and the jrk doesn’t have any concept of “Feedback” and doesn’t do PID calculations. In either of these modes, the jrk can report the current the motor is drawing, but please note that it isn’t very accurate for currents that are only a few hundreds of milliamps.