Click here to Skip to main content
16,022,301 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
Hello, im Javier from Spain. Right now im coding in STM32 a project which consist of a motor controller. Whenever i plot my rpms, it gets kind of noisy, like the rpms cant stay at a constant value and fluctuate between values. Im using an stm32 Nucleo F401RE, with a 9V power supply made up with a phone charger. Im using a JGA25-371 motor and a "tb6612fng" motor driver.

What I have tried:

I tried to change the motor, to change my samppling time, changing the power supply and tried to change the code but is no use.
Posted

1 solution

From the comment "Whenever i plot my rpms, it gets kind of noisy, like the rpms cant stay at a constant value” I conclude that a speed control should be realized. How exactly this was realized here is not mentioned in the text.

In addition to the correct wiring and the appropriate programming, the power supply is extremely important.

DC motors can cause considerable fluctuations in current consumption, especially during start-up and load changes. This can lead to voltage drops and faults that can affect the motor control and electronics. A separate and well stabilized and suitable power supply for the motor is therefore the first thing that comes to mind. The text only mentions a 9V power supply from a cell phone charger.

The microcontroller (STM32) and the encoder should be supplied with separate, very clean and stable voltage sources. Disturbances in the power supply can significantly interfere with the encoder pulses. To reduce high-frequency interference, it may also be necessary to provide the supply voltages with additional decoupling capacitors. Sensitive signal lines such as the encoder signals should be routed as far away as possible from the motor's power cables in order to minimize inductive coupling. As the encoder signals are very sensitive, short cables and level converters are recommended. It might also be worth considering shielding the signal lines.

The encoder outputs of the motor are OPEN COLLECTOR connections and require external pull-up resistors at each output. It may also be possible to configure these on the STM32.

In order to keep the speed of a DC motor constant, a functioning control loop is also required. The encoder pulses must be evaluated over a defined period of time in order to calculate the current speed of the motor. The STM32F401RE controller has several timers that can evaluate the encoder channel signals directly in hardware in encoder interface mode. It should be checked whether this has been implemented correctly here.
 
Share this answer
 
v2
Comments
CPallini 17-Jul-24 7:21am    
5.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900