Line Following Car - Raspberry pi Pico
Project
Title: Line Following Car using Raspberry Pi Pico
Overview
The Pico is a low-cost, high-performance microcontroller board built around the Raspberry Pi RP2040 chip. The Pico features flexible digital interfaces and can be easily programmed over USB using C/C++ or Micro Python, thanks to a comprehensive SDK with software examples and full documentation.
· Raspberry Pi designed RP2040 chipset
· Dual core ARM Cortex M0+ processor at up to 133MHz with variable core frequency
· 264kB SRAM & 2MB onboard flash memory
· 26 Multifunction GPIO pins (23x digital only, 3x ADC capable)
· 2x SPI, 2x I2C, 2x UART, 3x 12-bit ADC and 16x controllable PWM channels
· The Pico can be surface mounted as a module
· Accurate clock and timer on chip
· Temperature sensor
· Accelerated floating point libraries
· Micro USB port for power & data
· 3-pin ARM Serial Wire Debug (SWD) port
Raspberry Pi Pico is the debut microcontroller-class board from Raspberry Pi. Built around our RP2040 silicon platform, Pico brings our signature values of high performance, low cost, and ease of use to the microcontroller space.
With a large on-chip memory, symmetric dual-core processor complex, deterministic bus fabric, and rich peripheral set augmented with our unique Programmable I/O (PIO) subsystem, RP2040 provides professional users with unrivalled power and flexibility. With detailed documentation, a polished MicroPython port, and a UF2 bootloader in ROM, it has the lowest possible barrier to entry for beginner and hobbyist users.
RP2040 is manufactured on a modern 40nm process node, delivering high performance, low dynamic power consumption, and low leakage, with a variety of low-power modes to support extended-duration operation on battery power.
Raspberry Pi Pico pairs RP2040 with 2MB of Flash memory, and a power supply chip supporting input voltages from 1.8-5.5V. It provides 26 GPIO pins, three of which can function as analogue inputs, on 0.1”-pitch through-hole pads with castellated edges. Raspberry Pi Pico is available as an individual unit, or in 480-unit reels for automated assembly.
Specification
Form factor: | 21 mm × 51 mm |
CPU: | Dual-core Arm Cortex-M0+ @ 133MHz |
Memory: | 264KB on-chip SRAM; 2MB on-board QSPI flash |
Interfacing: | 2 6 GPIO pins, including 3 analogue inputs |
Peripherals: | • 2 × UART |
| • 2 × SPI controllers |
| • 2 × I2C controllers |
| • 16 × PWM channels |
| • 1 × USB 1.1 controller and PHY, with host and device support |
| • 8 × PIO state machines |
Input power: | 1.8–5.5V DC |
Operating temperature: | -20°C to +85°C |
Production lifetime: | R aspberry Pi Pico will remain in production until at least January 2028 |
Physical Specification
WARNINGS
• Any external power supply used with Raspberry Pi Pico shall comply with relevant regulations and standards applicable in the country of intended use.
• This product should be operated in a well-ventilated environment, and if used inside a case, the case should not be covered.
• Whilst in use, this product should be placed on a stable, flat, non-conductive surface, and should not be contacted by conductive items.
• The connection of incompatible devices to Raspberry Pi Pico may affect compliance, result in damage to the unit, and invalidate the warranty.
• All accessories used with this product should comply with relevant standards for the country of use and be marked accordingly to ensure that safety and performance requirements are met.
• The cables and connectors of all peripherals used with this product must have adequate insulation so that relevant safety requirements are met.
SAFETY INSTRUCTIONS
To avoid malfunction or damage to this product, please observe the following:
• Do not expose to water or moisture, or place on a conductive surface whilst in operation.
• Do not expose to heat from any source; Raspberry Pi Pico is designed for reliable operation at normal ambient temperatures.
• Take care whilst handling to avoid mechanical or electrical damage to the printed circuit board and connectors.
• Whilst it is powered, avoid handling the printed circuit board, or only handle it by the corners to minimise the risk of electrostatic discharge damage.
Introduction to Project:
This paper is intended on a practical approach to design a prototype Robotic Vehicle by using application of Arduino Programming. The robotic vehicle follows a specified path using an IR sensor. The designed robotic vehicle was smart enough to follow the path and directions in given space. It moves& navigates automatically on specified black lines marked on surface. A customized programme coding was also done to perform customized function. Such programmed robot may be useful in several mechanical, industrial, medical & Army operations and can save cost of human labor, human life at hazardous location & time.
A line follower robot vehicle is capable of moving on black line on the surface without requiring either a guide or remote control. Robots are smart machines designed to reduce manpower at work. It is often developed to reduce risk factors to human work and increase worker comfort. Younus et al mentioned in their paper that High performance, precision, low labor costs and the ability to work in hazardous locations put the robot at an advantage compared to many other similar technologies (Younus, Gadekar &Walse1). This paper is on actual making of original design and tests the functions of basic robotic vehicle using Arduino application by author. The robot vehicle was smart enough to follow automatically and navigate on black stripped line on the surface while using IR sensor and ATmega 328 microcontroller. The Arduino application is useful in designing of guided robots at low cost. Such battery backed up robotic vehicle may be used in many applications such as in hazardous mining operation, support to hospital patients, many surface agricultural operations and army operations without using human power, such design not only save labor cost & time but precious human life at low investment. and much time can be save.
Conceptualization of Idea & making of prototype smart Robotic Vehicle by using Raspberry pi pico Programming Idea behind making this robotic vehicle came out of interest and curiosity. Focused study materials were studied to develop the conceptual background for making smart robotic vehicle. Simultaneously, some working models were also observed to work upon the idea, and it was tried that a low-cost design can be developed to solve the day to day issue in many operations. Lots of thinking and brain storming was put to start work on the concept. Guidance and assistance from faculty, parents, friends & professionals were also taken to start the groundwork and finally design of this machine was made. However, overall idea was to design such a basic robot which can assist & support in reducing cost of operations in day-to-day operations at many working places and also to reduce risk to human life at hazardous place. Design and construction of Line follower Smart Robot Vehicle Based on the conceptual background and study of predesigned model of machine, an action plan was prepared to develop a low-cost working model.
Materials Required:
· Raspberry Pi Pico (any model should work)
· IR Sensor (2Nos)
· DC Gear Motor (2Nos)
· L293D Motor Driver
· Chaises
· Power bank
About Components:-
v IR Sensor:
IR sensor is an electronic device, that emits the light in order to sense some object of the surroundings. An IR sensor can measure the heat of an object as well as detects the motion. Usually, in the infrared spectrum, all the objects radiate some form of thermal radiation. These types of radiations are invisible to our eyes, but infrared sensor can detect these radiations.
The emitter is simply an IR LED (Light Emitting Diode) and the detector is simply an IR photodiode . Photodiode is sensitive to IR light of the same wavelength which is emitted by the IR LED. When IR light falls on the photodiode, the resistances and the output voltages will change in proportion to the magnitude of the IR light received.
There are five basic elements used in a typical infrared detection system: an infrared source, a transmission medium, optical component, infrared detectors or receivers and signal processing. Infrared lasers and Infrared LED’s of specific wavelength used as infrared sources.
The three main types of media used for infrared transmission are vacuum, atmosphere and optical fibers. Optical components are used to focus the infrared radiation or to limit the spectral response.
IR Sensors emit and receive Infrared radiation. They are often used as Proximity Sensors i.e. detect and alarm if an object is close to the sensor. Let me help you understand better about IR Sensors by giving two real life applications of IR Sensors. The first one is Mobile Phones.
Almost all mobile phones nowadays have IR Sensors in them. Usually, they will be placed near the earpiece on the phone. When the user make or receives a phone call, the IR Sensor detects how far the phone is from the user’s ear. If it is close to the ear, the phone’s display will be turned off so that you do not touch anything on the screen accidently.
Another important application is in automobiles. All modern cars are equipped with reverse parking sensor that sense how far you can reverse your car without hitting anything. These reverse sensors are implemented using IR Sensors.
An IR Sensor Module basically consists of three parts: an IR Transmitter, an IR Detector and a control circuit.
Usually, an IR LED is used as an IR Transmitter and a Photo Diode or a Photo Transistor (less often) is used as an IR Detector. The control circuit consists of a Comparator IC with necessary components.
Based on the application and requirement, IR Sensors can be implemented in two ways. In the first method, both the IR Transmitter and the IR Detector are placed side-by-side. In the second setup, the IR Transmitter and the IR Detector are placed facing each other.
Types of IR Sensor
There are two types of IR sensors are available and they are,
· Active Infrared Sensor
· Passive Infrared Sensor
Active Infrared Sensor
Active infrared sensors consist of two elements: infrared source and infrared detector. Infrared sources include the LED or infrared laser diode. Infrared detectors include photodiodes or phototransistors. The energy emitted by the infrared source is reflected by an object and falls on the infrared detector.
Passive Infrared Sensor
Passive infrared sensors are basically Infrared detectors. Passive infrared sensors do not use any infrared source and detector. They are of two types: quantum and thermal. Thermal infrared sensors use infrared energy as the source of heat. Thermocouples, pyroelectric detectors and bolometers are the common types of thermal infrared detectors. Quantum type infrared sensors offer higher detection performance. It is faster than thermal type infrared detectors. The photo sensitivity of quantum type detectors is wavelength dependent.
IR Sensor Working Principle
There are different types of infrared transmitters depending on their wavelengths, output power and response time. An IR sensor consists of an IR LED and an IR Photodiode, together they are called as PhotoCoupler or OptoCoupler.
IR Transmitter or IR LED
Infrared Transmitter is a light emitting diode (LED) which emits infrared radiations called as IR LED’s. Even though an IR LED looks like a normal LED, the radiation emitted by it is invisible to the human eye
IR Receiver or Photodiode
Infrared receivers or infrared sensors detect the radiation from an IR transmitter. IR receivers come in the form of photodiodes and phototransistors. Infrared Photodiodes are different from normal photo diodes as they detect only infrared radiation. Below image shows the picture of an IR receiver or a photodiode,
Different types of IR receivers exist based on the wavelength, voltage, package, etc. When used in an infrared transmitter – receiver combination, the wavelength of the receiver should match with that of the transmitter.
The emitter is an IR LED and the detector is an IR photodiode. The IR photodiode is sensitive to the IR light emitted by an IR LED. The photo-diode’s resistance and output voltage change in proportion to the IR light received. This is the underlying working principle of the IR sensor.
When the IR transmitter emits radiation, it reaches the object and some of the radiation reflects back to the IR receiver. Based on the intensity of the reception by the IR receiver, the output of the sensor defines.
Applications of IR Sensor
Night Vision Devices
Radiation Thermometers
IR Imaging Devices
Other Key Application Areas
Other key application areas that use infrared sensors include:
Climatology
Meteorology
Photobiomodulation
Flame Monitors
Gas detectors
Water analysis
Moisture Analyzers
Anesthesiology testing
Petroleum exploration
Rail safety
Gas Analyzers
v DC Gear Motor:
Workings of a brushed electric motor with a two-pole rotor (armature) and permanent magnet stator. "N" and "S" designate polarities on the inside axis faces of the magnets; the outside faces have opposite polarities. The + and - signs show where the DC current is applied to the commutator which supplies current to the armature coils
A DC motor is any of a class of rotary electrical motors that converts direct current (DC) electrical energy into mechanical energy. The most common types rely on the forces produced by magnetic fields. Nearly all types of DC motors have some internal mechanism, either electromechanical or electronic, to periodically change the direction of current in part of the motor.
DC motors were the first form of motor widely used, as they could be powered from existing direct-current lighting power distribution systems. A DC motor's speed can be controlled over a wide range, using either a variable supply voltage or by changing the strength of current in its field windings. Small DC motors are used in tools, toys, and appliances. The universal motor can operate on direct current but is a lightweight brushed motor used for portable power tools and appliances. Larger DC motors are currently used in propulsion of electric vehicles, elevator and hoists, and in drives for steel rolling mills. The advent of power electronics has made replacement of DC motors with AC motors possible in many applications.
v L293D Motor Driver:
I’ve used L293D Motor Driver IC for controlling a DC Motor with Raspberry Pi. It is a very common motor driver IC which is capable of driving two motors with individual currents up to 600mA. The Pin diagram of the L293D Motor Driver IC, along with the pin description is shown in the following image.
Features
· 8-Bit Serial-In, Parallel-Out Shift
· Wide Operating Voltage Range of 2 V to 6 V
· High-Current 3-State Outputs Can Drive Up To 15 LSTTL Loads
· Low Power Consumption, 80-µA Max ICC
· Typical tpd = 13 ns
· Low Input Current of 1
· Shift Register Has Direct Clear
Concepts of Line Follower
Line Follower Robot is able to track a line with the help of an IR sensor. This sensor has a IR Transmitter and IR receiver. The IR transmitter (IR LED) transmits the light and the Receiver (Photodiode) waits for the transmitted light to return back. An IR light will return back only if it is reflect by a surface. Whereas, all surfaces do not reflect an IR light, only white the colour surface can completely reflect them and black colour surface will completely observe them as shown in the figure below. Learn more about IR sensor module here.
Now we will use two IR sensors to check if the robot is in track with the line and two motors to correct the robot if its moves out of the track. These motors require high current and should be bi-directional; hence we use a motor driver module like L293D. We will also need a computational device like Raspberry Pi to instruct the motors based on the values from the IR sensor. A simplified block diagram of the same is shown below.
These two IR sensors will be placed one on either side of the line. If none of the sensors are detecting a black line them they PI instructs the motors to move forward as shown below
If left sensor comes on black line then the PI instructs the robot to turn left by rotating the right wheel alone.
If right sensor comes on black line then the PI instructs the robot to turn right by rotating the left wheel alone.
If both sensors comes on black line, robot stops.
This way the Robot will be able to follow the line without getting outside the track. Now let us see how the circuit and Code looks like.
Raspberry Pi Line Follower Robot Circuit Diagram and Explanation:
The complete circuit diagram for this Raspberry Pi Line Follower Robot is shown below
As you can see the circuit involves two IR sensor and a pair of motors connected to the Raspberry pi. The complete circuit is powered by a Mobile Power bank
Pin Diagram:
As shown in the picture the top left corner pin of the PI is the +5V pin, we use this +5V pin to power the IR sensors as shown in the circuit diagram (red wired). Then we connect the ground pins to the ground of the IR sensor and Motor Driver module using black wire. The yellow wire is used to connect the output pin of the sensor 2 and 3 to the GPIO pins and 3 respectively.
To drive the Motors, we need four pins (A,B,A,B). This four pins are connected from GPIO6,7,8 and 9 respectively. The orange and white wire together forms the connection for one motor. So we have two such pairs for two motors.
The motors are connected to the L293D Motor Driver module as shown in the picture and the driver module is powered by a power bank. Make sure that the ground of the power bank is connected to the ground of the Raspberry Pi, only then your connection will work.
Programming your Raspberry PI:
Once you are done with your assembly and connections your robot should look something like this.
Now, it is time to program our bot and get it running. The complete code for this bot can be found at the bottom of this tutorial.
We are going to import GPIO file from library, below function enables us to program GPIO pins of PI. Now let’s see the code.
Program:-
Get the code of this project from the GitHub link
https://github.com/ph143/Line-following-Car.git
Project Output Video:
Comments
Post a Comment