cyber physical systems analog output
play

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


  1. Cyber-Physical Systems Analog Output ICEN 553/453– Fall 2018 Prof. Dola Saha 1

  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 2

  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 On Off V H Duty Cycle (D) V L Period (T) 3

  4. Duty Cycle Formulation Duty Cycle is determined by: On Off V H On Time = Period ´ Duty Cycle 100 % Duty Cycle (D) *Average value of a signal can V L be found as: Period (T) 1 = ò T y f t dt ( ) T 0 ( ) = × + - × V D V 1 D V avg H L *In general analysis, V L is taken as zero volts for simplicity. 4

  5. PWM Duty Cycle 5

  6. PWM Mode Ø Counter counts up to the range provided Ø When the counter value is higher than set value, output is high 6

  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 7

  8. PWM0 and PWM1 Map 8

  9. exploringPi/chp06/wiringPi/pwm.cpp 9

  10. Implement the Circuit 10

  11. How do we fade an LED? 11

  12. gpiozero Library Ø PWM in effect 12

  13. Use RGB LED for showing your own colors 13

  14. Circuit 14

  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 15

  16. C Code for Soft PWM 16

  17. Soft PWM Ø PWM implemented in software Ø https://sourceforge.net/p/raspberry-gpio- python/code/ci/default/tree/source/soft_pwm.c 17

  18. Python Code for Soft PWM 18

Recommend


More recommend