The hardware layer in AMRs: an inventory of physical I/O
Atlasbot · 22/8/2026 · 11 min read
Category Hardware AMR studied each individual component — Motor, Encoder, LiDAR, IMU, Bumper. This article places them in the right place in the 5-layer model learned in lesson AMR Architecture: all those components, along with the minimum code that directly reads/writes them, make up Hardware Layer.
Key concepts
Hardware Layer includes 2 groups of physical components, connected directly to the MCU:
- Sensors (input) — Encoder, IMU, LiDAR, Camera, Bumper — learned in detail in the Hardware AMR section
- Actuator (output) — Motor + Motor Driver, E-Stop relay, signal light/horn
Important boundary to remember: Hardware Layer only reads/writes raw signals (voltage levels, PWM pulses, digital pulses) — it does not interpret, does not parse into meaningful messages. That interpretation is the responsibility of the Driver Layer (learned in the previous lesson), not the Hardware Layer.
How it works
At this level, the MCU only performs the lowest level operations: reading the voltage level on a GPIO pin, counting interrupt pulses from the encoder, and outputting the PWM duty cycle value to the motor driver. There is no control logic, no data analysis — those things belong to the Driver Layer (translating data to ROS2 messages) or higher layers.
Confusable point: many operations at this layer are actually related to hardware configuration of the MCU itself — choosing the correct interrupt support pin for the encoder, choosing the correct hardware PWM support pin for the motor driver, configuring the correct I2C/SPI bus speed for the IMU/LiDAR. This is why choosing an MCU (STM32/ESP32...) is not only based on processing speed but also carefully on the number and type of peripheral pins available.
Technical details
Formulas
I/O pin budget needed for a typical AMR — calculate the total before choosing an MCU, avoid situations where you discover there aren't enough pins after designing:
Number of interrupt pins needed = Number of wheels × 2 (each quadrature encoder needs 2 A/B channels)
For example: Differential Drive (2 wheels) → needs 4 pins to support disconnection
Mecanum Drive (4 wheel) → 8-pin lever to support disconnection
Number of PWM pins needed = Number of wheels (each motor driver needs at least 1 speed PWM channel,
plus 1-2 digital pins to control direction depending on driver type)
Parameters
| Components | Type of connection needed | Typical number of pins |
|---|---|---|
| Encoder (per wheel) | 2 interrupt support pins (channels A, B) | 2 × number of wheels |
| IMU | I2C (2 pins, can share bus) | 2 (shared with other I2C devices) |
| LiDAR | Separate UART (2 pins) or USB | 2 (or 0 if via USB directly to SBC) |
| Motor Driver (each wheel) | 1 PWM + 1-2 digital direction control | 2-3 × number of wheels |
| Bumper/E-Stop | Digital input, often requires high priority interrupts | 1 per sensor |
Practical applications
In the actual architecture of the Atlas A2 project (mentioned in many articles in the Hardware AMR category), the ESP32 takes on the role of this Hardware Layer - reading the encoder via interrupt, reading the high priority bumper/E-Stop signal, outputting PWM to the TSDA-C12D driver to control the TODE brushless motor. Choosing the ESP32 over a cheaper MCU (like a basic, pin-less Arduino Uno) largely comes down to exactly this I/O pin budget problem — the number of sensors + actuators that need to read/write simultaneously exceeds the capabilities of lower-end MCUs.
Practical example
Scenario: AMR Mecanum Drive (4 wheel), with IMU, LiDAR via separate USB to SBC
(not via MCU), 2 bumper sensors, 1 E-Stop button
Calculate the pin budget for the MCU:
- Encoder: 4 wheels × 2 channels = 8 interrupt support pins
- IMU (I2C): 2 pins (SDA, SCL)
- LiDAR: 0 MCU pins (connect directly from USB to SBC, not through MCU)
- Motor Driver: 4 wheels × 3 pins (1 PWM + 2 DC) = 12 pins
- Bumper: 2 high priority interrupt pins
- E-Stop: 1 highest priority interrupt pin
Total: 8 + 2 + 12 + 2 + 1 = 25 pins, of which 11 pins need interrupt support
→ ESP32 (34 available GPIOs, most support interrupts) responds comfortably
→ Arduino Uno (only 2 real external interrupt pins) is completely inadequate for this configuration
Common mistakes
- Not checking whether the pin actually supports interrupts before designing the circuit — not all GPIOs support hardware interrupts, mistakenly assigning an encoder pin to an unsupported pin causes having to read by polling (waste CPU, easy to miss pulses at high speed).
- Shared I2C bus for devices with identical addresses — 2 IMUs of the same type with the same default I2C address will conflict if the address is not reconfigured or a multiplexer is used.
- Putting processing logic into the Hardware Layer instead of just raw read/write — violates the boundary with the Driver Layer, making the code difficult to separate when needing to change the communication protocol above.
- Suppress the interrupt priority requirement for the safety signal (bumper/E-Stop) — if the bumper interrupt has the same priority as the high-frequency encoder interrupt, the safety signal may be delayed in processing in a situation where multiple interrupts occur simultaneously.
Conclusion
The Hardware Layer is where all the software layers above depend, but it itself should contain only the simplest read/write of raw signals — no logic, no interpretation. Calculating the correct I/O pin budget before selecting an MCU avoids having to redesign hardware midway through the project. The next article in the category — Driver Layer — is available, diving into how raw data from this layer is translated into meaningful ROS2 messages.
Get new articles and lessons by email
When a new technical article or course module is published, Atlas Robotics sends you a short email. No spam.
Unsubscribe any time with the link in each email. See our Privacy policy.