Pic18 f4520 and robotics

Post on 18-Jan-2017

1,223 views 2 download

transcript

PRESENTATION ON

PIC18F4520 & ROBOTICS

By- Siddhant Chopra

MICRO CONTROLLER ??

• Microcontroller is a small (micro) single-chip computer designed to perform a specific function, and the specific function is to control (controller) objects, processes or events.

• It is dedicated to one task, or a set of closely related task. It is similar to a personal computer, it has similar components built on to a single chip: CPU, Memory (ROM and RAM), I/O ports, Serial ports, Timer, ADC.

BASIC ARCHITECTURE OF MCU

• CPU: Processing Module.CPU: Processing Module. RAM: for storing DATA.RAM: for storing DATA. ROM: for storing the app. program.ROM: for storing the app. program. Ports: For interfacing with the Ports: For interfacing with the

outside world.outside world. Timer: Allows the MCU to performTimer: Allows the MCU to perform tasks for certain time periods.tasks for certain time periods. ADC: Allows the MCU to accept ADC: Allows the MCU to accept analogue input data foranalogue input data for

processing.processing.

BASIC DIFFERNCE BETWEEN MP & MC

• Clock rate of MPs are of the order of GHz.

Where as ........Where as ........

MCU is a more self-contained (CPU, RAM, ROM, I/O ports, and timers) and independent and functions as a tiny computer dedicated to a

specific task to control a single system...• Clock rate of MCs are of the order of MHz

WHY PIC HAS BEEN PICKED ?

• Wide range: More than 200 MCUs in the product portfolio.• Available in 8 ,16 and 32 bit in analogue as well as Digital Signal

Controller family.• RISC based architecture• Pin out compatibility• Software compatibility, Simple Instruction Set • Peripheral compatibility• Easy migration across product families.• Common and easy to use development tools.• Extensive support - Information is available in wide range and

depth.• Available in all package types

FEATURES OF 18F4520

TYPES OF ARCHITECTURE

Von Neumann Architecture

Harvard Architecture

VON NEUMANN ARCHITECTURE

• Single memory for storing both program and data.

• It has single bus which is multiplexed to be used as both address bus and data bus.

• The content of RAM can be used for both program storage as well as variable storage.

Single bus

HARVARD ARCHITECTURE

• Separate memory banks for program and data storage.

• It has a RAM for data storageand separate ROM for program storage.

• Has two sets of buses.One can simultaneously access these buses.

Data address bus

Program address bus

BLOCK DIAGRAM• operation of accumulator is scratch pad operation operation.

PIN DIAGRAM

PORT PINS

• Port A is a 8 pin bi directional port 5 analog / 6 digital pins

• Port B is a 8 pin bi directional port 8 digital pins/5 analog pins

• Port C is a 8 pin bi directional port 8 digital pins

• Port D is a 8 pin bi directional port 8 digital pins

• Port E is a 4 pin port 3 pin bi directional 3 analog / digital pins

• Pin 1 Digital input pin • Pin 13 & 14 are digital I/O digital pins if not used for XT Osc Total availability

13 analog pins 35digital pins 1 digital input pin

• Pin 39 & 40 (PORTB) are used for programming/debugging.

PROGRAMMING

PATTERN ON LEDsIN ASSEMBLY LANGUAGE IN C LANGUAGEList p=18F4520, f =inhx32 #include<p18F4520.h>#include <p18F4520.inc> ;This is a header file for PIC18F452 void delay(void); COUNTERL EQU 0X00 void main() COUNTERH EQU 0X01 {ORG 0x0000 TRISB=0x00;GOTO START ;Reset Vector PORTB=0x00;START while(1)CLRF PORTB ;Clear PORTB output latches {CLRF TRISB ;Load value to make PORTB output port PORTB=0x00;LOOP delay();BSF PORTB,0 ;Turn on LED on RB0 }CALL DELAY ;Call delay routine }BSF PORTB,0 ;Turn on LED on RB0 void delay(void)BSF PORTB,1 ;Turn on LED on RB1 {CALL DELAY unsigned char I,j;MOVLW 0X07 for(i=0;i<255;i++)MOVWF PORTB for(j=0;;j<255;j++)CALL DELAY }MOVLW 0X0FMOVWF PORTBCALL DELAY DELAY MOVLW 0XC4MOVWF COUNTERHS1MOVLW 0XFFMOVWF COUNTERLDECFSZ COUNTERL , 1GOTO$ - 1 DECFSZ COUNTERH,1 GOTOS1RETURN END

7 SEGMENT DISPLAYLISTP=18F4520#INCLUDE<P18F4520.INC>D1 EQU 0X20D2 EQU 0X21ORG 0X00GOTO START STARTMOVLW 0X00 MOVWF PORTCMOVWF TRISC ;selecting PORTC as output portLOOPMOVLW B'00111111‘ ;code for displaying 0 on displayMOVWF PORTCCALL DELAYMOVLW B'00000110‘ ;code for displaying 1 on displayMOVWF PORTCCALL DELAYMOVLW B'01011011‘ ;code for displaying 2 on displayMOVWF PORTCCALL DELAYMOVLW B'01001111‘ ;code for displaying 3 on displayMOVWF PORTCCALL DELAYGOTO LOOPContd.

DELAY SECTIONContd.

DELAYMOVLW 0X01MOVWF D1POLMOVLW .1MOVWF D2POOLDECFSZ D2,FGOTO POOLDECFSZ D1,FGOTO POLRETURNEND

Counter using 2 seven segment displays segment displays

LIST P=18F4520#INCLUDE<P18F4520.INC>D1 EQU 0X20D2 EQU 0X21ORG 0X0000GOTO STARTSTARTMOVLW 0X00MOVWF TRISDMOVWF TRISCMOVWF PORTDMOVWF PORTCLOOPMOVLW B'00111111'MOVWF PORTCCALL SUBCALL DELAYMOVLW B'00000110'MOVWF PORTCCALL SUBCALL DELAYMOVLW B'01011011'MOVWF PORTCCALL SUBCALL DELAYMOVLW B'01001111'MOVWF PORTCCALL SUBCALL DELAYGOTO LOOP

Delay sectionDELAYMOVLW 0X01MOVWF D1POLMOVLW .1MOVWF D2POOLDECFSZ D2,FGOTO POOLDECFSZ D1,FGOTO POLRETURN

SUB sectionSUBMOVLW B'00111111'MOVWF PORTDCALL DELAYMOVLW B'00000110'MOVWF PORTDCALL DELAYMOVLW B'01011011'MOVWF PORTDCALL DELAYMOVLW B'01001111'MOVWF PORTDCALL DELAYMOVLW B'01100110'MOVWF PORTDCALL DELAYMOVLW B'01101101'MOVWF PORTDCALL DELAYMOVLW B'01111101'MOVWF PORTDCALL DELAYMOVLW B'00000111'MOVWF PORTDCALL DELAYMOVLW B'01111111'MOVWF PORTDCALL DELAYMOVLW B'01101111'MOVWF PORTDCALL DELAYGOTO SUBRETURNEND

Program of PWM

List p=18F4431, f =inhx32#include <p18F4431.inc> ;This is a header file for PIC18F452org 00000hgoto STARTSTART CLRF PORTCMOVLW 0X63MOVWF OSCCONCLRF TRISC ; PORTC AS OUTPUTMOVLW .25 ;FREQUENCY IS 38 KHZMOVWF PR2 ;TIME PEROID OF 26 US MOVLW .13 ; FOR DUTY CYCLE OF 50% MOVWF CCPR1L ; SET THE CCP FOR PWMMOVLW 0X0C MOVWF CCP1CON ;SETTING FOR THE PRESCALER OF TIMER 2MOVLW 0X00MOVWF T2CON ;THE TIMER IS ON BSF T2CON,2GOTO $ ;KEEP THE controller BUSYEND

PROGRAM OF TIMER 05 SECOND DELAY ,TIMER0,16BIT

LIST P=18F4520 , f = inhx32#include <p18F4520.inc>ORG 0X00GOTO MAINMAINCLRFINTCON ;PRIORITY overflow ,int flagMOVLW B'00000110' ;Disable Timer0:16 bit,int clock.MOVWF T0CON ;Prescaler 1:128CLRFTRISBLOOPBSF PORTB,0 ;LED ONCALLDELAYBCF PORTB,0 ;LED OFFCALL DELAYGOTO LOOPDELAYMOVLW 0X67MOVWF TMR0HMOVLW 0X69MOVWF TMR0LBSF T0CON,7 BTFSS INTCON , TMR0IFGOTO $-1BCF INTCON , TMR0IFBCF T0CON,7 RETURNEND

ToCON Register

Other programs done are

• LCD • Stepper motor• Washing machine for fixed number of time• Washing machine for fixed number of

rotations• Traffic lights

ROBOTICS

EVOLUTION OF ROBOT

• Robotics brings together several very different engineering areas and skills.

• The word robot comes from the Czech word "robota", meaning "forced labor.“

• A robot is an electro-mechanical device that can perform autonomous or preprogrammed tasks.

Modern defination of Robot is-

A robot is a machine designed to execute one or more task repeatedly, with speed and precision.

Mechanism of Robotics

• Locomotion system• Power supply system• Actuators• Control system

– Open loop– Closed loop

Locomotion system

• Locomotion is nothing but the movement or the ability to move from one place to another. So,

• Robot locomotion is the collective name for the various methods that robots use to transport themselves from place to place.

Mechanism to achieve Locomotion

• Wheeled robots – These robots are quite energy efficient and simple to control.

• other forms of locomotion (legged locomotion) may be more appropriate for a number of reasons e.g. traversing rough terrain, moving and interacting in human environments.

• A major goal in this field is in developing capabilities for robots to autonomously decide how, when, and where to move.

Wheeled robot

Legged robot

Main issue in legged locomotion

Stability is the main issue in legged locomotion.

Stability can be divided into the 1) Static stability criterion 2) Dynamic stability criterion.

Static stability criterion

• Static stability means that the robot is stable, with no need of motion at every moment of time.

• Static stability is given, when the centreof mass is completely within the support polygon and the polygon’s area is greater than zero.

• To achieve statically stable walking a robot must have a minimum number of four legs, because during walking at least one leg is in the air.

• Statically stable walking means that all robots’ motion can be stopped at every moment in the gait cycle without overturning.

Dynamic stability criterion

• Most two legged walking machines are dynamically stable for several reasons -

Human like robots have relatively small footprints, because of this the support polygon is almost a line which is even reduced to a single point during walking. Therefore the robot must actively balance itself to prevent overturning

In face of that the robots’ centre of mass has to be shifted actively between the footprints. But the robots exact centre of mass is hard to predict due to the high dynamic of walking (for example because of the force which is imparted to whole robot when one leg swings forward) .

Legged configuration

• If a robot has k legs the number of possible events N is, accordant to [1], N=(2k-1)!

In case of a bipedal walking machine (k=2) the number of possible events is N=(2k-1)! = (2*2-1)! = 3! = 6 So there are six possible different events, these are 1. Lift left leg 2. Release left leg 3. Lift right leg 4. Release right leg 5. Lift both legs together 6. Release both legs together

• In case of k=6 legs there are already 39916800 possible events

Power supply system

• Suitable power source is needed to run the robots.

• Mobile robots are most suitably powered by batteries.

• The weight and energy capacity of the batteries may become the determinative factor of its performance.

Actuator

• An actuator is a type of motor for moving or controlling a mechanism or system. It is operated by a source of energy, typically electric current, hydraulic fluid pressure, or pneumatic pressure, and converts that energy into motion.

• An actuator is the mechanism by which a control system acts upon an environment.

There is no error correction. No way to check if the actuator was able to take the desired action

Simple system to design, not very reliable Requires regular calibration of the system

Controller

Actuator

O/PDesired Action Controller Actuator

Desired Action

Controller ActuatorO/P

Feedback

EscapeObstacle Controller DC

MotorsTurned away from

obstacle

Infrared Receiving Module

INTERFACE WITH OTHERS

• Robotics is a versatile, multi-disciplinary field,spanning a number of scientific and engineeringareas where the latest knowledge and techno--logical advances contribute to thegrowth of Robotics.

APPS. OF ROBOTICS

• EdutainmentEducational Robots, Robot Toys, Entertainment, Robotic Art

• Outdoor RoboticsLand, Sea, Air, Space Wheeled Mobile Robot

• Advanced production systemsIndustrial robotics

• Adaptive robot servants and intelligent homesIndoor Service Robots, Ubiquitous Robotics

• Network RoboticsInternet Robotics, Robot ecology

• Health Care and Life QualitySurgical Robotics, Bio-Robotics, Assistive Technology

• Military RoboticsIntelligent Weapons, Robot Soldiers, Super-humans Transportation

robots in a hospital

Machine-gun equippedrobot developed by

Samsung

Guide robot in a hosp.

Robot waiter in Hong-Kong

restaurant

Painting Robots

Pipeline

Inspection robot

MECHANICAL ASSEMBLING

PROJECT

Robocar using Arduino Board

• It is a robot that can besteered in any direction just like youdrive your car. Wireless steeringsenses the motion and transmits correspondinginstruction to control the robotthrough RF communication.

Transmitter of Robocar

Program of sensing directions from accelerometer

const int groundpin = 18;             // analog input pin 4 -- groundconst int powerpin = 19;              // analog input pin 5 -- voltageconst int xpin = A3;                  // x-axis of the accelerometerconst int ypin = A2;                  // y-axisconst int zpin = A1;                  // z-axis (only on 3-axis models)

void setup(){  // initialize the serial communications:  Serial.begin(9600);  pinMode(groundpin, OUTPUT);  pinMode(powerpin, OUTPUT);  digitalWrite(groundpin, LOW);   digitalWrite(powerpin, HIGH);}

void loop(){  // print the sensor values:  Serial.print(analogRead(xpin));  // print a tab between values:  Serial.print("\t");  Serial.print(analogRead(ypin));  // print a tab between values:  Serial.print("\t");  Serial.print(analogRead(zpin));  Serial.println();  // delay before next reading:  delay(100);}

Receiver of Robocar

COMPONENTS USED

• Arduino Board• Accelerometer• Micro Controller (PIC 16F877A & Atmega328)• Encoder IC (HT12E)• Transmitter & Receiver Module• Decoder IC (HT12D)• Motor Driver IC (L293D)

Arduino Board

Accelerometer

WORKING

APPLICATIONS

• Industries• Home automation

ANY QUESTIONS ???