All courses › Embedded Systems and Instrumentation

Embedded Systems and Instrumentation: free practice, theory and problems

Computers and microcontrollers store and compute with everything as binary numbers (0s and 1s). To read and write code efficiently, engineers also use hexadecimal numbers as a compact shorthand for binary, and they need to know how negative numbers are represented in a fixed number of bits. Digital logic – gates such as AND, OR, NOT and XOR – are the building blocks all of these operations are ultimately built from, both in hardware and in expressions in C code.

3 parts56 problems9 concepts explainedPractice examFree
Start practising for free →

Contents

  1. Number systems and digital logic
  2. Microcontrollers
  3. Measurement

1. Number systems and digital logic

What is it about?

Computers and microcontrollers store and compute with everything as binary numbers (0s and 1s). To read and write code efficiently, engineers also use hexadecimal numbers as a compact shorthand for binary, and they need to know how negative numbers are represented in a fixed number of bits. Digital logic – gates such as AND, OR, NOT and XOR – are the building blocks all of these operations are ultimately built from, both in hardware and in expressions in C code.

Concepts and formulas

How to solve the problems

  1. Converting between bases: multiply each digit by the base's power and sum (to decimal), or repeatedly subtract the largest possible power (from decimal).
  2. Two's complement, negative number to bit pattern: compute 2n−∣x∣2^n - |x| and write it as an unsigned binary/hex number.
  3. Two's complement, bit pattern to number: if the top bit is 1, subtract 2n2^n from the unsigned value.
  4. Bitwise operators: write out each number in binary and work bit by bit.
  5. Logic gates: build a truth table if unsure, or remember the rule for each gate.

Example

What is −5-5 written as 8-bit two's complement, in hexadecimal?

  1. Unsigned bit pattern: 28−5=256−5=2512^8 - 5 = 256 - 5 = 251.
  2. 251251 in hexadecimal: 251=15⋅16+11=FB251 = 15\cdot16 + 11 = \mathrm{FB}.

Answer: 0xFB.

Common mistakes

An nn-bit unsigned number covers 00 to 2n−12^n-1; an nn-bit signed (two's complement) number covers −2n−1-2^{n-1} to 2n−1−12^{n-1}-1, and a negative number −x-x is the bit pattern of 2n−x2^n-x.

Concepts in this part

Practise number systems and digital logic in the app →

2. Microcontrollers

What is it about?

A microcontroller is a small computer on a single chip: a processor, memory and input/output pins (GPIO) combined, built to control and read the environment in real time. It connects to sensors and actuators through digital and analog interfaces, keeps track of time with timers, and reacts quickly to events with interrupts. Understanding clock speed, communication protocols and memory types is necessary both to write working code and to judge whether it finishes its job in time.

Concepts and formulas

How to solve the problems

  1. Identify what quantity you need: voltage/duty cycle, a time interval, or a byte/bit rate.
  2. For PWM: use Vavg=D⋅VhighV_{avg}=D\cdot V_{high}, or find DD from the pulse length divided by the period.
  3. For timing: find the time per clock cycle (1/f1/f) and multiply by the number of cycles or instructions.
  4. For communication: count the bits per transmitted unit (UART has start/stop bits, SPI and I²C normally do not) and divide the clock frequency by that number.
  5. Check whether the answer is realistic: microseconds for single instructions, milliseconds for typical timer periods.

Example

A program with 200 instructions, each taking 4 clock cycles, runs on a microcontroller with a clock speed of 8 MHz. How long does the program take?

  1. Total number of cycles: 200⋅4=800200\cdot4=800.
  2. Time per cycle: 1/(8⋅106)=0.1251/(8\cdot10^6) = 0.125 µs.
  3. Total time: 800⋅0.125=100800\cdot0.125 = 100 µs.

Answer: 100 µs.

Common mistakes

Instruction time == cycles divided by clock speed. Communication speed == clock speed divided by the number of bits per transmitted unit (remember start/stop bits for UART, not for SPI/I²C).

Concepts in this part

Practise microcontrollers in the app →

3. Measurement

What is it about?

Instrumentation is about turning a physical quantity (temperature, force, light, motion) into a reliable digital number a microcontroller can use. Along the way you must choose the right sensor, amplify/condition the signal, sample it at the right frequency and filter out noise and aliasing – and you need to know how much you can trust the result (accuracy, precision, resolution).

Concepts and formulas

How to solve the problems

  1. Work out which concept the problem is about: sampling/aliasing, sensor/bridge, or ADC resolution.
  2. Sampling: check whether fs>2fmaxf_s>2f_{max}. If not, find the alias frequency by folding ff around fs/2f_s/2.
  3. Anti-aliasing filter: plug ff and fcf_c into the dB formula, or find fcf_c for a desired attenuation.
  4. RTD: plug the temperature into R(T)=R0+αR0TR(T)=R_0+\alpha R_0 T.
  5. Strain gauge/bridge: use ΔR=GF⋅ε⋅R\Delta R = GF\cdot\varepsilon\cdot R directly, or compute the bridge's differential voltage from ΔR\Delta R.

Example

A PT100 sensor has R0=100R_0=100 Ω and α≈0.385\alpha\approx 0.385 Ω/°C. What resistance does it have at 80 °C?

  1. Plug into the formula: R=R0+αR0⋅T=100+0.385⋅80R = R_0 + \alpha R_0\cdot T = 100 + 0.385\cdot80.
  2. R=100+30.8=130.8R = 100 + 30.8 = 130.8 Ω.

Answer: 130.8 Ω.

Common mistakes

Always sample faster than 2fmax2f_{max}, and filter out everything above fs/2f_s/2 *before* sampling – aliasing cannot be removed afterward. Precise is not the same as accurate.

Concepts in this part

Practise measurement in the app →

Example problems with solutions

Here are some of the problems in embedded Systems and Instrumentation. In the app, calculation problems get new numbers every time, so you can practise until it sticks – and take a graded practice exam before the real one.

Number systems and digital logic: What is 0x1F in decimal?

Answer: 31

1⋅16+15=311\cdot16 + 15 = 31.

Microcontrollers: A 5 V PWM signal has a 25 % duty cycle. What is the average voltage?

Answer: 1.25 V

0.25⋅5=1.250.25\cdot 5 = 1.25 V.

Measurement: The Nyquist criterion says the sampling frequency must be …

Answer: more than twice the highest frequency in the signal

Otherwise you get aliasing.

Number systems and digital logic: What is the binary number 1010 in decimal?

Answer: 10

8+2=108 + 2 = 10.

Practise all the problems →

Matches these university courses

The content covers the syllabus found in engineering degrees, for example: