Robotics from zero · Chapter 1
A robot is a system
A robot connects sensing, decisions and action to complete a task. Trace those connections to understand the result.
After this chapter
Identify each part’s role and choose what to check when a robot gets a task wrong.
- One loop
- 20 ms
- Loops per second
- 50
The sensor measures the distance ahead and sends the number to the controller as data.
- Energy: battery to every part
- Data: sensor to controller
- Command: controller to motor driver
- Motor needs
- 250 mA
- Source gives at most
- 1,000 mA
Through the motor driver the motor gets the current it needs from the battery.
This is a model. Its numbers explain an idea. They are not safety settings for a real robot.
See the system in three examples
Each system below has a task. Follow what it senses, how it decides and what moves. Real systems can run several loops at different speeds.
Mobile robot
Stop before an obstacle.
- SenseMeasure the distance ahead.
- DecideCompare it with a stopping rule.
- ActDrive or stop the wheels.
Robot arm
Place an object on a tray.
- SenseObserve the object’s position.
- DecideChoose where to reach.
- ActMove the joints and gripper.
Sorting system
Send a red box to a side lane.
- SenseRead the box’s color.
- DecideSelect the destination lane.
- ActActivate the diverter.
The connections behind the task
Sensors turn physical changes into data. Decisions produce commands. Actuators change the world, which is sensed again. Energy powers every part.
- Data
- Command
- Energy
Apply the idea
A sorter sends blue boxes into the red lane. What would you check, and what evidence would you look for?
Show the answer
Compare the box with the sensor reading, then check the selected lane and the diverter command. A wrong reading points to sensing. A correct reading with the wrong lane points to the decision. A correct command with the wrong motion points to the actuator.
Explore the original two-wheeled robot
Open the worked example: power, current and the control loop
A robot is a machine that senses its surroundings, decides what to do and acts. It does not need a human shape or artificial intelligence. A robot vacuum, a factory arm and a Mars rover all follow the same loop.
NASA's introduction to robotics puts it simply: some robots work by themselves, others need a person to tell them what to do.
Five parts and what each one does
- Sensor: measures something in the world, here the distance ahead, and turns it into data.
- Controller: a small computer, a microcontroller, that runs the rule again and again.
- Motor driver: a switch that lets a small command signal control a large current from the battery.
- Motors: turn electrical energy into movement of the wheels.
- Battery: stores the energy for every other part.
Why the motor needs a driver
A controller pin is built to send signals, not to power things. The ATmega328P datasheet lists 40 mA as the absolute maximum current per pin. A small DC gear motor in this model needs 250 mA.
250 mA ÷ 40 mA = 6.25, so the pin would carry 6.25 times its maximum.
How often the loop runs
One loop every 20 ms: 1000 ms ÷ 20 ms = 50 loops per second.
Real-world catch
- Motors pull the battery voltage down when they start and add electrical noise. Real robots often give the controller its own regulated supply, so a motor start does not reset it.
- The 40 mA figure is an absolute maximum, not a working value. Designs stay well below it.
- A stalled motor draws far more current than a running one. Motor drivers and batteries are chosen for that peak.
- A real robot often runs several loops at different speeds, for example a fast one for the wheels and a slower one for planning.
Check yourself
Predict first, then open the answer. Nothing is graded.
The distance sensor breaks and always reports that nothing is ahead. What does the robot do?
Show the answer
It keeps driving. The controller only knows what its sensors report, so a broken sensor makes a correct rule give the wrong command.
The loop runs once every 50 ms. How many times a second does the robot sense, think and act?
Show the answer
20 times: 1000 ms ÷ 50 ms. A slower loop means the robot reacts later, which matters in the obstacle lesson.
Why does the sensor connect straight to the controller while the motor needs a motor driver?
Show the answer
The sensor sends a signal that needs almost no current. The motor needs about 250 mA, but a controller pin gives at most 40 mA.
From model to hardware
The loop from the model fits in a few lines. This is logic to read, not wiring instructions.
every 20 ms: # repeat every 20 ms
reading = sensor.read() # sense: read the sensor
command = decide(reading) # think: apply the rule
motor_driver.set(command) # act: the driver switches battery power
On a hobby robot the controller is often a microcontroller board. The motor driver sits between the board, the battery and the motors.
Parts for this robot: a distance sensor, a microcontroller board, a motor driver, two DC gear motors, a battery pack and a caster wheel.
Terms in this lesson
- Robot
- A machine that senses, decides and acts.
- Sensor
- A part that measures something and turns it into data.
- Microcontroller
- A small computer on one chip that runs the robot's program.
- Actuator
- A part that makes something move, such as a motor.
- Motor driver
- A switch that lets a weak signal control a strong current.
- Control loop
- The cycle of sense, think and act that repeats many times a second.