Page 94 - Toucpad robotics C11
P. 94
Difference in Approach
Microcontroller Programming: Often involves direct interaction with the hardware registers and memory.
u
Programs are typically written in lower-level languages like C or Assembly, or higher-level languages specific to the
platform (like Arduino C++). The code is compiled into a small binary file and “flashed” onto the microcontroller’s
program memory.
Single Board Computer Programming: Involves writing programs that run on an operating system (like Linux).
u
This allows for using higher-level languages like Python, C++, or Java, and leveraging powerful libraries for Artificial
Intelligence, computer vision, and networking. The development environment is often more complex but offers greater
flexibility and computing power.
Application in Robotics
Microcontrollers: Ideal for real-time, low-level control (e.g., precise motor control, reading raw sensor data,
u
implementing PID loops for individual joints).
Single Board Computers: Ideal for high-level decision-making, running complex Artificial Intelligence algorithms
u
(e.g., object recognition from camera feeds, global path planning, human-robot interaction using natural language
processing), and coordinating multiple subsystems. Many advanced robots combine both: an Single Board Computer
for high-level intelligence and microcontrollers for low-level hardware control.
Robot Mistakes Human for a Button
During a tech camp in Europe, a humanoid robot tried to learn “button-pressing.” When a
volunteer wore a shirt with shiny buttons, the robot kept poking his stomach, thinking it was a
“power switch!” Laughter filled the room, and engineers updated its “button image database.”
actual funny
incidents Learning: Robots need visual training, or they’ll confuse clothes with controls.
Basic Embedded C Programming
Description
Embedded C programming refers to writing code in the C programming language specifically for embedded systems,
which are computer systems designed for a dedicated function within a larger mechanical or electrical system.
Microcontrollers are prime examples of embedded systems. C is a very popular choice for embedded programming due
to its efficiency, direct hardware access capabilities, and wide availability of compilers for various microcontrollers.
Why C for Robotics/Embedded Systems?
Close to Hardware: C allows programmers to directly manipulate hardware resources (like Input/Output pins,
u
timers, communication interfaces) through registers, giving fine-grained control.
Efficiency: C code can be compiled into very compact and fast executable programs, which is crucial for
u
microcontrollers with limited memory and processing power.
Portability: While hardware-specific aspects exist, core C code can often be adapted for different microcontroller
u
architectures.
Memory Management: C provides tools for efficient memory management.
u
Key Concepts in Embedded C
Variables and Data Types: Defining storage for numbers, characters, etc.
u
Operators: Arithmetic, relational, logical (Boolean) operators.
u
Control Flow Statements: if-else, for loops, while loops (to implement algorithms).
u
Functions: Breaking down a program into smaller, reusable blocks of code.
u
92
Touchpad Robotics - XI

