Presentation is loading. Please wait.

Presentation is loading. Please wait.

BM-305 Mikrodenetleyiciler Güz 2016 (3. Sunu)

Similar presentations


Presentation on theme: "BM-305 Mikrodenetleyiciler Güz 2016 (3. Sunu)"— Presentation transcript:

1 BM-305 Mikrodenetleyiciler Güz 2016 (3. Sunu)
(Yrd. Doç. Dr. Deniz Dal)

2 Analog Çıkış ve Darbe Genişlik Modülasyonu (Pulse Width Modulation – PWM)
Arduinos and other microcontrollers provide analog to digital (ADC) conversion to convert an input voltage to a digital value. You might think that they also provide the converse which is digital to analog (DAC) conversion. This is not the case. Instead they provide pulse-width modulated (PWM) outputs. The Arduino library provides this functionality with a function called analogWrite(). The name seems to imply DAC functionality, but it just controls the PWM output. For many applications, such as the case of motor control, PWM is sufficient.

3 Analog Çıkış ve Darbe Genişlik Modülasyonu (Pulse Width Modulation – PWM)
Pulse Width Modulation, or PWM, is a technique for getting analog results with digital means. Digital control is used to create a square wave, a signal switched between on and off. This on-off pattern can simulate voltages in between full on (5 Volts) and off (0 Volts) by changing the portion of the time the signal spends on versus the time that the signal spends off. The duration of "on time" is called the pulse width. To get varying analog values, you change, or modulate, that pulse width. If you repeat this on-off pattern fast enough with an LED for example, the result is as if the signal is a steady voltage between 0 and 5v controlling the brightness of the LED.

4 Analog Çıkış ve Darbe Genişlik Modülasyonu (Pulse Width Modulation – PWM)
In the graphic below, the green lines represent a regular time period. This duration or period is the inverse of the PWM frequency. In other words, with Arduino's PWM frequency at about 500Hz, the green lines would measure 2 milliseconds each. A call to analogWrite() is on a scale of , such that analogWrite(255) requests a 100% duty cycle (always on), and analogWrite(127) is a 50% duty cycle (on half the time) for example.

5 Görev Çevrimi (Duty Cycle)
A duty cycle is the percentage of one period in which a signal is active. A period is the time it takes for a signal to complete an on-and-off cycle. A 60% duty cycle means that the signal is on 60% of the time but off 40% of the time. The "on time" for a 60% duty cycle could be a fraction of a second, a day, or even a week, depending on the length of the period.

6 analogWrite Fonksiyonu ve Arduino UNO PWM Çıkış Pinleri
Writes an analog value (PWM wave) to a pin. Can be used to light a LED at varying brightnesses or drive a motor at various speeds. After a call to analogWrite(), the pin will generate a steady square wave of the specified duty cycle until the next call to analogWrite() (or a call to digitalRead() or digitalWrite() on the same pin). The frequency of the PWM signal on most pins is approximately 490 Hz. On the Uno, this function works on pins 3, 5, 6, 9, 10, and 11. Those pins are marked with a tilde ~ symbol and output a variable duty cycle from 0 to 255 (0 to 100%). You do not need to call pinMode() to set the pin as an output before calling analogWrite(). The analogWrite function has nothing to do with the analog pins or the analogRead function. Syntax: analogWrite(pin, value) Parameters: pin: the pin to write to. value: the duty cycle: between 0 (always off) and 255 (always on).

7 PWM ile LED Parlaklığının Kontrolü

8 PWM ile LED Parlaklığının Kontrolü

9 PWM ile LED Parlaklığının Kontrolü

10 Dijital Giriş ve digitalRead Fonksiyonu
digitalRead() reads the value from a specified digital pin, either HIGH or LOW. Syntax: digitalRead(pin) Parameters: pin: the number of the digital pin you want to read (int) Returns: HIGH or LOW

11 Geçici Anahtar ile LED Kontrolü

12 Geçici Anahtar ile LED Kontrolü

13 Geçici Anahtar ile LED Kontrolü

14 Analog Giriş ve analogRead Fonksiyonu
analogRead() reads the value from the specified analog pin. The Arduino UNO board contains a 6-channel, 10-bit analog to digital converter (ADC). This means that it will map input voltages between 0 and 5 volts into integer values between 0 and This yields a resolution between readings of: 5 volts / 1024 units or, volts (4.9 mV) per unit. The input range and resolution can be changed using analogReference(). Syntax: analogRead(pin) Parameters: pin: the number of the analog input pin to read from (0 to 5) Returns: int (0 to 1023)

15 Potansiyometre Çıkış Geriliminin Analog Giriş Olarak Kullanılması

16 Potansiyometre Çıkış Geriliminin Analog Giriş Olarak Kullanılması


Download ppt "BM-305 Mikrodenetleyiciler Güz 2016 (3. Sunu)"

Similar presentations


Ads by Google