Hii friends I have started this blog to share our knowledge and experience which I have earned in past few years...in this blog I will post articles related to embedded systems, arduino , MATLAB and electronics which will be useful for beginners and hobbyists...there will be a lot of useful tutorials, discussions and projects from all these topics....I hope it will help you...:)
Wednesday, January 30, 2013
ROBOTICS TUTORIAL 1- HOW TO USE L293D MOTOR DRIVER IC
Hi…. Friends.. welcome back..!! I am again here with some
discussion on L293D motor driver IC , in this article we will discuss how to
use L293D in motor driving applications.L293D
is most widely used motor driver IC , it is used in various robotics projects
and in other applications where motor driving is required. So lets have a look
how we can drive motors using L293D.
PIN DISCRIPTION
L293D IC is a 16 pin IC the function of various pins is as
follows-
PIN 1&9- ENABLE PINS
PIN 2,7 & 10, 15- INPUT PINS
PIN 4,5 & 12,13- GROUND PINS
PIN 3,8 & 11, 14 – OUTPUT PINS
PIN 8- VS (+5V)
PIN 16- VSS (VOLTAGE AT WHICH YOU WANT TO DRIVE YOUR MOTOR)
WORKING
The working of L293D is very simple , this IC consists of
two H bridges which are capable of driving two motors at a time. Two input are
required for driving a motor the connections are as shown-
When A is high and B is low M1 will rotate in forward
direction while when A is low and B is low motor will rotate in reverse
direction. Similarly we can drive M2 ,using inputs C and D. Thus by changing logic
states of inputs the motor rotation direction can be controlled.
PROTEUS SIMULATION
You can understand working of L293D very easily with the
help of proteus just implement the proteus design as shown and check the
rotation of motor by changing input logic satats.
DOWNLOADS
You can download proteus design file and datasheet of L293D
from the links given below-
So its all about L293D, in our upcoming posts we will use
this IC in various robotics projects.
I hope this article was useful for you guyz………….in case of
any query , doubt or critical view just leave a comment. In our upcoming posts
we will discuss about some projects using this IC . Stay tuned…….!!
THNX….:
Monday, January 28, 2013
ROBOTICS PROJECT 1- MAKING A LINE FOLLOWER ROBOT WITHOUT USING MICROCONTROLLER
Hi friend …!! Welcome back…! this time I am here with a very
interesting project for robotics beginners, in this tutorial I am going to
discuss how to make an autonomous line follower robot without using a
microcontroller, so lets have a look how to make your own autonomous robot with
intelligence of following a black line on white surface or white line on black
surface.
INTRODUCTION
Line followers are the autonomous robots with the capability
of following a black line on white surface and vice versa. Basically we use
some kind of sensors to detect the color difference between line and surface. In
our project we are going to use IR sensors for detail description of IR sensor first
of all read this article BASIC ELECTRONICS PROJECT 6- MAKING AN IR SENSOR
According to the output of sensors we control our motor to
control the direction of robot. In this project we are going to make a BLACK
LINE FOLLOWER.
REQUIREMENTS
A robust chassis for robot
Two motors
Two wheels
One caster wheel
Two IR sensors
One motor driver IC ( we are using ULN2003A)
IC 7432
And a power supply.
STRUCTURE OF ROBOT
Attach wheels with motor to the chassis, place sensors at
front side at a distance more than width of the black line. Also attach caster
wheel at front side between sensors. Structure will look something like this-
ALGORITHM FOR LINE FOLLOWER ROBOT (USING TWO SENSORS)
-Start
-Check for line
-CASE 1-If both sensors are on move
forward
- CASE2-If only left sensor is off ,
turn left till both sensors are on
the line
ELECTRONIC
CONNECTIONS
Now just connect sensors, ICs and motors as shown in the
diagram below-
So now our first line follower robot is in action.
In case of any doubt, query or critical view just leave a
comment. I am waiting for your comments.
THNX..:)
BASIC ELECTRONICS PROJECT 6- MAKING AN IR SENSOR
Hi..friends ,welcome back……!! This time I am here
with some discussion on INFRA RED sensors. IR sensors are most widely used in
many electronics and robotics project , so have a look how to make a IR sensors
and how to use them.??
INTRODUCTION
IR SENSORS circuit is very important circuit to
detect the presence of any object or to distinguish between black and white
colors these sensors are most widely used in making a black or white line
follower robots. IR emitter detector circuit is very easy to implement and it
can be easily used in object detection, motion detection or color sensing.
IR reflective sensors have emitter (IR LED) and receiver (Photo‐Transistor or photo
diode). If white
surface is present beneath the IR LED
or if there is any object, IR rays are reflected and are
sensed by the receiver, while in case of no object receiver does not sense IR rays
and same is in case of black surface as light
gets absorbed and hence receiver does not sense IR rays.
IR SENSOR CIRCUIT
Here is the circuit which we have to implement for
making our IR sensor module just implement circuit and calibrate your circuit
with the help of variable resistor for proper result.
now this sensor circuit can be used in so many electronics and robotics projects. In our other posts we will discuss about use of IR sensors in so many projects.
For making a line follower robot with IR sensors just go to this link ROBOTICS PROJECT 1- MAKING A LINE FOLLOWER ROBOT WITHOUT USING MICROCONTROLLER
For making a line follower robot with IR sensors just go to this link ROBOTICS PROJECT 1- MAKING A LINE FOLLOWER ROBOT WITHOUT USING MICROCONTROLLER
I hope this article was useful for you guys..!!
In case of any doubt, query or critical view just leave a
comment. I am waiting for your comments.
EMBEDDED SYSTEMS TUTORIAL10- TIMERS IN AVR -TIMER1
Hi
friends..!! welcome back this time I am here with some discussion on second
part of TIMERS in avr , this time we are
going to discuss about TIMER1. I hope that you have read and understood the
previous posts:
Now
we are aware with the concepts of AVR so we are moving towards TIMER1. TIMER1
is more or less like TIMER0 so without wasting much time we will simply go
through problem statementwe .Once we are done with this, we can proceed to the
CTC and PWM modes of operations in subsequent posts.
Problem Statement
This
time our task is to flash an LED every 2 seconds, i.e. at a frequency of 0.5
Hz. We have an XTAL of 16 MHz.
Using prescaler and interrupt
So
here is the formula.
TIMER COUNT = (REQUIRED DELAY/CLOCK TIME PERIOD ) - 1
Given
that we have a CPU Clock Frequency of 16 MHz. At this frequency, and using a
16-bit timer (MAX = 65535), the maximum delay is 4.096 ms. It’s quite low. Upon
using a prescaler of 8, the timer frequency reduces to 2 MHz, thus giving a
maximum delay of 32.768 ms. Now we need a delay of 2 s. Thus, 2 s ÷ 32.768 ms =
61.035 ≈ 61. This means that the timer should overflow 61 times to give a delay
of approximately 2 s.
Now
it’s time for you to get introduced to the TIMER1 registers (ATMEGA16/32). We
will discuss only those registers and bits which are required as of now. More
will be discussed as and when necessary.
TCCR1B Register
The
Timer/Counter1 Control Register B- TCCR1B Register is as follows.
TCCR1B Register |
Right
now, only the highlighted bits concern us. The bit 2:0 – CS12:10 are the
Clock Select Bits of TIMER1. Their selection is as follows.
Clock Select Bits Description
Since
we need a prescaler of 8, we choose the third option (010).
TCNT1 Register
The
Timer/Counter1 - TCNT1 Register is as follows.
TCNT1 Register |
It is 16 bits wide since
the TIMER1 is a 16-bit register. TCNT1H represents the HIGH byte whereas
TCNT1L represents the LOW byte. The timer/counter value is stored in
these bytes.
TIMSK Register
The
Timer/Counter Interrupt Mask Register – TIMSK Register is as follows.
TIMSK Register |
As
we have discussed earlier, this is a common register for all the timers.
The bits associated with other timers are greyed out. Bits 5:2
correspond to TIMER1. Right now, we are interested in the yellow bit only.
Other bits are related to CTC mode which we will discuss later. Bit 2 –
TOIE1 – Timer/Counter1 Overflow Interrupt Enable bit enables the overflow
interrupt of TIMER1. We enable the overflow interrupt as we are making the
timer overflow 61 times (refer to the methodology section above).
TIFR Register
The
Timer/Counter Interrupt Flag Register – TIFR is as follows.
TIFR Register |
Once
again, just like TIMSK, TIFR is also a register common to all the
timers. The greyed out bits correspond to different timers. Only Bits 5:2
are related to TIMER1. Of these, we are interested in Bit 2 – TOV1 – Timer/Counter1
Overflow Flag. This bit is set to ’1′ whenever the timer overflows. It is
cleared (to zero) automatically as soon as the corresponding Interrupt Service
Routine (ISR) is executed. Alternatively, if there is no ISR to execute, we can
clear it by writing ’1′ to it.
Code
Now
its time for coding its too easy like TIMER0, if you have not gone through
TIMER0 please read TIMER0 tutorial first otherwise it will be a bit tough for
you.
/*
* TIMER1.c
*
* Created: 1/28/2013 1:59:29 AM
*
Author: ABHILASH
*/
#include <avr/io.h>
#include <avr/interrupt.h>
// global variable to
count the number of overflows
volatile uint8_t
timer_overflow;
// initialize timer,
interrupt and variable
void timer1_init()
{
// set up timer with prescaler = 8
TCCR1B |= (1 << CS11);
// initialize counter
TCNT1 = 0;
// enable overflow interrupt
TIMSK |= (1 << TOIE1);
// enable global interrupts
sei();
// initialize overflow counter variable
timer_overflow = 0;
}
// TIMER1 overflow
interrupt service routine
// called whenever
TCNT1 overflows
ISR(TIMER1_OVF_vect)
{
// keep a track of number of overflows
timer_overflow++;
// check for number of overflows here itself
// 61 overflows = 2 seconds delay (approx.)
if (timer_overflow >= 61) // NOTE: '>=' used instead of '=='
{
PORTC ^= (1 << 0); // toggles
the led
// no timer reset required here as the timer
// is reset every time it overflows
timer_overflow = 0; // reset
overflow counter
}
}
int main(void)
{
// connect led to pin PC0
DDRC |= (1 << 0);
// initialize timer
timer1_init();
// loop forever
while(1)
{
// do nothing
// comparison is done in the ISR itself
}
}
So
friends it was all about TIMER1 in AVR , in case of any query doubt or critical
view just leave a comment here . in our next tutorial we will discuss about
TIMER2 , till then bye…!!
THNX...:)
Tuesday, January 22, 2013
EMBEDDED SYSTEMS TUTORIAL 9- INTERFACING 128X64 GRAPHICAL LCD WITH AVR
What is required??
I am using a
HQM1286404 LCD it’s a pretty old one and please don’t be mistaken with newer
versions of LCD, if you are using any other version you have to find its
datasheet for wiring connections because wiring connections may be different
from version to version. I will provide connections for HQM1286404 LCD only and its pretty hard
to get accurate wiring connection , so better consult your datasheet and
internet as well. Except this you will need a AVR MCU, I am using ATMEGA 8 here
and of course an LCD library you can
find o many libraries on internet but I am giving a best link to download a
very nice library written by Mr. Fabian Maximilian Thiele , thanx to him the
link for this library is GLCD_LIBRARY
LCD PIN-OUT CONNECTIONS
Here is the
correct pin-out of LCD:
1
Vcc
2
GND
3
VCON
4-11
DB0-DB7
12
CS2
13
CS1
14
RESET
15
R/W
16
D/I
17
EN
18
Vee out
19
LED Anode
20
LED Kathode
NOTE:- in some cases you will found that your LCD screen is swapped into two halves in such cases just swap the chip select pins and problem will be corrected...:)
LIBRARY USE
The library ,
which you have downloaded contains to files ks0108.c and ks0108.h you have to copy these files and have to
paste in the same folder wher .c file of your main program is contained and you
have to add corresponding header files in the beginning of the program too like
#include
"ks0108.h"
#include
"ks0108.c"
the .h files contains the information about
pin connection and commands you can easily change the connection pin and ports
from there .
Getting familiar
with commands is just a learning by doing thig more you do more you learn. Just go through the library to know more about the command its self explaining.
Along with these library files some font files are also provided these fonts must be added by adding corresponding header file in beginning of the program.except these font you can fetch your windows font with the help of this java program GLCDFontCreator2
SOURCE CODE
here is an
interesting source code to start with
#include <inttypes.h>
#include <avr/io.h>
#include <avr/pgmspace.h>
#include "ks0108.h"
#include "ks0108.c"
#include
"arial_bold_14.h"
int main(void) {
// Wait a little while the display starts up
for(volatile uint16_t i=0; i<15000; i++);
// Initialize the LCD
ks0108Init(0);
// Select a font
ks0108SelectFont(Arial_Bold_14, ks0108ReadFontData, BLACK);
// Set a position
ks0108GotoXY(15,10);
// Print some text
ks0108Puts_P(PSTR("Tech_strong"));
// two little circles
ks0108DrawCircle(30, 30, 5, BLACK);
ks0108DrawCircle(90, 30, 5, BLACK);
// again some text
ks0108GotoXY(29,38);
ks0108Puts_P(PSTR("Tutorials"));
// a loading bar
for(int x=0;x<128;x++)
{
ks0108GotoXY(x,50);
ks0108DrawRect(x, 50, 80, 10, BLACK);
}
while(1);
}
CIRCUIT DIAGRAM
now just
implement this easy circuit burn your MCU with corresponding .hex file and
enjoy your GRAPHICAL lcd.
NOTE:- In my program I have changed
data port of LCD from PORTA to PORTD so be careful if you are using this
circuit connection you will have to change PORTA to PORTD in ks0108.h file of
library be careful ….!!
I think it was a
useful article for you all in case of any query, doubt or critical view just
leave a comment in next tutorial we will discuss about displaying an image on
this LCD,… till then bye…!
THNX..:)
Subscribe to:
Posts (Atom)