# How to find a suitable `herz` value for a Low Inertia Solar Motor [closed]

I would like to use a Low Inertia Solar Motor-1820 RPM with the Raspberry Pi.

More specifically, I want to control its speed using pulse width modulation (PWM) as is explained in this video Controlling a DC Motor with the Raspberry Pi.

Now to do this I need to know to which value to set the `hertz` parameter in the function `GPIO.PWM(pin_number, hertz)`.

This code is shown in the video at 1:35, see line 7.

• Now I know from blind experimentation that a valid value is `hertz = 207`, but what other values can I use?
• And how do different Hertz values affect the motor? For example, are there values that could potentially break my motor?
• And how can I find/calculate suitable Hertz values? I cannot find it in the linked specification.
• This is nothing to do with the Raspberry Pi. – joan Jan 10 '18 at 11:59
• Please make sure you use a motor driver board between the Pi and the motor. If you don't you will likely destroy your Pi. Your questions are better asked about the motor driver board you buy, the motor itself is likely to be irrelevant. – joan Jan 10 '18 at 12:49
• At the moment the motor seems to work fine without any driver board. I am just curious how the herz/frequency influences the motor, what valid values for this parameter are and how one can determine such values? – MuadDev Jan 10 '18 at 14:23
• I expect the Pi will seem fine and then it will seem not fine. – joan Jan 10 '18 at 15:43
• Should be moved to "SE Electrical Engineering". – MatsK Jan 10 '18 at 19:57

The second parameter of `GPIO.PWM(channel, frequency)` determine the frequency of the pwm (hertz is the unit of frequency, i.e. cycles/second), in the case of an LED, you will noticed the LED blinking at every 2 second if you set it to 0.5 (i.e. 1/2). But if you set it 100, you will feel the LED is constantly ON even though it is actually blinking at 100 cycles/second.

In the case of motor control using PWM, the frequency does not affect the speed of the motor, the Duty Cycle does. You can set the `freq` to 50Hz (which is same as your home appliance power frequency), and change duty cycle to control the speed of the motor. Duty cycle can be controlled between 0% to 100%. A duty cycle of 50% means it is running at half of the full speed. Here is an example in python using RPi.GPIO library that you can try it out. The program increases the duty cycling by 5% between 0% to 100 (i.e. gradually speed up) and then decrease the duty cycling by 5% from 100% to 0% (i.e. gradually slow down):

``````import time
import RPi.GPIO as GPIO
GPIO.setmode(GPIO.BOARD)
GPIO.setup(12, GPIO.OUT)

p = GPIO.PWM(12, 50)  # channel=12 frequency=50Hz
p.start(0)
try:
while 1:
# speed up by increase duty cycling by 5% each time
for dc in range(0, 101, 5):
p.ChangeDutyCycle(dc)
time.sleep(0.1)
time.sleep(1)        # take a break for 1 sec
# speed down
for dc in range(100, -1, -5):
p.ChangeDutyCycle(dc)
time.sleep(0.1)
except KeyboardInterrupt:
pass
p.stop()
GPIO.cleanup()
``````

Finally, neither the frequency nor the duty cycling will break your motor. However, your motor may not be able to function properly at very high frequency, so keep the frequency low.

• Thank you for your elaborate answer, this makes everything a lot clearer for me. Now I can work with the motor. But I am still left with the question as to why 50 herz is a valid choice? Isn't there a way to find out what a good frequency is for any given motor or other object? Or is that something that one can only find out by reading the specs of such an object? Meaning that if it is not mentioned in the specs you just don't know...? – MuadDev Jan 10 '18 at 14:20
• There is no good or bad frequency (at least for motor control), 50Hz (or 60Hz depends on which continent you are in) is the frequency used in the power grid. This has nothing to do with spec, it is the understanding of electrical theory and how motor works. I'm happened to be a guy with electrical/electronics background that learnt those long time ago... – hcheung Jan 10 '18 at 14:36
• As suggested by your motor product description suggested "Low Inertia Solar Motor - 1820 RPM", if you apply a 3v DC (i.e. Direct Current instead of 50Hz Alternative Current or AC) voltage to it, it will turning at 1820 revolutions per minute. In short, for a DC motor, frequency does not matter much. – hcheung Jan 10 '18 at 14:47