This is my first post and I'm just asking a little bit about motor control in a team project I'm a member of.

This is a bit of a "not so serious" project, so probably the solar panel system consumes much more energy than it generates but anyway: our parts budget for the project was not very extensive and we just had whatever was available at the school for parts.

So, we are using a DC motor to control the rotation of a solar panel tracker system. It was given to us by our teacher so we don't know much about it. We did test that it works at full speed in both directions, but as the supply voltage became too low, it didn't work so well (less than 3 V wasn't very good).

The system works like this:

  • There is a solar panel plate to which the solar panel attaches on a hinge, and the other end of the solar panel has a hinge and a part into which the "top-end" of screw attaches, and solar panel is able to tilt, by using a screw, which is turned by the stepper ("bottom-end" of screw is attached at the stepper). The stepper is mounted on a hinge at the solar panel plate
  • That solar panel plate has wheels at the bottom,
  • Then there is a second "baseplate" and the solar panel plate rests on that baseplate.
  • The baseplate has the DC motor which turns the solar panel plate, the rotation part.

Then we have that L298n chip.

The tilting axis is controlled with a separate stepper motor.

I think we are connecting 12 V into the power of the DC motor, but this results in too fast a speed for the motor.

I think that after consulting an Arduino tutorial (and the chip L298 datasheet), it was recommended to use PWM into the enableB pin, to control speed.

We are using SCtimer functionality from the LPCxpresso to pulse the PWM


  1. It appears that on this website, it was recommended to PWM into the in3 and in4 pins, see L298n PWM frequency. Is it a better solution to PWM into the in3 and in4 pins, as opposed to the enableB pin? We require good speed control in our project, and the motor speed should be able to be fairly slow, and we would want to have the ability to rapidly stop also. Overall, I would say that we require of the motor: slow speed, ability to stop quickly, ability for direction changes.

  2. I would say that of course one channel PWM into the enableB pin is the simplest PWM in the software to configure, but I suppose that we could also make a two channel PWM, while leaving the enableB pin = TRUE. Then we could control the directions by changing the duty cycles of in3, and in4, by switching around the duty cycles like (0%, 25%) and vice-versa. I suppose we could also have the stop motor at (0%, 0%)

  3. Is there any way to know a good PWM frequency for a DC motor, if you don't know much about that motor directly in terms of specs and datasheet, and make & model? I think that we succeeded in some early tests with 1 kHz PWM, but some of our classmates had used that same DC motor with about 400 Hz PWM.


1 Answer 1


As the braking force is a function of the turning speed, you'll probably seen not too much of a difference between braking and simply turning of when the motor only runs at slow speeds. But that will definitely the fun part figuring out what works best, you might even try a short reverse impulse, depending of the driven mass.

You probably want the PWM frequency to be outside of the audible band, but not too high to struggle with the raise time of your driver. Around 30khz is not uncommon. Beside the noise it can produce the low pass characteristic of your complete system defines the lowest frequency you are able to use. With a complete solar panel attached to a motor plus gearbox you won't have any problems with something like 100hz, beside the terrifying sound of it.

  • \$\begingroup\$ do you have any opinion on the enableB pin, vs controlling both input3 and input4 pins with the PWM? I don't understand what's the difference between so-called "free-wheeling" that happens with DC motor when enableB pin is being used with the pwm, vs the other scenario (not-free-wheeling) \$\endgroup\$
    – Late347
    Dec 22, 2018 at 7:31
  • \$\begingroup\$ That's what I implied by the braking. The difference between free wheeling and braking becomes more noticable at higher turning speeds. Free wheeling is equivalent to not connected at all vs braking is shorted. There are probably better ways to explain it. \$\endgroup\$
    – wiebel
    Dec 22, 2018 at 7:39
  • \$\begingroup\$ Why stopping motor on solar system? He already know the time interval of sunrise and sunset. Choose a gearbox according to the time when the sun is shortest and adjust its speed. High Rate Reducers Do Not Have Brakes ! Edit: Choose the maximum speed according to which the day or night is shorter. \$\endgroup\$
    – dsgdfg
    Aug 13, 2023 at 12:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.