skip to main content
Historic District, Mount Dora, FL
Fitting controller to case

PWM Motor Control Using Cytron Full H-Bridge

This is the original WiFi Motor Controller our son, Nick, put together for his Lionel trains. Well, it's not exactly the original any longer, but it was his gadget before we put it to work on the Barkyard. The one issue that remained unresolved was the current sensing. It uses a hall effect type sensor, immediately of interest because it doesn't require a "shunt" resistor in series with the motor to "sense" the current.

There are a number of sensors in that same family, differing based on the maximum current sensed. There are three current ranges available - five, twenty, and thirty amps. The biggest advantage of using a hall effect sensor is there is neglible voltage drop across the device. Every other means of sensing current places a discrete component in the current path, and that produces a voltage drop that can be measured. Unfortunately, it's that very same voltage drop that also wastes power, and a lot of it depending on the component(s) used.

In any case, the issue isn't with the power the sensor consumes, but with its erratic behavior. It returns seemingly random values, or rather, sampling its voltage output provides what amounts to random values. Is it because we're sensing less than a tenth the current the 30A sensor is rated for? Nope. Same results using the 5A sensor. What could be causing it?

More time was spent trying to analyze and solve the problem than it was worth at the time. Analog meters still work, the only issue is directionality. In other words, the meters have to go inline before the H-Bridge. They read just fine that way. The current reading is not quite zero though, registering the quiescent draw of the H-bridge itself. In operation, the ammeter reads the sum of the motor current plus the H-bridge demands. A small price to pay for accurate readings.

Over time it was discovered that lower PWM frequencies caused unusually large currents at low speeds, drawing nearly full throttle current! The current would actually drop toward mid range speeds, then increase again as the speed approached full throttle. This seemed rather strange, and was accompanied by an annoying buzzing (think power cycle hum). Increasing the PWM frequency just made the buzzing more annoying, becoming an unbearable audio tone in the 2500Hz to 8000Hz range.

Beyond that, the annoying "audio" seemed to diminish, perhaps due to the inductance of the motor acting as a choke. Higher PWM frequencies did resolve the unusual current issue though. Unfortunately, the directional lighting became ineffective the higher the frequency went, so no happy medium was found. That's more annoying than the unbearable audio. No lights until full throttle is a step in the wrong direction.

What's causing it? Is it the Cytron H-Bridge itself? Is using PWM itself the culprit? Time to order some different H-Bridge component to make a determination. Since modifications had to be made to the original Arduino sketch to allow changing the PWM frequency at run time, more effort was directed toward troubleshooting the hall effect current sensing. There was time while waiting for the new H-Bridge units to arrive. Current readings, updated every tenth of a second, are reported via the user interface.

Another issue is the analog to digital converter onboard the Arduino is only capable of reading a voltage range from 0V to 3.3V, but the sensor output range is 0V to 5V. Looking at the graphs of output voltage in relation to current sensed, the output is linear about 2.5V, swinging ±1V at full scale. Our power supply is limited to 3A max, so that should yield ~3.1V, which falls within the maximum 3.3V input range.

It yields a rather "lopsided" set of data however. No current output of 2.5V yields a value of 776 when sampled at 10 bits. The actual output seems to float between 2.5V and 2.6V, yielding values in the range of 776 to 806. Just to throw another wrench in the works, the sampled value will increase or decrease with increasing current, depending on the direction of current flow and how the sensor is connected. That's probably a bit too much detail, but helps to explain some of the confusion in readings.

Our next controller designs employ and test the operation of a number of different H-Bridge components available. The gamut ranges from barely able to handle the required current to way overkill at 43A! Follow along with the next step in our motor controller evolution.
See More...

News
October 25, 2025
July 15, 2025
June 21, 2025

Join our newsletter!

There was a problem with your submission. Please correct the issues below