MATLAB and Microcontroller based advance Robot project

5.00 avg. rating (90% score) - 1 vote

This part of document only provides brief definitions of the key terms and concepts that is just a part of the complete document. You may download the complete document from website just by clicking on

Symbol to download the PDF file Download PDF

Abstract

As the name suggests an Advanced Line Follower Robot is just a Simple Line Follower Robot with a few extra features. It will move and follow a black line over white background continuously.

The main electronics/mechanical components that will be used in making this line follower robot are ATmega32 micro-controller, 2 MOSFET transistors IRF540, MAX232 IC, a webcam, RS232 to USB converter cable and related software, 2 small dc motors with gear boxes, and few other typical resistors, capacitors, and a 11.0592 MHZ crystal, a designed PCB, 5 AA regular batter, and few other goodies.

The AVR Microcontroller Digital I/O Ports

    Atmel AVR 8-bits microcontrollers provide pins to take in/output information form/to the outside world in the form of logic values. These pins are usually organized in groups of eight (8) and referred to as a port. The AVR use the alphabet to name these port, example PortA, PortB, etc. The figure below shows the pins of an AVR 8-bit microcontroller which has four (4) digital I/O ports: PortA, PortB, PortC and PortD. The pins of PortA are: PA0 – PA7. In the next figure, see block diagram of the AVR microcontroller.

    Notice the alternate name of the Ports pins. The AVR microcontrollers are designed to allow dual use of most of its pins. This has the advantage of allowing a developer to use these pins as I/O pins if the function they are provided for is not being utilized.

The pins of the AVR microcontroller are not fixed as input or output at the manufacturing stage, these pins are software configurable which is the topic of the section below.

1

Associated I/O Registers

Each of the AVR Digital I/O ports is associated with three (3) I/O register. A Data Direction Register (DDRx), A Pin Register (PINx) and a Port Register (PORTx). Where x is the port A, B, C, etc. For example, for port B, we are going to have; DDRB, PIN B, and PORTB

All AVR ports have true read-modify-write capability when used as general I/O ports.

The direction of any pin on the ports of the AVR microcontroller can be independently controlled.

The port pins of the AVR are used for communication with the external environment.

The port pins can be configured as output for controlling devices like motors, solenoids, LED’s, relays, etc.

Also the port pins can be configured as inputs for processing sensor information and thereby controlling the outputs.

The general form of port pin description of AVR microcontrollers is PORTxn, where “x” represents the numbering letter for the port and “n” represents the bit number as an example, PORTB3 where PORTB3 represents bit no. 3 of PORTB.

The I/O memory address locations are allocated for each port. They are:

  1. DDRx   : Data direction register (read/write).
  2. PORTx : Data register (read/write).
  3. PINx     : Port input pins (read only).

The port pins have a lot of alternate functions other than using them as general I/O pins.

  1. DDRx : the data direction register is used for setting the direction of the port pins either as input or output.
  2. PORTx : the PORTx register is used for initializing the port pins and also driving the port pins to high logic (1) or low logic (0).
  3. PINx  : the PINx register is used for reading the status of the port pins.

The DDRx register is used for setting the direction of the port pin:

All the 8 bits of a port are set as input or outputs.

DDRD = 0xFF > All pins of PORTD set as O/P.

DDRD = 0x00 > All pins of PORTD set as I/P.

Hence, putting 0xFFH in DDRD makes all pins of PORTD as outputs and vice versa.

Bit level access: this comes handy when only few pins need to be controlled without affecting other pins. For example:

DDRD.0 = 1 > Setting bit 0 of PORTD as O/P.

DDRD.3=1   > Setting bit 3 of PORTD as O/P.

DDRD.0=0   > Setting bit 0 of PORTD as I/P

DDRD.3=0   > Setting bit 3 of PORTD as I/P

The PORTx register is used for initializing the port pins and also for controlling the logical state of the pins.

If PORTxn is written logic 1 when the pin is configured as an output pin, the port pin is driven high (1).

DDRD.0 = 1; PORTD.0 configured as O/P.

PORTD.0=1; PORTD.0 goes high (1)

DDRD.0 = 1; > PORTD.0 configured as O/P

PORTD.0 = 0; PORTD.0 goes low (0)

Reading the pin Status;

The PINx register is used for reading the status of the pins when any sensor data needs to be processed. For such as operation the corresponding DDRxn should be set as an input pin.

PINx.n is used to read the logical state of the pins.

DDRD.0 = 0 > setting PORTD.0 as input pin

PORTD.0=1 > initializing PORTD.0

AVR Serial communication

What is RS232? It’s just a name for a standard that has propagated from generation to generation of computers. The first computers had serial ports that used RS232, and even current computers have serial ports (or at least USB ports that act like RS232 ports). Back in the day, serial information needed to be passed from devices like printers, joysticks, scanners, etc to the computer. The simplest way to do this was to pass a series of 1s and 0s to the computer. Both the computer and the device agreed on a speed of information – ‘bits per second’. A computer would pass image data to a printer at 9600 bits per second and the printer would listen for this stream of 1s and 0s expecting a new bit every 1/9600 = 104us (104 micro-seconds, 0.000104 seconds).

As long as the computer output bits at the pre-determined speed, the printer could listen.
Electronics have changed a bit. The standard that is ‘RS232’ dictates that a bit ranges from -12V to +12V. In fact, our AVR  runs 0V to 5V. So how do we get our 5V micro to talk the RS232 +/-12V voltages? This problem has been solved by the IC manufacturers of the world. They have made an IC that is generically known as the MAX232.
The MAX232 is an IC originally designed by a company called Maxim IC that converts the +/-12V signals of RS232 down to the 0/5V signals that our AVR can understand. It also boosts the voltage of our AVR to the needed +/-12V of the RS232 protocol so that a computer can understand our AVR and vice versa. To get our AVR IC sending serial characters to a computer, we have to send these serial signals through a MAX232 circuit so that the computer receives +/-12V RS232 signals.

‘ICL232’ or ‘ST232’ – these are just generics of the MAX232. Everyone says ‘MAX232’. The ICs all function the same and nearly all have the same pinout.

D-sub 9 Connector Pinout

Pinout and diagram of DE9 connector (DB9 connector), commonly used for serial ports (RS-232).

Finally, to connect the microcontroller’s RS232 serial port to PC’s USB port, I used a USB to RS232 UART Serial Converter cable.

2

The DTE (PC) has the male connector (shown below), and the DCE (peripheral) has the female.

3

4

 Hardware circuit

From image shown in figure 3, notice that this motor has two dc motors and one caster wheel. In the hardware circuit of the project, I used two MOSFET transistors to turn either motor on or off. Also a MAX232 IC is used to establish a communication between microcontroller’s RS232 port and laptop’s USB port. Figure 4, displays robot’s hardware circuit which can be simulated by any typical software such as Proteus.

5

Figure 4

To watch the performance of the project tested, click on the following link:

Key terms discussed on the download file:

Detecting events, for visual surveillance or people counting, Organizing information,  Modeling objects or environments, medical image analysis , topographical modeling, Interaction, as the input to a device for computer-human interaction, Sub-domains of computer vision include scene reconstruction, event detection, video tracking, object recognition, learning, indexing, motion estimation, and image restoration, webcam as a line Sensor, Image acquisition, Image processing, Image analysis and execution of commands, RS232 serial port, AVR Microcontroller Digital I/O Ports, converter, getsnapshot function , BW = im2bw(I,level) , BW2 = bwareaopen(BW, P) , imfill function , bw = imclose ( bw , se ), Dilating an Image

The bw = imdilate ( bw , se ) , imdilate function, imshow(I) , Digital Camera Resolution, Recognition of a picture by MATLAB software, Truecolor, Indexed and scaled indexed, Grayscale, Binary, Binary images, Imcomplement complementing image instruction, Strel, Creates a morphological structuring element, SE = strel(shape, parameters), Morphological Filtering, Dilate, erode, reconstruct, Dilate the image,

Leave a Reply

Your email address will not be published. Required fields are marked *