Why isn't my AVR microcontroller controlling motor speed with PWM using Zephyr?
@Middleware & OS Hello guys, I'm attempting to control a motor's speed using PWM on my AVR microcontroller running Zephyr. I've set up the PWM peripheral and device tree configuration, but the motor does not respond to PWM signals. The PWM peripheral has been configured in prj.conf. I also created the device bindings in the device tree source file (dts), then wrote a code to generate PWM signals to control the motor. I expect the motor to change its speed in response to the PWM signals. Specifically, varying the duty cycle should result in corresponding changes in motor speed. The motor I'm using is a Mabuchi RS-540 series. The issue I'm having is that the motor is not responding to the PWM signals. What could be the reason for this, and how can I debug it?
this is my code snippet:
4 Replies
@Dtynin Is your motor connected properly to the PWM pin on the microcontroller? Sometimes wiring issues can cause these kinds of problems and have you checked if the PWM peripheral is correctly defined in your device tree source file? Can you share that part of your dts file?
@Dtynin what kind of values are you getting back from the
ADC
? Are they consistently off by a certain amount, or do they seem random?@RED HAT They seem pretty random. Sometimes they’re way higher than expected, other times much lower. It’s all over the place.
@Dark AI Yeah, I have double-checked the wiring, and the motor is connected properly. don't know what seems to be the issue.