- Introduction to PIC Microcontroller (PIC 18f4550)
- Introduction to PID algorithm
- Sensor selection
- PID Controller Algorithms
- Code & Tuning
- SCHEMATIC and simulations
Components that we have used in building a PID base Line following Robots:
- · PIC micro controller 18f4550
- · IR sensor
- · Chesses and Motor
- · LM 324
- · PID algorithm
Introduction to PIC Microcontroller (PIC 18f4550)
There were two main alternatives regarding the choice of microcontroller: PIC18F family (specifically the PIC18F4550, due to familiarity, and it having the needed features and number of ports), or Arduino (most likely the Nano or UNO, since both have enough processing power and I/O pins for it to be unnecessary to consider the more powerful models).
32 KB Flash Program Memories.
A 12 MIPS CPU
256-byte data EEPROM
1 x A/E/USART Port
1 x MSSP (SPI/I2C) Port
1 x CCP & 1 x ECCP
1 x 8-bit & 3 x 32-bit Timers
13 x 10-bit Analog Inputs
2 x Comparators.
1 x USB 2.0.
35 x Digital I/O Pins
This microcontroller has been used extensively. It can be programmed natively in Microchip PIC assembly, or in C18, Microchip’s implementation of the C programming language for use with their PIC18 line. Due to their popularity, there exist a great number of open-source projects developed for the PIC18F line, along with libraries, tutorials, and many articles on coding and developing using these microcontrollers. They are also used to great extent professionally.
IR transmitter is modulation of the information signal with the carrier signal because the receiver modules which are available off-the-shelf are made for a particular carrier frequency. So it is clear that when you chose a particular IR receiver module, you also need to transmit the modulated wave with the same carrier frequency of that of an IR receiver module. Modulating a 38 kHz carrier signal.
An IR receiver with readily available off-the-shelf modules.the receiver is designed for 38 kHz carrier signal; hence the IC selected should work for the same frequency. The IC TSOP4838 will serve as a receiver module, which is compatible with both TTL and CMOS logic. This means that we can directly get a digital signal from the receiver module and then connect it to the microcontroller. The Implementation of IR receiver is explained using an LED as an indicator.
Introduction to PID algorithm:
The Proportional Integral and Derivative (PID) controller is the control algorithm and mostly used in industrial control. PID algorithm allows engineers to operate them in a simple and straightforward way. The name shows PID, The three words Proportional, Integral, and Derivative.
The Proportional Response:
The proportional component in PID algorithm is the difference between the set point of the system and the process variable. Now, this difference is called Error. The proportional gain (Kp) is the ratio between output response and the error signal.
The Integral Response
Integral in PID is the sum of the error term over the time. If the result is a small error the integral component will increase slowly. Now the integral term will continually increase over the time unless and until the error is going to be zero, so the ultimate effect is driving the Steady-State error towards zero. The difference between the process variable and the set point is the Steady state error.
The Derivative Response:
The function of the derivative component is to decrease the output of the process variable is going to increase. The derivative is the rate of change of the process variable. The Increase in the derivative time (Td) will make the system to react strongly and to make changes in the error term.This will increase the overall speed. The very small (Td) the derivative time is used in most practical systems.Derivative Response is sensitive and highly sensitive to the noise and in the process variable. If the feedback is noisy or the control loop rate is very much slower, The control system will be unstable due to derivative response.
PID Controller Algorithms:
PID Controller Algorithms:
Using only kp parameter the robot will be applied and give the results as the classical line following algorithm discussed earlier.
Kd: kd does not allow the robot to perform any deviation
PID tuning is greatly affected by the floor where it is going to be use and the track where the robot is going be run and these physical parameters cannot be calculated mathematically. For example motor inductance, friction center of mass etc. these quantities can be just guessed and applied by hit and trial method.
In this project, our main focus was to cover the PID algorithm implementation.some of the sections about making robot are not included here.
Below is the Code of PIC microcontroller.
enable_interrupts(INT_RDA); //Serial Interrupt Enable
enable_interrupts(GLOBAL); //Global Interrupt Enable
setup_ccp1(CCP_PWM); // CCP1 Initialization
setup_ccp2(CCP_PWM); // CCP2 Initialization
totalerror=0; // PID LOOP Variables
If you have any query then comment below and Subscribe to our YouTube channel for video Tutorials,