Sunday, 23 November 2014

Optical Position Encoder with Arduino

Common applications of position encoders are:
  • DC motor position / velocity control
  • Servo-mechanism Position / velocity control
  • Computer printer
  • Numerically controlled machinery
  • RPM sensors in robotics
    Photo-Interrupter
    Front end of an ordinary optical position encoder, used for these tasks, is a slotted PhotoInterrupter /Opto-Interrupter module with an IR LED & a Photo Transistor/Diode mounted facing each other enclosed in plastic body. When light emitted by the IR LED is blocked because of the alternating slots of the encoder disc (also known as index disc), conduction level of the photo transistor/diode changes. This change can be detected by a discrete hardware or by a microcontroller. In short, a photo-interrupter is composed of an infrared emitter on one side and an infrared detector on the other By emitting a beam of infrared light from one side to the other, the photo-interrupter can detect when an object passes between them, breaking the beam.


    Encoder/Index Disc
    As we need to create pulses, an encoder disc/index disc is very necessary here. An easy way to make it is with a thin transparent acrylic, thin transparent adhesive transparency sheet and a laser printer. Take a drawing software and draw the black stripes as shown in the picture. Print it to the transparency sheet and fix it on the round-shaped thin transparent acrylic. As an alternative, you can make the disc from black acrylic and cut out the white spaces.


    An important note: Physical width of stripes and spaces is a most critical factor. Look at the datasheet of the photo-interrupter to find its slit width. It is better to set minimum witdh of the stripes (and also of the spaces) two times (x2) the slit width of the photo-interrupter. For example, if the slit width is 1mm, the width of the stripes and spaces should be 2 mm. If the RPM of the disc is 60, then we have 1 disc turn/second. If the disc has 36 stripes then the pulse frequency is 36Hz, which can easily be handled by the photo-interrupter.

    The Hardware
    To get started, just create a small test circuit as shown here with a photo- interrupter and an Arduino. This allows you to experiment and make sure all things works as per your expectation. The 10K resistor (R2) is a pull-up resistor. Value of the first resistor (R1) depends on the photo-interrupter you use. In this set-up, the onboard LED (at D13) of the Arduino board is usually in off mode, and when the beam broken the LED goes on. Auxillary output available from D12 of the Arduino can be used to monitor the encoded signal on an oscilloscope, for example.

     The Arduino Sketch

    1. /*
    2. -Arduino Position Encoder
    3. -Using a generic photo-interrupter
    4. -Basic Test Sketch 1 / June 2014
    5. -Tested at TechNode Protolabz
    6. -www.electroschematics.com/
    7. */
    8. const int encoderIn = 8; // input pin for the interrupter
    9. const int statusLED = 13; // Output pin for Status indicator
    10. const int pulseOutput = 12; // Pulse output pin for external interfacing
    11. int detectState=0; // Variable for reading the encoder status
    12. void setup()
    13. {
    14. pinMode(encoderIn, INPUT); //Set pin 8 as input
    15. pinMode(statusLED, OUTPUT); //Set pin 13 as output
    16. pinMode(pulseOutput, OUTPUT); // Set Pin 12 as output
    17. }
    18. void loop() {
    19. detectState=digitalRead(encoderIn);
    20. if (detectState == HIGH) { //If encoder output is high
    21. digitalWrite(statusLED, HIGH); //Turn on the status LED
    22. digitalWrite(pulseOutput,HIGH); // Give a logic-High level output
    23. }
    24. else {
    25. digitalWrite(statusLED, LOW); //Turn off the status LED
    26. digitalWrite(pulseOutput,LOW); // Give a logic-Low level output
    27. }
    28. }
      Test Procedure
      Bring the photo-interrupter connected with the hardware to your encoder disc and do the test. Connect the D12 output to an oscilloscope and run your encoder disc by hand, or by using a low rpm dc motor. If you don’t have an oscilloscope, watch the onboard LED (D13) to note the pulse output. In this case, try to turn the disc slowly by hand to see the pulse activity directly.

     This is the very basic code you need. We have the hardware and the basic software up and running. Now you can upgrade it to whatever you want it to do.


Saturday, 22 November 2014

Car Parking Guard Circuit Using Infrared Sensor

Introduction: While parking the car the driver should be more careful because he cannot see the back of the car while parking or taking reverse, if there is any obstacle and ran over it might be  get damage to the car. Our project will help the person in the driving seat and give alarm if there is any obstacle or a wall while parking or while driving in reverse.

Block Diagram of Car Parking Guard:

 


The IR sensor will detect the obstacle with in 100cm, if there is any obstacle it will sense and give information to the tone detector which will enable the LM555 timer to generate a PWM for the buzzer. The LM555 will generate the pulse which helps to buzz the buzzer so driver can understand that there is an obstacle.
Main Component Explanation:
LM567: is a tone detector which can interpret the frequency generated by the other component and give the output according to the application designed by the engineer. For example if a component is attached to the input of LM567 which can generate a 40 kHz signal , but we to function the following circuit when the component has reached to the 40KHz. At this decision making we will use tone detector. The tone detector is mainly used in touch tone decoders, ultrasonic controls, frequency monitoring and control etc.
LM555: is a timer which can generate a PWM signals in various width and duty cycles. The 555 timer is mainly used to control the other peripherals like motors, detectors, regulators etc.
IR Sensor: the main function of the IR sensor is to produce a beam for certain distance (the distance of the beam is always depends on the IR sensor, different IR sensor have different range of beam distance) if the there is any obstacle in the beam it will conduct and give signal.
Photo Darlington Transistor: the photo darlington transistor will act as a photo detectors. They will conduct to the light or electro magnetic signals. The main function of this transistor is to amplify the input signal of the transistor. But it will work slowly when compared to the other transistors. It is having a maximum frequency of 20 KHz.

Circuit Diagram of Car Parking Guard:

 

Explanation:

  • The reverse indicator light supply is given to the 7805 regulator to give 5v to the rest of the circuit. The diode D6 is used to eliminate the reverse current and wrong supply polarity.
  • When the car is driving in reverse the car battery will provide DC supply the reverse light indicator at the back of the car when this supply came to the reverse light indicator the circuit will have the power supply.7805 will regulate the DC voltage to 5V and give to the IR Sensors through the transistor with 20 KHz modulating frequency of the LM567 (TONE DETECTOR) available at Pin5. The resistor R1 will resists the IR senor current. At this point the pin8 of LM567 is high which will enable the LM555 timer operating in astable multivibrator mode. The output of the timer is enabled which can be assured by the LED (blinking) and also buzzer will beeps at determined rate given by the resistors R6, R7 and capacitor C7. The timer output also is given to the lamp through a transistor. The lamp will blink as a warning signal because of the PWM signal generated by the timer, transistor will work as a switch and resistor R10 will limit the current. This condition is maintained until the 20 KHz signal is received by the pin3 of the LM567.
  • The above condition is when there is no obstacle in the path of the car while taking reverse. If there is a obstacle the IR beam will radiate back to the IR sensor and the 20KHz modulated signal is given to the pin3 of LM567 through photo Darlington transistor, at this point the pin8 of the LM567 is turned to low and also gets locked to detect the 20Khz signal. By this the LM555 is turned low and disabled by this the led will remain lighting and buzzer makes the continuous sound to alert the driver.
Note: This complete circuitry will be attached to the back bumper and placed at the center. The buzzer and led should be placed on the dash board for visibility of light and hearing purpose for the driver.
Make the connection to the reverse indicator light and the circuit in parallel and beware of the polarity.

GSM Controlled Robot using Microcontroller

GSM controlled robot or SMS controlled robot is a wireless robot which performs the necessary actions by receiving a set of instructions in the form a Short Message Service (SMS). In this project we can control the robot directions like forward, backward, left and right by sending SMS from the mobile. Earlier, we have already seen the working of a DTMF Controlled Robot without using Microcontroller.
This project mainly consists of 2 sections, one is mobile unit and the other one is robot unit. The GSM modem which is fixed at the robot receives the messages sent by the mobile and gives the instructions to the microcontroller to control the robot directions. In this project, we interface 8051 microcontroller with GSM SIM 300. The protocol used for the communication between controller and GSM modem is UART (Universal Asynchronous Receiver-Transmitter). This system continuously checks for message to take the decision for controlling the robot.

GSM Controlled Robot Circuit Principle:

When we send the message from the mobile to the modem, GSM modem sends the below command serially to indicate that new message is received.

+CMTI: “SM”,3
In the above command number 3 indicates the location of the new message. Now we need to read this unread message to display it on LCD. The command to read the message from GSM modem is

at+cmgr=3
Here the number 3 indicates the location of the message to be read. After sending this command to GSM module, modem sends the below command serially.

+CMGR: “REC UNREAD”,”MD-WAYSMS”,,”13/05/20,15:31:48+34″ forward
In the above command “REC UNREAD” indicates that message is unread message, “MD-WAYSMS” indicates sender mobile number or name, 13/05/20 indicates the date, 15:31 indicates time and forward is the content of the message.
From the above command, we need to extract message (forward) sent by the user. Now compare this message with predefined strings (forward, backward, left, right), based on result control the robot.

GSM Controlled Robot Block Diagram:


 GSM Controlled Robot using 8051 Microcontroller Circuit:




Hardware Requirements:

  • 8051 Microcontroller
  • AT89C51 Programming board
  • Programming cable
  • 16*2 LCD
  • MAX 232 level converter
  • GSM sim 300 module
  • L293D motor driver
  • Robot
  • 9V DC batteries – 2
  • 5V power supply circuit
  • 0.1uF ceramic capacitors – 4
  • 33pF capacitors – 2
  • 10uF electrolytic capacitor
  • 12MHz crystal
  • 10k (1/4 watt) resistor
  •  Single pin connecting wires 



Software Requirements:

  • Kiel U vision
  • Flash magic
  • Proteus    

    SMS Controlled Robot Circuit Design:

    The major components used in the above circuit are microcontroller, motor driver, level converter, GSM module and robot. Here at89c51 microcontroller is used and it requires a power supply of positive 5V DC. In order to provide regulated 5V DC voltage to the controller, use 7805 power supply circuit. Here two 9V batteries are used, one is for giving the supply to the circuit and other is to run the DC motors.
    In the above circuit, 16 x 2 LCD is connected to the PORT1 of the microcontroller in 4 bit mode. LCD data lines D4, D5, D6 and D7 are connected to P1.4, P1.5, P1.6 and P1.7 respectively and control pins are connected to P1.0, P1.1 and P1.2. Here it used to indicate the received message.
     GSM modem Tx and Rx pins are connected to the 13 and 14 pins of max232. Microcontroller TXD and RXD pins are connected to the 11 and 12 pins of level converter. Here max232 is a mediator between controller and GSM module and it is used to convert the voltage levels. To know more details about max232 refer MAX 232 Datasheet.
    GSM module requires 5V power supply. In order to communicate with this GSM we need to send AT commands using serial communication (UART protocol). Use a baud rate of 9600 to communicate with GSM.
    P2.0, P2.1, P2.2 and P2.3 pins of controller are connected to the l293d input pins and these pins are used to control the two DC motors. The operating voltage of this IC is 5V. Using this IC we can operate the 2 DC motors with a voltage ranging from 4.5 to 36V. We need to apply the motors supply at 8th pin of l293d. To know more about motor driver IC refer L293 Datasheet


    GSM Controlled Robot Circuit Working Algorithm:

  • Initialize the LCD and UART protocol
  • Continuously check for the command +CMTI: “SM”,3 (Location number) to know weather new message is received or not
  • If you receive the command then store message location number.
  • Now read that particular message and extract the body of the message
  • Display the extracted content on LCD and compare this content with predefined strings.
  • If matched then perform the necessary action on robot.   
    Use below code to read a new message from the GSM modem.
    while (rx_data() ! = 0x0d);
    while (rx_data() ! = 0x0a);
    if (rx_data() == ‘+’)
    {
    if (rx_data() == ‘C’)
    {
    if (rx_data() == ‘M’)
    {
    if (rx_data() == ‘T’)
    {
    if (rx_data()==’I’)
    {
    while (rx_data() != ‘,’);
    a = rx_data ();
    delay_ms (10);
    tx_string (“at”);
    tx_data (0x0d);
    tx_data (0x0a);
    tx_string (“at + cmgf =1″);
    tx_data (0x0d);
    tx_data (0x0a);
    tx_string (“at + cmgr =”);
    tx_data (a);
    tx_data (0x0d);
    tx_data (0x0a);
    while (rx_data() ! = 0x0a);
    while (rx_data() != 0x0a);
    while (rx_data() ! = 0x0a);
    for (i=0; i<15; i++)
    {
    read [i]= rx_data();
    }
    lcd_stringxy(1,0,read);
    delay_ms (5000);
    }
    }
    }
    }
    }

    How to Operate GSM Mobile Controlled Robot?

  • Write the program to the GSM controlled robot project using keil software
  • Now burn the program to the microcontroller with the help of flash magic.
  • Give the connections as per the circuit diagram.
  • Use power supply circuit to provide 5V DC to the microcontroller
  • Insert the SIM (Subscriber Identity Module) to the GSM module.
  •  Now switch on the supply
  • Send SMS to the GSM module using other mobile
  • Now you can see the same message on LCD.
  •  If the received message match with any predefined string then robot moves accordingly.


GSM Controlled Robot Circuit Applications:


  • This project is used in robotic applications
  • Used in military applications.

Limitations of the Circuit:

  • Robot section must have the network to receive the commands wirelessly.
  • As there is no password any one can operate the robot by sending message.

Tuesday, 18 November 2014

Using Fuse Tube Light


The circuit illustrated below can RE use your thrown tube light. which usually blinks in normal circuit. A high DC voltage has advantage to glow a a weak florescent tube light. A weak florescent tube gets black at one edge. At black end Positive voltage should be applied and can be marked as anode and other clear end cathode can be marked for Negative voltage or electron will be supplied.

Please see circuit Diagram.For converting AC to DC we have used a Rectifier Circuit. Choke Should be used in series with rectifier circuit for limiting current.Rectified voltage(DC) is applied to both end of the tube.

Circuit Diagram
Part List :
Choke or you can use 100W Bulb
Diode -IN4007 or 159 X 4pcs

Sunday, 16 November 2014

Mobile Jammer

Now, let us learn about one more interesting concept i.e. Cell Phone or Mobile Phone Jammer Circuit.


Cell Phone Jammer Circuit Explanation:

  • If you understand the above circuit, this circuit analysis is simple and easy. For any jammer circuit, remember that there are three main important circuits. When they are combined together, the output of that circuit will work as a jammer. The three circuits are
    1. RF amplifier.
    2. Voltage controlled oscillator.
    3. Tuning circuit.
  • So the transistor Q1, capacitors C4 & C5 and resistor R1 constitute the RF amplifier circuit. This will amplify the signal generated by the tuned circuit. The amplification signal is given to the antenna through C6 capacitor. Capacitor C6 will remove the DC and allow only the AC signal which is transmitted in the air.
  • When the transistor Q1 is turned ON, the tuned circuit at the collector will get turned ON. The tuned circuit consists of capacitor C1 and inductor L1. This tuned circuit will act as an oscillator with zero resistance.
  • This oscillator or tuned circuit will produce the very high frequency with minimum damping. The both inductor and capacitor of tuned circuit will oscillate at its resonating frequency.
  • The tuned circuit operation is very simple and easy to understand. When the circuit gets ON, the voltage is stored by the capacitor according to its capacity. The main function of capacitor is to store electric energy. Once the capacitor is completely charged, it will allow the charge to flow through inductor. We know that inductor is used to store magnetic energy. When the current is flowing across the inductor, it will store the magnetic energy by this voltage across the capacitor and will get decreased, at some point complete magnetic energy is stored by inductor and the charge or voltage across the capacitor will be zero. The magnetic charge through the inductor will decreased and the current will charge the capacitor in opposite or reverse polarity manner. Again after some period of time, capacitor will get completely charged and magnetic energy across the inductor will be completely zero. Again the capacitor will give charge to the inductor and becomes zero. After some time, inductor will give charge to capacitor and become zero and they will oscillate and generate the frequency.
  • This circle run upto the internal resistance is generated and oscillations will get stop. RF amplifier feed is given through the capacitor C5 to the collector terminal before C6 for gain or like a boost signal to the tuned circuit signal. The capacitors C2 and C3 are used for generating the noise for the frequency generated by the tuned circuit. Capacitors C2 and C3 will generate the electronic pulses in some random fashion (technically called noise).
  • The feedback back or boost given by the RF amplifier, frequency generated by the tuned circuit, the noise signal generated by the capacitors C2 and C3 will be combined, amplified and transmitted to the air.
  • Cell phone works at the frequency of 450 MHz frequency. To block this 450MHz frequency, we also need to generate 450Mhz frequency with some noise which will act as simple blocking signal, because cell phone receiver will not be able to understand to which signal it has been received. By this, we can able to block the cell phone signal from reaching the cell phones.
  • So here in the above circuit, we generated the 450 MHz frequency to block the actual cell phone signal. That’s what the above circuit will act as a jammer for blocking the actual signal.

Saturday, 15 November 2014

Arduino based distance sensor

This Project uses a HCR-SR04 distance sensor and Atmega 328 or any other Atmega chip which is programmed using a Arduino programming kit, so the project is based on Arduino. But our final Circuit will be a standalone circuit without attached Arduino programmer.

Hardware Used

1)  HC-SR04
It is a simple Ultrasonic ranging module.
Specifications: power supply :5V DC
quiescent current : <2mA
effectual angle: <15°
ranging distance : 2cm – 500 cm


We can send a short ultrasonic pulse at t1 , and if any obstacles is there the received ultrasonic signal is converted to an electrical signal as Echo.  If a 10μs width trigger pulse is sent to the signal pin, the Ultrasonic module will  output eight 40kHz ultrasonic signal and detect the echo back. The measured distance is proportional to the echo pulse width and can be calculated by the formula above. If no obstacle is detected, the output pin will give a 38ms high level signal.


 2) Arduino
Either a Arduino Board or a Arduino IC( Atmgea 328 , Atmega 128 , Atmega 8 etc ) with a programmer is used. To know more about Arduino visit the official arduino site http://arduino.cc

3) 16*2 LCD

Wiring: SO If you are going to use arduino board then please connect devices as following:
FOR LCD:
* LCD RS pin to digital pin 12
* LCD Enable pin to digital pin 11
* LCD D4 pin to digital pin 5
* LCD D5 pin to digital pin 4
* LCD D6 pin to digital pin 3
* LCD D7 pin to digital pin 2
* LCD R/W pin to ground
* 10Komhs Variable resistor   with two ends to +5v and ground and the middle   wipper ti LCD pin VO.

If you also have back light in your LCD and  want to enable it:
* LCD A to +5v , LCD K to Ground.
And LCD VSS to Ground , LCD VDD to +5v.
FOR HC-SR04:
* VCC to +5v , Gnd to Ground
* “Trig” Pin to Digital pin 7
* “Echo” Pin to Digital pin 8

And if You are not using Arduino Board instead using a Arduino IC after programming it then use the following schematic: 

Software: Here is a simple version of the software:

       #define trigPin 7
       #define echoPin 8

void setup() {
Serial.begin (9600);
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);
}
void loop() {
int timetaken, dist;
digitalWrite(trigPin, HIGH);
delayMicroseconds(1000);
digitalWrite(trigPin, LOW);
timetaken = pulseIn(echoPin, HIGH);
dist = (timetaken/2) * 0.034049 ;
if (dist >= 300 || dist <= 0){
Serial.println(“Out Of Range”);
}
else {
Serial.println(“Distance in CM: “);
Serial.print(dist);
}
delay(500);
}

Using above software You can only view the Distance in the Serial Monitor of your arduino and not on LCD. For viewing the Data on LCD use following Code:
#define trigPin 7
#define echoPin 8
#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
void setup() {
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);
lcd.begin(16, 2);
lcd.print(“electronics”);
lcd.setCursor(0, 1);
lcd.print(“project.org”);
delay(2000);
lcd.clear();
lcd.print(“Welcome To”);
lcd.setCursor(0, 1);
lcd.print(“Distnance Meter”);
delay(2000);
lcd.clear();
lcd.print(“Designed by:”);
lcd.setCursor(0, 1);
lcd.print(“ElectronicsProject”);
}
void loop() {
int timetaken, dist;
lcd.clear();
lcd.print(“Distance in CM:”);
digitalWrite(trigPin, HIGH);
delayMicroseconds(1000);
digitalWrite(trigPin, LOW);
timetaken = pulseIn(echoPin, HIGH);
dist = (timetaken/2) * 0.034049 ;
if (dist >= 300 || dist <= 0){
lcd.setCursor(0, 1);
lcd.print(“Out Of Range”);
}
else
{
lcd.setCursor(0, 1);
lcd.print(dist);
}
delay(500);
}

Theory:

Here , we are going to calculate the distance of the sensor and any object in front of it. 
At t1 we send the trigger signal , and at t2 we get the echo.
so dt = t2-t1
And as dt is the time for the sound taken to reach to the object and return back;
The exact time taken by the sound to reach the object is : dt/2
Now , Normal speed of sound is: 340.29 m / s 
And converting it to Centimeters per Micro Seconds gives : 0.034049 CM / microseconds
The actual distance traveled by the sound or the distance between the sensor and the object is:
(dt/2) * 0.034049
Which is the exact formula used in the software.