Packet Checksum Calculator¶
Run the Packet Checksum Calculator MicroSim Fullscreen
You can include this MicroSim on your website using the following iframe:
<iframe src="https://dmccreary.github.io/robot-arm/sims/packet-checksum-calculator/main.html"
height="652px" width="100%" scrolling="no"></iframe>
Description¶
Build a servo instruction packet and watch its checksum worked out in three steps: add from the ID, keep the low byte, flip every bit. Then calculate the checksum of six packets yourself. Used in Chapter 4.
The packet is drawn as a row of hex bytes. The two gray FF bytes are the header and are not added. The yellow bytes, from the ID to the last parameter, are added up. The green byte is the checksum. This MicroSim is a calculator and sends nothing to any device.
Lesson Plan¶
Grade level: Middle school and up (age 12+). Time: 10 to 15 minutes.
- Start with the chapter's example. Explore mode opens on a PING to servo 1, the packet
FF FF 01 02 01 FB. Follow the three steps in the panel: add, keep the low byte, flip every bit. - Explore. Change the instruction to WRITE. The Length byte changes with the number of parameter bytes. Try a value of 255 in a one-byte register and watch the sum grow past one byte.
- Six packets. Type the checksum of each packet as two hex digits and press Check. You get one try for each packet, and 5 of 6 is mastery. After each answer the full working is shown, so you can find the step that went wrong.
- Think about it. Change one yellow byte by 1. What happens to the checksum? Why does that let a servo detect a damaged packet?
Flipping every bit of a byte is the same as subtracting it from 255, so the panel also shows that shortcut.
Specification¶
The learning objective, evidence of mastery and content for this MicroSim are specified in Chapter 4: Serial and CAN Communication.