Pulse-width modulation is a digital technique to control a signal by repeatedly toggling a signal between a HIGH and a LOW state in a consistent pattern. We can portray new information by changing how long the signal is HIGH versus LOW. The PWM signal has two key parameters - frequency and duty cycle.
The period of the PWM signal(measured in seconds) indicates the amount of time it takes for the signal to complete one cycle. Refer to the image above. We can see that a period is a complete cycle of the signal, changing from LOW signal to a HIGH signal and back to a LOW signal. The signal pattern of each period is repeated over and over again.
The frequency of the PWM signal, measured in Hertz (Hz), indicates the number of complete periods that occur in 1 second. In our LaunchPad, the PWM signal typically has a frequency of 490 Hz. This means that our PWM signal completes 490 periods every second. The period and frequency of a signal are closely related, in that the faster the frequency, the smaller the period. The slower the frequency, the larger the period.
The relationship between period and frequency is realized with this equation:
For example, the period of a 1-kHz (1000 Hz) signal is 1/(1000 Hz) = 0.001 s or 1 ms.
The Duty Cycle of the PWM signal is the percentage of time that our PWM signal is in a HIGH state versus a LOW state. For example, a simple square wave has a duty cycle of 50%. However, we can change the duty cycle of our PWM signal, anywhere from 0% (for always OFF) to 100% (for always ON) and anywhere in between, depending on what type of information we want to portray.
PWM can also be used to control the power that is fed into certain electrical devices. By changing the duty cycle of a PWM signal, we can actually simulate an average voltage (or current) output. The longer the duty cycle is, relative to the period, means that, on average, the signal is more HIGH than LOW. This means on average more voltage (or current) is seen at the digital output pin. If we start at a duty cycle of 0%, we should see an effective average voltage of 0 V. Increasing duty cycle to 50%, we’ll start to see an effective average voltage of VCC/2. And lastly, at a duty cycle of 100%, we should see an effective voltage of VCC.
(extract from ScienceDirect)
The XY_PWM is a low cost module that generates a PWM signal. You can control the frequency of the PWM signal from 1Hz to 150kHz and the duty cycle from 0 to 100%. A LCD screen shows the current settings and there are four buttons to control frequency and duty cycle.
The module has an input voltage from 3.3 to 30V. The output signal voltage will range from 0V to the input voltage. The output is a simple transistor with a 1K pull-up resistor. It isn't designed to drive high current motors but is an ideal signal for a servo for example.
The XY-PWM module is great at generating a PWM signal for a servo or for being a simple square generator for digital circuits. To make it even more useful, I decided to 3D print a case and include a 5V 1A power supply. The case is a clam shell design and can neatly sit on a shelf or workbench.
The STL files for 3D printing are attached. All printing was sliced with a 0.2mm layer and no supports. You will need to orientate the parts to sit flat on the build plate.
The module generates a clean precise waveform. The only issue I have with the module is there is no contrast setting for the LCD screen. It's viewing angle is not good and you almost need to be directly in front of the screen to read it. It really needs more contrast. However for under the price of a cup of coffee, it is a great value module.
Comments
Please log in or sign up to comment.