UAT 204 Microcontrollers and Embedded Systems

Worksheet 4 Connecting a sensor and sending serial data

Lab 6 hAssesses CLO3

Objective

Read a sensor over I2C, analyse bus signals, send checksummed frames over UART and identify DroneCAN device settings

Equipment and materials

  • Pico 2 board
  • I2C sensor such as the training board's barometer or IMU
  • Logic analyzer
  • USB-UART adapter
  • Computer with Python
  • ArduPilot DroneCAN documentation

Safety

  • Low-voltage bench work; check the sensor's logic level matches 3.3 V before connecting
  • Share ground between the board and the USB-UART adapter

Steps

  1. Connect the I2C sensor, scan the bus for addresses and read values
  2. Capture SDA and SCL; identify start, address, ACK and data
  3. Send Example 2 frames over UART to the computer
  4. Write a receiver that checks the checksum
  5. Set a wrong baud rate on one side; observe and explain
  6. Study ArduPilot's DroneCAN page and list the parameters for a DroneCAN GPS

Record of results

Table 1 I2C bus scan and sensor readings
Address found (hex)Device per datasheetReading (with unit)Plausible?
Table 2 Parts of the captured I2C signal
Signal partValue read (hex)Time taken (µs)Meaning
Table 3 UART frames sent and checksum results
Test caseBaud sender / receiverBytes received (hex)Checksum resultExplanation

Questions

  1. How many bytes is the Example 2 frame, how long does one frame take at your baud rate in µs, and what share of the link does it use if sent every 100 ms?

  2. With mismatched baud rates, what did the received data look like, and why does the checksum let the receiver know the data is unusable?

  3. Does a passing XOR checksum always mean the data is correct and fit to control with? Give a case where the checksum passes but the data should not be used.

  4. From ArduPilot's DroneCAN page, why do larger drones put the GPS, ESCs and power module on a CAN bus instead of separate UART wires to each?

Check before you hand in

What to hand in

  • Sensor address and readings
  • Annotated I2C capture
  • Sender and receiver code with checksum results
  • Wrong-baud explanation and DroneCAN parameter list

CLO3 Interface devices via UART, I2C, SPI and CAN. (CLOs are a web-team draft; the course owner sets the final ones.)

Instructors: answers and teaching notes for this worksheet are in the teaching pack