Select Page

Rms&amp Average calculator of different waveforms

PROBLEM STATEMENT
To find the average voltage of a PWM waveform using Tiva tm4c123gh6pm microcontroller

Figure: Block diagram of the setup

 

 

 

 

 

 

 

 

 

 

 

DESIGN APPROACH
Approach 1: Using timer peripheral
Timer 1A (pin PF2) is configured in rising/falling edge trigger mode.
The on period (Ton) of the pulse is evaluated as the difference between the time-stamp of a falling edge and the immediate
preceeding rising edge.
The total time period (T ) is evaluated by the timestamp of two successive rising edges.
Assuming VDD = 3.3V , the average voltage can be calculated as

 

 

 

 

Approach 2: Using ADC and running average
ADC0 analog input channel on PE3 pin is used for sampling thePWM signal.
Average of the waveform is evaluated by averaging 1e4 samples of the digitized analog input.
The average voltage after (n + 1)th iteration is given as

 

 

 

 

 

 

Where V is the value of the ADC at the sampling instant.

Finding rms value for sine and square waveform
 For calculating rms value of square wave , we calculate duty cycle then we calculate rms value as follows
Vrms=Vmax*sqrt(duty cycle)
 For calculating rms value of sine wave we take maxium value of output samples in one time period then from that rms value is as
follows Vrms=Vmax*0.707.

INPUTS AND OUTPUTS
PWM signals are generated using another Tiva microcontroller board. SysTick timer and UART commands used to set the on time and off
time of the generated PWM pulses.
Results displayed on LCD screen.

RESULTS

 

 

 

 

 

 

Figure: Output voltage versus duty cycle using ADC

 

 

 

 

 

 

 

 

 

Figure: Output voltage versus duty cycle using timer

 

 

 

 

 

 

 

 

 

 

CONCLUSION:

We are able to measure average and rms value of PWM signal using timer mode and ADC mode.
Average value of PWM signal is very accurate when measured in timer mode compared to ADC mode.
ADC mode can be used to evaluate average value of any type of signal with varying voltages.
Timer mode can work accurately for frequencies up to 50 KHz. (Theoperation mode used in this project offers a resolution of 1µs)
ADC mode can work accurately for high frequency up to 100 KHz.

Code: pwm_generate

PWM_measure_ADC_timer

Demo: Rms&amp Average calculator of different waveforms