Lesson 4.3 · Module 4: Digital Hardware & Embedded Protocols

I2C and PWM Signals on a Virtual Oscilloscope

What digital communication looks like on an oscilloscope: an I²C message to a temperature sensor, and PWM that dims an LED.

The live, interactive simulation for this lesson opens here when JavaScript is on.

Key ideas

  • I²C sends bits one at a time on a data wire (SDA), timed by a clock wire (SCL).
  • Each chip on the bus has an address; the right chip answers with an ACK.
  • PWM switches fully on and off very fast; the on-time fraction sets the average brightness.

Try this in the simulation

  • Change the address until the TMP102 sensor answers with ACK.
  • Switch to PWM and change the duty cycle while watching the LED.
  • Read the decoded bits above the scope trace.

What do I²C and PWM signals look like?

I²C sends data one bit at a time on a data wire (SDA), timed by a clock wire (SCL). A message starts with the address of the chip being called, and the right chip answers with an acknowledge (ACK) bit. PWM (pulse-width modulation) switches a signal fully on and off very quickly, and the fraction of time it is on, the duty cycle, sets the average power, such as the brightness of an LED.

What you’ll learn

  • How an I²C message is built: start, address, read or write, ACK, data, stop.
  • How to read the decoded bits on a virtual oscilloscope.
  • What duty cycle and frequency mean for a PWM signal.
  • Why the average voltage of a PWM signal equals duty cycle times the supply.

The formula, letter by letter

S⏟start  1000000⏟addr 0x40  0⏟R/W‾  1⏟NACK⋯P⏟stop\underbrace{\htmlData{sym=S:start}{S}}_{\text{start}}\;\underbrace{1000000}_{\text{addr }0x40}\;\underbrace{0}_{\htmlData{sym=R:read}{R}/\overline{\htmlData{sym=W:write}{W}}}\;\underbrace{1}_{\text{NACK}}\cdots\underbrace{\htmlData{sym=P:stop}{P}}_{\text{stop}}

Shown with this lesson’s starting values. In the simulation the numbers change as you move the sliders.

SS
Start condition (no unit) : SDA falling while SCL is HIGH: tells every device a message begins.
RR
Read bit (no unit) : 1 means "read from the device".
WW
Write bit (no unit) : 0 means "write to the device". The bar over W means "active when 0".
PP
Stop condition (no unit) : SDA rising while SCL is HIGH: tells every device the message is over.

Common questions

What is an I²C address?

A number that identifies one chip on the shared bus. Every message begins with it, and only the chip with that address answers with an ACK.

What does ACK mean on I²C?

It means acknowledge: after each byte, the receiving chip pulls the data line low for one clock pulse to say “got it”. No ACK usually means a wrong address or a missing chip.

How does PWM dim an LED?

The LED is switched on and off too fast for the eye to notice. A 25 % duty cycle means it is on a quarter of the time, so it looks about a quarter as bright.

Keep going

Words used in this lesson

Parts in this lesson

All lessons · How components work · Glossary