1 / 11

Pulse Width Modulation (PWM)

Pulse Width Modulation (PWM). Pulse Width Modulation (PWM). 100%. Pulse Width Modulation (PWM). 0%. On the chipKIT there are 490 periods per second. U se analogWrite (pin, value) to control the duty cycle on a pin. The value must be between 0 and 255.

yanni
Télécharger la présentation

Pulse Width Modulation (PWM)

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Pulse Width Modulation (PWM)

  2. Pulse Width Modulation (PWM) 100%

  3. Pulse Width Modulation (PWM) 0% • On the chipKIT there are 490 periods per second. • Use analogWrite(pin, value) to controlthe duty cycle on a pin. • The value must be between 0 and 255. • The pin must be one of the underlined pins.

  4. Pulse Width Modulation (PWM) • If you take the average value over one period,you can think of the voltage as being between0 V (0% duty cycle) and 3.3 V (100% duty cycle). • There are 256 different voltage levels (0 to 255).

  5. Conversion of Analog to Digital • Obtain “analog” input using analogRead(). • analogRead()returns a value between 0 (if pin at ground) and 1023 (if pin at 3.3 V). • Argument of analogRead()is the pin to read(only pins labeled ANALOGIN can be used). • Used this to read setting of a potentiometer.

  6. Pulse Width Modulation (PWM) Wrote led_with_potentiometer for this circuit.

  7. Dimmable LED Program intpotPin = 0; // Pin for potentiometer. intledPin = 9; // Pin for LED. intpwmValue = 0; voidsetup() { Serial.begin(9600); // To see potentiometer setting. } voidloop() { // Read potentiometer value and set PWM value. pwmValue = analogRead(potPin) / 4; Serial.println(pwmValue, DEC); analogWrite(ledPin, pwmValue); // Set PWM duty cycle. delay(15); // Waits 15 ms. }

  8. Different Circuit; Same Result

  9. Transistor: Electrically Controlled Switch If “base” of the transistor is high, then current can flow freely.

  10. Transistor: Electrically Controlled Switch If “base” of the transistor is low, then current cannot flow.

  11. Variable Speed Motor

More Related