Electronics & Circuits · Study deck

Binary Number Systems

Picture a pressure alarm stored as eight bits.

Voltage Vera is your guide for this deck.

analogdigitalbinary
Voltage Vera, the module guide, in a scene from this chapter.
iotclass.org

After studying this chapter

Learning objectives

You will be able to:

  • Convert Binary Numbers: Translate between decimal and binary number systems using place-value decomposition
  • Apply Powers of 2: Calculate ADC resolution ranges from bit depth
  • Interpret Place Values: Use positional notation in base-2 arithmetic
  • Analyse Floating Point: Explain IEEE 754 representation and identify its precision limitations
iotclass.org

Major section

Start Simple

The same row can mean a value, several flags, or part of a signed number.

  • The hardware contract must say which meaning is correct.
  • An analog-to-digital converter is a circuit that turns a changing voltage into a number.
  • ADC is its short name.
  • This runway does not prove measurement accuracy or every number format.

Key terms

Binary
Binary means writing numbers with only zero and one, where each place has a power-of-two value.
iotclass.org

Major section

Phoebe's Field Notes: How Many Bits Does A Reading Actually Need

The mathematical gist.: To resolve a smallest change \(\Delta\) across span V_{FS}, require \(2^N\ge V_{FS}/\Delta\), hence \(N_{min}=\lceil\log_2(V_{FS}/\Delta)\rceil\).

  • Resolving 1% of a 50 mV conditioned span needs 7 bits; leaving that signal on a bare 5 V range needs 14 bits.

Numbers to remember

1%Resolving 1% of a 50 mV conditioned span needs 7 bits
50 mVResolving 1% of a 50 mV conditioned span needs 7 bits
7 bitsResolving 1% of a 50 mV conditioned span needs 7 bits
iotclass.org

Major section

For Kids: Meet the Sensor Squad!

But your feelings are analog - smooth like sliding down a slide." This was a big problem!

  • Analog and digital are like the difference between a slide (smooth) and stairs (steps)!
  • I can only work with exact step numbers, like climbing stairs.
  • The Sensor Squad's translation team was complete!
iotclass.org

Major section

For Kids: Meet the Sensor Squad! (continued)

But I can make my stairs have MORE steps - instead of big steps like 20, 21, 22, I can use tiny steps like 20.0, 20.1, 20.2.

  • Temperature Terry had a problem. "Max, I can feel temperatures that go smoothly from cold to hot - like 20.1, 20.2, 20.3 degrees.
  • He's a translator!" ADC Andy arrived with a big smile. "I can help!
  • The more steps I use, the closer I get to Sammy's smooth feelings!" Now Sammy could measure temperatures, Andy would translate them into step-numbers, and Max could process them.
iotclass.org

Major section

Getting Started: Analog vs Digital

The analog trace can occupy any intermediate voltage, while the digital trace can occupy only one of the four pictured step levels.

  • The left-hand trace has effectively infinite possible values; the right-hand trace assigns each sample to one of $2^n$ fixed levels.
  • Everything we want to measure is analog, but computers only understand digital!

Why it matters

That loss of intermediate values is quantisation, and increasing $n$ reduces the voltage interval represented by each step.

Analog vs Digital Signals: Continuous Ramp vs Discrete Steps
Analog vs Digital Signals: Continuous Ramp vs Discrete Steps
iotclass.org

Major section

Binary Number System

An $n$-bit word provides $2^n$ combinations, but an unsigned ADC labels them from 0 through $2^n-1$: 4 bits give codes 0–15 and 8 bits give codes 0–255.

  • The same doubling rule explains why adding one register bit doubles the representable states.
Powers of 2 and binary place values
Powers of 2 and binary place values
iotclass.org

Deck summary

Key takeaways

The same row can mean a value, several flags, or part of a signed number.

  • The mathematical gist.: To resolve a smallest change \(\Delta\) across span V_{FS}, require \(2^N\ge V_{FS}/\Delta\), hence \(N_{min}=\lceil\log_2(V_{FS}/\Delta)\rceil\).
  • But your feelings are analog - smooth like sliding down a slide." This was a big problem!
  • But I can make my stairs have MORE steps - instead of big steps like 20, 21, 22, I can use tiny steps like 20.0, 20.1, 20.2.
iotclass.org

Retrieval practice

Recall check 1 of 3

Voltage Vera says: answer from memory, then check your reasoning.

Q1Why should you avoid using == to compare floating-point numbers in IoT sensor code?

AIt's too slow for real-time processing
BRounding errors make exact comparison unreliable
CFloating-point numbers can't be compared
DIt causes compiler errors
Show answer

Answer: B

Q2What is the decimal value of binary 1101 ?

A11
B13
C15
D9
Show answer

Answer: B Answer: B) 13 $$1101_2 = (1×8) + (1×4) + (0×2) + (1×1) = 8 + 4 + 0 + 1 = 13_{10}$$.

iotclass.org

Retrieval practice

Recall check 2 of 3

Voltage Vera says: answer from memory, then check your reasoning.

Q3How many different values can a 16-bit ADC represent?

A16,384
B32,768
C65,536
D131,072
Show answer

Answer: C Answer: C) 65,536 $$Values = 2^{bits} = 2^{16} = 65,536$$ The actual digital output ranges from 0 to 65,535 (one less than total values).

Q4If you increase an ADC from 10-bit to 12-bit, how much more precise is each voltage step?

A2× more precise (2 more bits = double precision)
B4× more precise (2^2 = 4 times more voltage levels)
C12× more precise (12 bits vs 10 bits)
D1.2× more precise (linear relationship)
Show answer

Answer: B Each additional bit doubles the resolution: 10-bit = 1,024 levels, 12-bit = 4,096 levels.

iotclass.org

Retrieval practice

Recall check 3 of 3

Voltage Vera says: answer from memory, then check your reasoning.

Q5Place each binary-conversion element where it lives so you can prove that 100101 represents decimal 37.

ADecimal input: 37
BBinary output: 111000
CHex value: 0xFF
DReference voltage: 3.3V
Show answer

Answer: A Separate the decimal input, active bit weights, and final sum so you can verify a binary conversion instead of memorising the bit string.

iotclass.org

Print reference

Answers 1 of 2

Answer key.

  1. B
  2. B · Answer: B) 13 $$1101_2 = (1×8) + (1×4) + (0×2) + (1×1) = 8 + 4 + 0 + 1 = 13_{10}$$.
  3. C · Answer: C) 65,536 $$Values = 2^{bits} = 2^{16} = 65,536$$ The actual digital output ranges from 0 to 65,535 (one less than total values).
  4. B · Each additional bit doubles the resolution: 10-bit = 1,024 levels, 12-bit = 4,096 levels.
iotclass.org

Print reference

Answers 2 of 2

Answer key.

  1. A · Separate the decimal input, active bit weights, and final sum so you can verify a binary conversion instead of memorising the bit string.
iotclass.org