Adapting a DC motor controller to use a Hall sensor

Last week, I wrote about a DC motor controller I was modifying to work for a project of mine. The last step I needed to perform for full implementation was to adapt the signal from my Hall effect throttle sensor to the expected range that the stock potentiometer would give.

Hall effect sensors are sensors which output a signal that varies depending on the magnetic field it is currently experiencing. As a completely non-mechanical solution, this leads to increased durability and reliability in sensors that move frequently. However, the range of output voltage is typically from 0.8 volts to 4.2 volts (assuming a 5 volt supply). Put simply, the output voltage moves between 0.8 and 4.2 volts depending on how close it is to a magnet.

The problem I faced was simple on the surface, but required a more complex solution. As the motor driver was designed for a potentiometer, it expected the full range of input signals from 0 to 5 volts. As a result of this, there was a significant mismatch between what I wanted and what the motor driver thought I wanted. When the throttle was completely closed, it sent a signal of 0.8 volts, which the motor driver then interpreted as me wanting a non-zero amount of power. The same issue was happening at the upper end as well, where I could not get the full 5 volts that I wanted at full throttle.

Can you believe I haven’t been hired as a data analyst yet?

When I boiled down the problem to look for a solution, my options were to either modify the complex motor driver, or build a translator to scale the voltages for me. Ultimately I chose to use a microcontroller as it seemed like the simplest solution. I chose an ATTiny85 as they function well enough with low power draw and cost nearly nothing, then wrote a simple program to poll the ADC, scale it to the expected 0-5 volts, and then output it as PWM. As I discovered in last week’s post, I found that this controller actually has a low pass filter built in, so it was easy to smooth the PWM back into an analog voltage. I also used the EEPROM function to calibrate the throttle rather than hard-code it into the program. This allows me to recalibrate the scaler if, for example, I replace the throttle with one that behaves slightly differently.

I was able to wire the ATTiny to a 5 volt supply I found on the board of the motor controller, and then wire the output back to the original potentiometer input point on the PCB. With all of this, I now have a DC motor controller that is able to take in any voltage range between 0 and 5 volts. In the future, if I desired, I would also be able to apply a logarithmic curve to the throttle for a more aggressive feel, or any other form of data processing I want.

In the video, you can see that the throttle affects the duty cycle of the power sent to the motors, changing how “on” the motor is.

Previous
Previous

Applied Intelligence

Next
Next

Pi Room - Spectrum Analyzer