Friday, November 23, 2012

L293D Motor Driver IC

L293D is a dual H-bridge motor driver integrated circuit (IC). Motor drivers act as current amplifiers since they take a low-current control signal and provide a higher-current signal. This higher current signal is used to drive the motors.

Two DC motors can be driven simultaneously using the L293D; The motor operations of two motors can be controlled by input logic at pins 2 & 7 and 10 & 15. Input logic 00 or 11 will stop the corresponding motor. Logic 01 and 10 will rotate it in clockwise and anticlockwise directions, respectively.
Digital pins 1 and 9 are used to enable/disable the motors; setting these pins to HIGH value will enable the motors.

Below is the pin diagram for the L293D :-



Below sketch can be used to build up a simple motor circuit





From the above diagram,
a. Pins 1, 9 are set to HIGH so that enable both motors.
b. Arduino digital pins D6, D7 will be used to set pins 2, 7 which drive Motor 1
c. Arduino digital pins D3, D4 will be used to set pins 10, 15 which drive Motor 2

The above diagram is built using Fritzing software; go to Tools->Fritzing to download it.

Thursday, November 22, 2012

Distance measurement sensors

There are many Aurdino sensors to measure distance. one common analog sensor is the Long range Infrared sensor GP2Y0A02YK0F, other common digital sensor is Ultrasonic sensor HC-SR04.
The use of each sensor depends on your needs. For example, the IR sensor can measure distances between  15 cm to 150 cm otherwise output distances would be inaccurate, in this case, there are some algorithms used for error detection and one common algorithm is Kalman filter. The Ultrasonic sensor can measure distances from 2 cm to 400 cm. Cost of each sensor should be considered when choosing the sensor.

IR Sensor GP2Y0A02YK0F 

The IR sensor has 3 ports, VCC for the supply supply which is 5V DC, GND for the ground, and V0 for the output voltage represents the distance, according the output voltage we can calculate the distance using some equation. The equation used for calculate distance is 
          inches = 4192.936 * pow( outputVoltage ,-0.935) - 3.937;
          cm = 10650.08 * pow(outputVoltage,-0.935) - 10;

Below is the Outline Connection for the component

source: https://www.sparkfun.com/datasheets/Sensors/Infrared/gp2y0a02yk_e.pdf


To connect the device, connect the VCC port with the 5V supply voltage in the aurdino port, GND to the ground, VO to any of the analog ports in the board.

Below is a working sample shows how to use the sensor.

         #define sensorIR1 1           
         float sensorValue, inches, cm ;   
         void setup() {
           Serial.begin(9600);
         }

         void loop() {
           sensorValue = analogRead(sensorIR);
           inches = 4192.936 * pow(sensorValue,-0.935) - 3.937;
           cm = 10650.08 * pow(sensorValue,-0.935) - 10;
           delay(500);
           Serial.println(sensorValue);
           Serial.println("");
         }

Ultrasonic Sensor HC-SR04


The sensor has 4 ports, VCC the supply voltage which is 5V DC, GND Ground, TIG Trigger, and ECHO is the echo port.

Generally,  Ultrasonic sensors generate high frequency sound waves and evaluate the echo which is received back by the sensor. Sensors calculate the time interval between sending the signal and receiving the echo to determine the distance to an object.

To connect the device, connect the VCC to the 5V supply voltage, GND to the ground, TGR and ECHO to two digital ports in the board.


There is one library  to deal with the sensor. the library consists of 2 files ultrasonic.h and ultrasonic.cpp and should exist under Document/Aurdino/Libraries/Ultrasonic folder,  if you don't find them, you can download library Here.

Blow is a working example for ultrasonic sensor, the example  should exist in the example list of Aurdino "File-> SketchBook->Aurdino->UltrasonicDemo"

     #include "Ultrasonic.h"
     #include <LiquidCrystal.h>
     //LiquidCrystal lcd(11, 10, 9, 4, 5, 6, 7);
     Ultrasonic ultrasonic(12,13); //trigger into 12

     void setup() {
     //lcd.begin(16, 2);
     //lcd.print("testing...");
     Serial.begin(9600);  
     Serial.println(" Ultrasonic testing...");
     
     }

     void loop()
     {
      Serial.print(ultrasonic.Ranging(CM));
      Serial.println("cm");
       delay(100);
     }

Introduction

Working with Arduino Software

Arduino software is a common program to write your code that will be deployed to the Arduino  oard; it supports multiple Arduino boards with lots of functionalists.

You can easily use it and it can run on different operating systems ( Windows, Mac OS, Linux)

To use it,
       1) Download Arduino Software from Here
       2) Run Arduino Software on your machine, the below screen will appear

     3) Select the board you use as below

       4) Get The COM number in which the connecting board uses.
       5) Set the COM port the board uses in the Arduino software "Tools->SerialPort-> Choose the COM"
       6) Write your own code, verify it, then deploy it.


Hello World exercise

         In our first Arduino  xercise, we are going to build a simple program to blink one led in the board. The example exists in the examples list with the Arduino software "File->Sketchbook->Blink"

         
           int led = 13;  // led number that will be blinked
           void setup() {                
           // initialize the digital pin as an output.
           pinMode(led, OUTPUT);   
           }

           // the loop routine runs over and over again forever:
           void loop() {
           digitalWrite(led, HIGH);   // turn the LED on (HIGH is the voltage level)
           delay(1000);                    // wait for a second
           digitalWrite(led, LOW);    // turn the LED off by making the voltage LOW
           delay(1000);                    // wait for a second
           }



Tuesday, November 20, 2012

EEEC Overview

Welcome to the EEEC blog; EEEC or Ejada Embedded Electronic club is a micro-controllers workshop held by Ejada. The course introduces the basics of micro-controllers.
At the end of the workshop; you are expecting to be familiar with the Arduino boards and most common Aurdino sensors. In addition, through the course, we will do sample projects to compete with each-others like line follower robot, 2 wheel balancing robot, .. etc.