SEARCH
TOOLBOX
LANGUAGES
modified on 18 September 2014 at 14:48 ••• 22,061 views

05-03 PWMFrequency

From Manuals

(Difference between revisions)
Jump to: navigation, search
(Created page with 'This example program uses an analog input to control the period of a PWM. /*Program Example 5.3: Uses analog input to control PWM period …')
Line 1: Line 1:
This example program uses an analog input to control the period of a PWM.
This example program uses an analog input to control the period of a PWM.
 +
The signals used for this example are listed below:
 +
{| border="1" cellpadding="5" cellspacing="2" align="center" style="text-align: center;"
 +
|+ align="bottom"|'''Signals Used and Connector Locations for Example 05-03'''
 +
|'''Signal'''
 +
|'''LPC4330 PIN NAME'''
 +
|'''BAM210E'''
 +
|'''BAM210'''
 +
|'''BAM200E'''
 +
|'''BAM200'''
 +
|'''Used for'''
 +
|-
 +
|A0
 +
|P7_4
 +
|J8-1
 +
|J8-1
 +
|S4-3
 +
|S4-3
 +
|Potentiometer
 +
|-
 +
|PWM1
 +
|P1_7
 +
|J9-3
 +
|J9-3
 +
|S2-3
 +
|S2-3
 +
|-
 +
|}
 +
 +
The following schematic can be used to build the circuit with a BAM210E or BAM210.
 +
[[Image:BAM210_05_03_SCH.png|center|alt=BAM210|frame|<div align="center">'''Schematic for example 05-03''']]
 +
 +
<div style="text-align: left;">
  /*Program Example 5.3: Uses analog input to control PWM period
  /*Program Example 5.3: Uses analog input to control PWM period
                                                                       */
                                                                       */
Line 16: Line 48:
[[Image:BAM210_PWMFrequency.jpeg|center|]]
[[Image:BAM210_PWMFrequency.jpeg|center|]]
-
 
-
 
-
[[Image:BAM210_05_03_SCH.png|center|alt=BAM210|frame|<div align="center">'''Schematic for example 05-03''']]
 

Revision as of 19:31, 17 September 2014

This example program uses an analog input to control the period of a PWM.

The signals used for this example are listed below:

Signals Used and Connector Locations for Example 05-03
Signal LPC4330 PIN NAME BAM210E BAM210 BAM200E BAM200 Used for
A0 P7_4 J8-1 J8-1 S4-3 S4-3 Potentiometer
PWM1 P1_7 J9-3 J9-3 S2-3 S2-3

The following schematic can be used to build the circuit with a BAM210E or BAM210.

BAM210
Schematic for example 05-03
/*Program Example 5.3: Uses analog input to control PWM period
                                                                     */
#include "mbed.h"
PwmOut pwm(PWM1);
AnalogIn Ain(A0);

int main() {
    while(1){
      pwm.period(Ain/10+0.001);            // set PWM period
      pwm=0.5;                             // set duty cycle
      wait(0.5);
    }
}