PULSE WIDTH MODULATION USING CLOUDX CloudX

  • img
Project Details

PROJECT DETAILS

In this tutorial i'll be explaining Pulse width Modulation using cloudx to get started which is a very essential technique used in various applications of electronics.

DEFINITION

The term Pulse Width Modulation can be well understood if just from the three words

Pulse, Width and Modulation.

PULSE: whats a Pulse?? , a pulse is simply a ON and OFF state of an electric signal , e.g when you on your light and off it again , you just generated a pulse.

 Just to visualize, a Pulse is a signal shown above but you can see that there are two of various type shown above the first one being 

(1) rectangular pulse train

(2) Triangular pulse train

just to show that there are various types of pulses classified based on their shape, types of pulses are not limited to the two shown above but there are quite a lot of them,

Width: the width of the pulse as shown in the figure above is determined by how long the total duration of the pulse summing both the ON and the OFF time of the pulse.

MODULATION

This in simple terms means the process of varying one or more properties of a periodic waveform, this is where the difference between PWM signals and clocking signals lies in electronics. a clock signal can never be modulated it has to have a fixed property.

In digital electronics we can 

1) modulate(change) the amplitude of the waveform i.e generating signal of 5v , 3,3v, 1.5v etc on the same train of pulses or

  1. 2) modulate(change ) the duty of the waveform to be 50%,25% etc on the same train of pulse and by duty i mean the time duration of the ON time as a percentage of the full pulse width as shown above.
  2.  
  3. combining all the above the PWM is a process of changing characteristics of pulses(Modulation) of a single or more pulses on a train of pulses, it can be at regular interval or randomly.

 

PROJECT MATERIALS

Cloudx m633

connecting wires

10k variable resistors

PROJECT CODE

#include <CloudX/CloudX.h> 
#include <CloudX/Adc.h>
#include <CloudX/PWM.h>

int potValue; // create a variable for placing a whole number or integer

setup(){
//setup here
analogSetting(); // Configure and initialize the CloudX Analog Pins for Use
PWM1_Init(5000); /* Configure and initialize the CloudX PWM module 1 with the Desired PWM frequency in Hz within the set limits of the device MCU */
PWM1_Start(); // Starts PWM Module 1 Operation.
PWM1_Duty(0); /* Sets PWM duty ratio. The Function Can take values from 0% duty cycle - 100% duty cycle */

loop(){
//Program here
potValue = analogRead(A0); /* A 10-bit (0 -123) unsigned analog voltage signal value is read at the selected analog pin (A0) and assigned to the potValue variable */
potValue = ((float)potValue/1023) * 100; /* The value inside the potentiometer variable is converted to its percentage value so that it can be read by the PWM1_Duty() Function*/
PWM1_Duty(potValue); /* Sets PWM duty ratio with the value inside the potentiometer variable */

}
}
 

 

OUTPUT

EXPLANATION

from the code above all i did is to vary the input voltage to the cloudx board pin named A0(analog pin), then the cloudx ADC library reads the voltage values and changes the Pwm output pin (pwm1)  which is connected to the oscilloscope.

from the output on the oscilloscope in the image above you can see that the width of the output pulses is changed, or lets say modulated due to the program we've written

APPLICATION

There are several application of PWM which includes lamp dimmers, speed control of motors , it's upon this basis that several project on robotics and Digital signal processing where achieved.

for more examples check out these projects which are based on PWM 

 

 

 

Share this with friends