Download presentation
Presentation is loading. Please wait.
Published byVernon Richards Modified over 9 years ago
1
[Lab10] Output PWM Output PWM Signal Example Exercise(Optional)
2
PWM PWM, Pulse Width Modulation. It enable us to contral dc motors, servo motors, fans… etc. PyBBIO provides 4 PWM pins output which is P9_14, P9_18, P8_13 and P8_19.
3
PWM The circuit illustrates below Device PWM Pin GND
4
PWM The PWM output action depends on the integer we give to PWM pins which between 0 to 255. Pass the integer to PWM by function analogWrite(PWM, value), which is discribe in bbio.py
5
PWM Example: In this lecture, we are going to generate an PWM signal by Beaglebone. Use led as the target of PWM signal. Give different value to PWM output and observe the brightness of led.
6
Analog Reader(ADC) Circuit: LED P9_14 (PWM1A) GND
7
Analog Reader(ADC) Code: from bbio import * brightness = 0 inc = 1 pass = 10 def setup(): pass def loop(): global brightness, inc analogWrite(PWM1A, brightness) brightness += inc if( (brightness==0) or (brightness == 255) ) inc*= -1 delay = pass run(setup, loop)
8
Exercise: Use ADC to receive an external signal and change the brightness of led refers to external signal. Be careful as you did in last week. PWM
9
Pin Configuration
10
VDD_ADC 1.8v AIN0 VR 10K Ω GND_ADC Circuit2 PWM LED P9_14 (PWM1A) GND
11
Code: from bbio import * def setup(): pass def loop(): brightness = analogRead(AIN0) *255/4096 analogWrite(PWM1A, brightness) delay(10) run( setup, loop) PWM
12
Tune the resistor and observe the led changes. PWM
13
END
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.