Cyber-Physical Systems Analog Output ICEN 553/453 Fall 2018 Prof. - - PowerPoint PPT Presentation

cyber physical systems analog output
SMART_READER_LITE
LIVE PREVIEW

Cyber-Physical Systems Analog Output ICEN 553/453 Fall 2018 Prof. - - PowerPoint PPT Presentation

Cyber-Physical Systems Analog Output ICEN 553/453 Fall 2018 Prof. Dola Saha 1 Pulse Width Modulation (PWM) Technique that conforms a signal width, generally pulses The general purpose is to control power delivery The on-off behavior


slide-1
SLIDE 1

1

Cyber-Physical Systems Analog Output

ICEN 553/453– Fall 2018

  • Prof. Dola Saha
slide-2
SLIDE 2

2

Pulse Width Modulation (PWM)

Ø Technique that conforms a signal width, generally pulses Ø The general purpose is to control power delivery Ø The on-off behavior changes the average power of signal Ø Output signal alternates between on and off within a

specified period.

Ø If signal toggles between on and off quicker than the load,

then the load is not affected by the toggling

slide-3
SLIDE 3

3

PWM – Duty Cycle

Ø A measure of the time the modulated signal is in its “high”

state

Ø Generally recorded as the percentage of the signal period

where the signal is considered on

Period (T) Duty Cycle (D) VL VH On Off

slide-4
SLIDE 4

4

Duty Cycle Formulation

% 100 ´ = Period Time On Cycle Duty

( )

L H avg

V D V D V ×

  • +

× = 1 Duty Cycle is determined by: *Average value of a signal can be found as:

1 ( )

T

y f t dt T = ò

*In general analysis, VL is taken as zero volts for simplicity.

Period (T) Duty Cycle (D) VL VH On Off

slide-5
SLIDE 5

5

PWM Duty Cycle

slide-6
SLIDE 6

6

PWM Mode

Ø Counter counts up

to the range provided

Ø When the counter

value is higher than set value,

  • utput is high
slide-7
SLIDE 7

7

PWM Duty Cycle Calculation

Ø The PWM device on the RPi is clocked at a fixed base-

clock frequency of 19.2 MHz

Ø Integer divisor and range values are used to tailor the

PWM frequency according to application requirements

Ø !

"#$ = 19.2*+,/(/010234×46789)

Ø If !

"#$ is 10KHz (0.01MHz), and range is 128,

§ /010234 =

;<.=$>? @ABC×DEFGH = 15

slide-8
SLIDE 8

8

PWM0 and PWM1 Map

slide-9
SLIDE 9

9

exploringPi/chp06/wiringPi/pwm.cpp

slide-10
SLIDE 10

10

Implement the Circuit

slide-11
SLIDE 11

11

How do we fade an LED?

slide-12
SLIDE 12

12

gpiozero Library

Ø PWM in effect

slide-13
SLIDE 13

13

Use RGB LED for showing your own colors

slide-14
SLIDE 14

14

Circuit

slide-15
SLIDE 15

15

Soft PWM Library in WiringPi (C/C++)

Ø https://projects.drogon.net/raspberry-

pi/wiringpi/software-pwm-library/

Ø https://github.com/WiringPi/WiringPi/blob/master/wiringP

i/softPwm.c

slide-16
SLIDE 16

16

C Code for Soft PWM

slide-17
SLIDE 17

17

Soft PWM

Ø PWM implemented in software Ø https://sourceforge.net/p/raspberry-gpio-

python/code/ci/default/tree/source/soft_pwm.c

slide-18
SLIDE 18

18

Python Code for Soft PWM