7/21/2017

Interfacing LCD With Arduino Microcontroller

In this tutorial we are going to interface a Liquid Crystal Display (LCD) with Arduino MicrocontrollerLiquid Crystal Display are used in many devices.

Liquid Crystal Display LCD


Components Required


Hardware: 

ARDUINO UNO, 
power supply (5v),  
16X2 Liquid Crystal Display  (LCD)

Software: 

Arduino IDE

Pin Configuration

Liquid Crystal Display LCD
Pin 1GND
Pin 2+5V
Pin 3Mid terminal of potentiometer (for brightness control)
Pin 4Register Select (RS)
Pin 5Read/Write (RW)
Pin 6Enable (EN)
Pin 7DB0
Pin 8DB1
Pin 9DB2
Pin10DB3
Pin 11DB4
Pin 12DB5
Pin 13DB6
Pin 14DB7
Pin 15+4.2-5V
Pin 16GND


Description Of Pin

Register Select : RS pin is used to select the register.


RW selects either read or write mode.
Enable: E enables the LCD module.

Data Pins: Pin7 to Pin14 are data Pins.
Logic High (1) – Activates Data register.
Logic Low (0) – Activates  Instruction register.
Logic High (1) – Activates Read mode.
Logic Low (0) – Activates Write mode.
Vss: It is the Ground Pin of the module.
Vdd : It is the supply pin of the module.
VEE : Pin3 is used for controlling the brightness of the LCD. Normal setting of this pin is between 0.4V to 0.9V.A 10 k pot is connected to adjust the brightness of the screen.

Circuit Diagram:

Liquid Crystal Display LCD
Arduino Code:-


 #include
LiquidCrystal lcd (5, 4, 3, 2, 1, 0);  

Void setup ()
{
 lcd.begin(16, 2);  
}

Void loop ()
{
  lcd.setCursor (0, 0);         
  lcd.print ("Hello World"); 
  lcd.setCursor (0,1);       
  lcd.print ("16X2 LCD");     
}




2/03/2017

How to display hidden files and folders

There is a lot of method to do so, but today i am going to share the easiest method to display hidden files and folders in window.

  •  Click on start button 
  • Go to control panel


    • Click on Appearance and Personalization

    • click on Folder Options
    • Under Folder Option, do the same as follow image

    • Now restart your PC and see the magic :) ..
    But do not forget to again the restore default after finish your work.

    5/16/2016

    Line Following Robot using Microcontroller

    Line Follower Robot is simply a machine that follows line, either black or white. In this tutorial, i will teach you that how to make a line follower robot. At any instant, if you face any problem ask me in comment.
    Now, let's get start. 

    Concepts of line follower robot 

    To understand the concept of  LFR, first you have to learn about the bahaviour of light. When light fall on white surface, it reflect back and in case of black surface the light full absorb by black surface.






    1/17/2016

    PID Controller ( proportional integral derivative controller)

    A proportional–integral–derivative controller also known as a PID controller is a basic control loop response mechanism/controller which is extensively used in industrial control systems. A PID controller is used for calculating "error" values as the difference between a measured process variable and a desired set point. By adjusting the process control inputs, the controller attempts to reduce the error. Parameters of a PID controller used in the calculations must be tuned according to the nature of the system.

    Three separate parameters are involved with PID controller calculations which are; the proportional, the integral and derivative values. Proportional values determine the reaction to the current error, while integral values determine the reaction based on the sum of recent errors, and derivative values determine the reaction based on the rate at which the error has been changing. The weighted sum of the proportional, integral, and derivative actions are used to adjust the process by means of a control element such as the position of a control valve or the power supply of a heating element. Consequently, the PID controller can be illustrated as a controller that takes into account the present, the past, and the future of the error.

      
    Tuning the three constants in the PID controller algorithm, will allow the controller can provide control action designed for detailed process requirements. The response of the controller can be described in terms of the responsiveness of the controller to an error, the degree to which the controller overshoots the set point and the degree of system oscillation. Also, note that the use of the PID algorithm for control does not guarantee optimal control of the system or system stability.

    Control Loop Summary

    A basic explanation of a control loop is the simple act of adjusting hot and cold faucet valves to preserve the faucet water at the preferred temperature. Usually by mixing of the two streams, the hot and cold water, the desired temperature can be obtained. When the person touches the water to measure its temperature the sense of feel tells them if the stream of water has met the desired temperature. From this point the person will either adjust the hot and cold water valves until the preferred temperature is met and stabilized or do nothing because the desired temperature has already been met. Sensing the water temperature is equivalent to taking a measurement of the process value or process variable (PV). The desired set-point (SP) is the temperature in which the person is trying to obtain. Additionally, the water valve position which can be called the input to the process is known as the manipulated variable (MV), which basically means that one can change the values of this variable. Moreover, in this example the difference between the desired set-point and the temperature measurement is known to be the error (e). The error will quantify if the water is too hot or cold and by how much.

    After measuring the process variable (PV) or in this case the temperature, then calculating the error, the controller determines when to change the manipulated variable (MV) or tap position and by how much. Once the controller turns on the water, they might turn the hot valve slightly if warm water is preferred, or they may turn it all the way. This is an example of the proportional control. To speed up the process so that the water becomes hot faster, the controller may open the valve more and more as the time elapse, this is an simple example of an integral control. By using both the proportional and integral control methods, the water temperature has the potential to oscillate between hot and cold. This is due to the fact that the controller is over-compensating and overshooting the desired set-point at a rapid rate.

    If the controller wanted to achieve the desired temperature on a more gradual convergence, the controller can damp the anticipated future oscillations. In other words the controller may elect to temper their adjustments; this can be referred as a derivative control method.

    PID Controller Theory

    As stated in the previous sections the PID control scheme is named after its three correcting terms, whose sum constitutes the manipulated variable (MV). Which presents the equation:


    MV(t)=Pout+Iout+Dout           
    where
    • Pout is the proportional term
    • Iout is the integral term
    • Dout is the derivative term
    These terms are the contributions to the output from the PID controller.

    Proportional term


    The proportional term which can also be referred to as gain, makes a change to the output that is proportional to the current error value. By multiplying the error by a constant Kp, which is known as the proportional gain, the proportional response can be adjusted.
    The proportional term is given by:
      

    Pout=Kpe(t)          
    where
    • Pout: Proportional term of output
    • Kp: Proportional gain, a tuning parameter
    • e: Error = SP - PV
    • t: Time or instantaneous time (the present)
    When the proportional gain has a value it results in a large change in the output in the given change in the error. As a result of the proportional gain being out of range or too high, the system can eventually become unstable. On the other hand, if the proportional gain is very small it will result in an output response to a large error in the input which will also make the responsive controller lessen. Additional having a proportional gain that is too low may cause the t control action to be too small when it tries to respond to the system.

    Integral Term

    The integral term which can also be called the reset, its contribution is proportional to the magnitude and duration of the error. By the summation of the instantaneous error over the time, which is basically the integration of the error, gives the accumulated offset that should have been corrected previously. This accumulated error is multiplied by the integral gain then added to the controller output. Additionally, the integral gain, Ki, determines just how much the integral term will contribute to the total control action.
    The integral term is given by:
    (3)

    Iout=kit0e(τ)dτ
    where
    • Iout: Integral term of output
    • Ki: Integral gain, a tuning parameter
    • e: Error = SP - PV
    • t: Time or instantaneous time (the present)
    • τ: a dummy integration variable
    When added to the proportional term, the integral term accelerates the movement of the process towards the desired set-point which will eliminate the residual steady state error which occurs with the proportional controller. The one drawback from the integral term is the simple fact that it responds to an accumulated error from the past which can cause the present values to overshoot the desired set-point value.

    Derivative Term


    By determining the slope of the error over time and multiplying that rate of change, which is done by the derivative gain Kd, the rate of change of the process error is calculated. From here, the magnitude of the contribution of the derivative term which is also known as the rate, to the overall control action is called the derivative gain, Kd.
    The derivative term is given by:
       

    Dout=Kdddte(t)  
    where:
    • Dout: Derivative term output
    • Kd: Derivative gain, a tuning parameter
    • e: Error = SP - PV
    • t: Time or instantaneous time (the present)
    A noticeable slow down in the rate of change close to the controller set point is done by the derivative term. Therefore, the derivative control helps reduce the magnitude of the overshoot which is the result of the integral component while also improving the combined controller-process stability.

    Summing the Terms

    Thus, these three terms are then added up to produce the output for the PID controller. The final form of the PID algorithm is:


    u(t)=MV(t)=Kpe(t)+Kit0e(τ)dτ+Kdddte(t)
    Where u(t) is defined as the controller output.

    Reference



    12/29/2015

    Line Following Robot

    Line following robots have been around for years, so many people have had chances to attack this sort of problem. Line following robots can be very basic or very sophisticated depending on the hardware used, efficiency wanted, and programming capabilities. In the history of line following robots the differential steering system is the most widely used way of keeping the robot on course. Infrared (IR) sensors are used more frequently in line following robots then any other sensor.

    Hardware

    The four main Hardware items needed to build and control a line following robot are Sensors, Micro-controllers, Drivers, and Motors.

    Sensors

    As mentioned before IR sensors are the most popular sensor used in the line following robot field. IR sensors have two IR LED, one is the Emitter and the other is the Receiver. An electrical property of these LED is that they produce a voltage difference across its leads when it is subjected to light. This voltage can barely be detected. An Op-Amp is normally used to increase this voltage to a reasonably detectable range. By amplifying the voltage, the changes in voltage will be easier to detect.

    There are many other sensors that can be used to detect lines. Photo-cells and Photo-resistors are two other common sensors used.

    The image below is a commercially available single line following IR sensor. It needs only 5 volts to run. The output signal ranges from 0V to 5V. This range is based off of it seeing white or black. This also means there is an Op-Amp already installed. The sensing distance is 0.04 in to 0.5 in. This short range is common for IR sensors.

     The image shown below is also a commercially available line following IR sensor. As you can see there are five IR sensors set up in an array. This board reads from all five sensors and outputs a 0-127 signal, 0 meaning all sensors are seeing white and 127 means all are seeing black. It has the same input voltage and range as the single line following IR sensor. An array of sensors is the most efficient way of sensing and staying on a line. PID Controller

    Common Sensors

    IR

    IR— Infra-red sensors are normally used in range or proximity sensing. Time-of-Flight from the emitter to the receiver is used to calculate the distance to an object.

    Sonar

    Sonar sensors are used in the same manner as the IR sensors. The sonar sensor sends out a sound wave and measures the time it takes to return to the sensor. Sonar sensors are also used widely in range finding.

    Laser

    Lasers have the best range and percision of all the sensors used in robotics. They are very expensive and can be fairly large compared to IR and Sonar sensors. The same basic concept is used in laser sensors as IR and Sonar sensors.

    Micro-Controller

    The type of micro-controller used in your application may vary depending on what other objectives you may need to accomplish. The simplest micro-controller that will be needed to just follow a line will need to have an Analog to Digital (ATD) port (or something equivalent "Comparator") and a couple basic I/O pins. The ATD port is to read from the sensor and the two I/O pins are to control the drivers which in part control the motors. The more ATD ports on the micro-controller used will greatly improve the efficiency of the robot if coded properly.

    Drivers

    There are many types of drivers offered but all of them have the same concept. An H-Bridge configuration is the most common.
    The diagram above shows how simple the concept of an H-Bridge really is. To rotate the motor in one direction the controller would need to close switches S1 and S4. To rotate in the opposite direction, the controller would need to close switches S3 and S2.

    The driver shown below is a Texas Instruments(TI) L293 quadruple high-current half-H driver. The L293 is designed to provide bidirectional drive currents of up to 1 A at voltages from 4.5 V to 36 V. The L293 is designed to drive inductive loads such as relays, solenoids, dc and bipolar stepping motors, as well as other high-current/high-voltage loads in positive-supply applications.

    Most IC drivers like the TI L293 have Enable pins, which will turn on that half of the IC or the IC in general. Pin 1 is the Enable pin for the first two half-H bridges. From the diagram Pin 9 turns on the other two half-H bridges. Pin 8 is the motor supply voltage input pin. This voltage is normally higher then the voltage used by other components on the robot. Pins 2 & 7 are the input pins to turn on or off the motors. Pins 3 & 6 are the outputs to the motor. Everything from here on is mirrored across the IC. This driver offers multiple configurations for motor set-ups. The figure below shows two different configurations. By connecting the two half-H bridges through a motor the controller can rotate the motor in both directions(right side). If Pin 2 is high and Pin 7 is low the motor will rotate in one direction and vise versa for the opposite direction. The drivers can also be configured to run one motor in only one direction using only one of the half-H bridges as seen on the left side of the figure below.

    Motors

    The motors and gearing used will be based off of the objective the robot is trying to complete.
    A concern when choosing motors and gear reduction for a line following robot would be keeping the speed of the motors slow enough the robot is not over shooting the edge of the line. If the robot does over shoot the edge of the line the robot could become lost. Depending on programming the robot may never find the line or could find the line but will be going in the wrong direction and not know.

    Programming

    Zig-Zag Method

    The Zig-Zag method is the simplest and easiest way of programming a line following robot. The concept is the robot moves across the line it is following until it meets an edge. Once it senses it has hit an edge it turns the current motor off and turns the opposite motor on. Once it senses the next edge it swaps the power to the first motor again. As you can see the robot Zig-Zags back and forth across the line.

    One Sensor

    The Zig-Zag method with one sensor is a very basic line following robot. Since there is only one sensor there will only be one reading. This reading will be either "I see Black" or "I see White". As mentioned before the Zig-Zag method crosses back and forth across the line being followed, this causes problems with wide lines. The robot will move across the line untill it senses the edge, by the time it gets to the edge it might not be facing the end point any more. Further thought into programming and powering both motors, one just more then the other will help with this problem.
     
    Basic Zig-Zag Code

    %Zig-Zag Code
    %2/10/10
    %PinA is connected to the enable Pin on the driver for the right side motor
    %PinB is connected to the enable Pin on the driver for the left side motor
    %ATD1 is the port connected to the IR sensor(reads 1 for Black and 0 for
    % White)
    %In this program the robot will be following a White line. If you are
    %following a Black line the inputs for the IF loops will be swapped
    %Start centered on the line
    ATD1 = 0;
    %
    %Start off scanning for edge to the left
    PinA = 1;
    %Right_wheel means the right wheel is spinning,
    Right_wheel = 1;
    %
    %The percentage of your PWM will be based off of the gearing of your motor
    %and the width of the line. I am using a PWM% of 50% just to show the
    %concept
    %Continuous loop
    while(1);
    %
    %Sensor reads Black(Not on the Line)
    if (ATD1 == 1)
    %Figures out which direction it is currently moving
    if(Right_wheel == 1)
    %Changing direction by changing which motor is running
    Right_wheel = 0;
    PinB = 1;
    PinA = 0;
    else
    %Changing direction by changing which motor is running
    Right_wheel = 1;
    PinA = 1;
    PinB = 0;
    end
    end
    end

    Two Sensors

    The Zig-Zag method using two sensors becomes more efficient then using one sensor. There are two ways of setting the sensors on the robot. Depending on the width of the line and personal preference the robots sensors can be set up to straddle the line or can be set up to stay with-in the line's width. Both of these configurations makes the response of the robot faster at detecting the edge then the single sensor robot. The robot will Zig-Zag faster back and forth but will have a more true heading. Using two sensors makes the over shoot problem a little easier to handle. If over shoot happens it is possible one of the sensors is seeing the line and could straighten the robot out based off of the general Zig-Zag coding.

    PID Control Method

    Array of Sensors

    In many applications an array of sensors is used. By using the array of sensors the robot can have a better understanding of where it is on the line and will be able to correct its trajectory a little more accurately. The figure below is a simple diagram of an array of sensors that could be used on a line following robot. It has four sensors on the right (R1-R4) and four on the left (L1-L4). As seen in the above explanations these can be 0's or 1's depending on the color of the line you are following.

    The figure below shows what the controller would see if the robot was centered on the line. When your robot is seeing this you will want your robot to supply both motors with an equal amout of power.

    The Diagram below shows the robot trailing slightly to the right of the line. In this case the controller will want to power the right wheel slightly more then the left wheel to correct the trajectory of the robot back to centered on the line. If you are using a PID type of controller the error signal would be proportional to the magnitude the robot was off of center. In this case the robot is not far from center so the error would small.

    In the following figure you can see the robot is drifting further to the right. In this case the PID error signal would be greater then the above example. There for supplying a greater amount of power to the right wheel.

    When using an array of sensors the most common controller used is a PID controller. Most configurations using arrays will wire the signals into one whole eight pin ATD PORT on a micro-controller. By using the whole port the controller can read an 8 bit number from the sensors. By calibrating the sensors centered on the line to be followed, the controller can take that reading as "I'm on course". The PID control in the programming will try to keep the robot at the "I'm on course" reading by smoothly and constantly adjusting the right and left wheel speed. To learn more about PID Controlling please see PID Controller

    Bibliography

    http://www.ikalogic.com/ir_prox_sensors.php [1]
    http://www.trossenrobotics.com/p/single-line-following-sensor.aspx [2]
    http://www.trossenrobotics.com/p/I2C-Line-Following-Sensor.aspx [3]
    http://focus.ti.com/lit/ds/symlink/l293.pdf [4]
    http://www.kronosrobotics.com/application.shtml [5]

    Interfacing LCD With Arduino Microcontroller

    In this tutorial we are going to  interface a  Liquid Crystal Display (LCD)  with Arduino Microcontroller .  Liquid Crystal Display are us...