All paths

Compression, encoding and checksums

Get a space probe's telemetry and pictures home over a noisy link, in Python on a Raspberry Pi: bits and bytes, run length and Huffman coding, Base64, parity, checksums and CRC-32, ending in a file transfer that survives the noise.

Raspberry Pi 4 Model BFree7 lessons6 h4 chapters2,515 XPCoding · Advanced+250 XP

0 of 7 done

What you will build

3 projects, built step by step

7 lessons in 4 chapters, about 6 hours on a simulated Raspberry Pi 4 Model B. Free, in your browser, every step checked by the simulator.

Chapter 1 project

Run length

The simplest compression there is: a picture of space is mostly black, so say "37 dark pixels" instead of listing them. Runs, packing them into bytes, decoding to prove nothing was lost, and the input that makes it worse than nothing.

Open it in the simulator
Chapter 2 project

Base64

Some links only carry text: email, JSON, a URL, an old radio modem. Base64 turns any bytes into 64 safe characters, 3 bytes to 4 at a time. Write the encoder and decoder from the bits up, with padding, and check them against Python's own.

Open it in the simulator
Chapter 3 project

CRC checks

The check inside Ethernet, ZIP, PNG and spacecraft links: a cyclic redundancy check is the remainder of a polynomial division done with XOR. Write CRC-8 and CRC-32 bit by bit, prove CRC-32 against binascii, speed it up with a table, and test it against a thousand noisy frames.

Open it in the simulator
The map

Chapter by chapter

Each lesson opens when the one before it is done, and each chapter ends in a project.

Chapter 1

Bytes

What the probe sends, packed tight, and the simplest compression.

  1. Open250 XP

    Bits and bytes

    Everything a space probe sends home is bytes. Text as bytes, binary and hex, packing telemetry into 5 bytes instead of 11 with struct, and eight on-off flags squeezed into a single byte with shifts and masks.

    0 of 5 steps

  2. ProjectLocked500 XP

    Run length

    The simplest compression there is: a picture of space is mostly black, so say "37 dark pixels" instead of listing them. Runs, packing them into bytes, decoding to prove nothing was lost, and the input that makes it worse than nothing.

    0 of 5 steps

4 questions, graded as you go.
Chapter 2

Codes

Shorter codes for common letters, and safe characters for any bytes.

  1. Locked250 XP

    Huffman

    Give common letters short codes and rare ones long codes: count letters, build a Huffman tree with a priority queue, encode a status report in far fewer than 8 bits a letter, and decode it by walking the tree.

    0 of 5 steps

  2. ProjectLocked500 XP

    Base64

    Some links only carry text: email, JSON, a URL, an old radio modem. Base64 turns any bytes into 64 safe characters, 3 bytes to 4 at a time. Write the encoder and decoder from the bits up, with padding, and check them against Python's own.

    0 of 5 steps

4 questions, graded as you go.
Chapter 3

Checks

Catch the bit flips: parity, checksums and the CRC.

  1. Locked250 XP

    Parity and checksums

    Space is noisy, and a flipped bit turns -12 into -76. Simulate the link with seeded bit flips, catch single flips with a parity bit, watch two flips sneak past, then add a checksum, find its blind spot, and close it with Fletcher's checksum.

    0 of 5 steps

  2. ProjectLocked500 XP

    CRC checks

    The check inside Ethernet, ZIP, PNG and spacecraft links: a cyclic redundancy check is the remainder of a polynomial division done with XOR. Write CRC-8 and CRC-32 bit by bit, prove CRC-32 against binascii, speed it up with a table, and test it against a thousand noisy frames.

    0 of 5 steps

4 questions, graded as you go.
Chapter 4

Project

A picture home, intact.

  1. Locked265 XP

    Project: a reliable file transfer

    Bring the course together and get a picture home over a link that corrupts a third of everything: frames with a sequence number and a CRC-32, a receiver that rejects bad ones, stop-and-wait resends until every frame arrives, run length compression to send fewer frames, and lamps that show each frame land.

    0 of 6 steps

4 questions, graded as you go.
Syllabus

Every lesson in the course

All 7 lessons, in order, each with what it covers. Any of them opens in the editor right away.

Chapter 1

Bytes

  1. Bits and bytesEverything a space probe sends home is bytes. Text as bytes, binary and hex, packing telemetry into 5 bytes instead of 11 with struct, and eight on-off flags squeezed into a single byte with shifts and masks.
  2. Run lengthThe simplest compression there is: a picture of space is mostly black, so say "37 dark pixels" instead of listing them. Runs, packing them into bytes, decoding to prove nothing was lost, and the input that makes it worse than nothing.
Chapter 2

Codes

  1. HuffmanGive common letters short codes and rare ones long codes: count letters, build a Huffman tree with a priority queue, encode a status report in far fewer than 8 bits a letter, and decode it by walking the tree.
  2. Base64Some links only carry text: email, JSON, a URL, an old radio modem. Base64 turns any bytes into 64 safe characters, 3 bytes to 4 at a time. Write the encoder and decoder from the bits up, with padding, and check them against Python's own.
Chapter 3

Checks

  1. Parity and checksumsSpace is noisy, and a flipped bit turns -12 into -76. Simulate the link with seeded bit flips, catch single flips with a parity bit, watch two flips sneak past, then add a checksum, find its blind spot, and close it with Fletcher's checksum.
  2. CRC checksThe check inside Ethernet, ZIP, PNG and spacecraft links: a cyclic redundancy check is the remainder of a polynomial division done with XOR. Write CRC-8 and CRC-32 bit by bit, prove CRC-32 against binascii, speed it up with a table, and test it against a thousand noisy frames.
Chapter 4

Project

  1. Project: a reliable file transferBring the course together and get a picture home over a link that corrupts a third of everything: frames with a sequence number and a CRC-32, a receiver that rejects bad ones, stop-and-wait resends until every frame arrives, run length compression to send fewer frames, and lamps that show each frame land.
Kits

Build it on your bench too

Every lesson runs in the simulator with nothing to buy. When you want the real thing, these kits have the parts.

Have a kit already?

Find your kit

Pick the starter kit you own and run every lesson in its manual with the same parts on the same pins.

See every kit
Questions

About Compression, encoding and checksums

Is Compression, encoding and checksums free?

Yes. All 7 lessons of Compression, encoding and checksums are free and run in your browser, with nothing to install and no parts to buy before you start.

Do I need a real Raspberry Pi 4 Model B?

No. Every lesson runs on a simulated Raspberry Pi 4 Model B with its parts on the canvas, and the simulator checks each step as you go. When you want to build it for real, the same wiring and code work on a real board.

How long does Compression, encoding and checksums take?

About 6 hours: 7 lessons in 4 chapters, each one a few short steps. Your progress is kept, so you can stop after any lesson and pick up where you left off.

What will I build?

Each chapter ends in a project that puts it together: Run length, Base64 and CRC checks.

Where do I start?

With "Bits and bytes", and each lesson builds on the one before it. New to circuits? Electronics basics is the course that starts from zero.