57
PRESENTATION ON PIC18F4520 & ROBOTICS By- Siddhant Chopra

Pic18 f4520 and robotics

Embed Size (px)

Citation preview

Page 1: Pic18 f4520 and robotics

PRESENTATION ON

PIC18F4520 & ROBOTICS

By- Siddhant Chopra

Page 2: Pic18 f4520 and robotics
Page 3: Pic18 f4520 and robotics

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.

Page 4: Pic18 f4520 and robotics

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.

Page 5: Pic18 f4520 and robotics

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

Page 6: Pic18 f4520 and robotics

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

Page 7: Pic18 f4520 and robotics
Page 8: Pic18 f4520 and robotics

FEATURES OF 18F4520

Page 9: Pic18 f4520 and robotics

TYPES OF ARCHITECTURE

Von Neumann Architecture

Harvard Architecture

Page 10: Pic18 f4520 and robotics

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

Page 11: Pic18 f4520 and robotics

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

Page 12: Pic18 f4520 and robotics

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

Page 13: Pic18 f4520 and robotics
Page 14: Pic18 f4520 and robotics
Page 15: Pic18 f4520 and robotics

PIN DIAGRAM

Page 16: Pic18 f4520 and robotics

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.

Page 17: Pic18 f4520 and robotics

PROGRAMMING

Page 18: Pic18 f4520 and robotics

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

Page 19: Pic18 f4520 and robotics

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.

Page 20: Pic18 f4520 and robotics

DELAY SECTIONContd.

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

Page 21: Pic18 f4520 and robotics

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

Page 22: Pic18 f4520 and robotics

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

Page 23: Pic18 f4520 and robotics

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

Page 24: Pic18 f4520 and robotics

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

Page 25: Pic18 f4520 and robotics

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

Page 26: Pic18 f4520 and robotics

ToCON Register

Page 27: Pic18 f4520 and robotics

Other programs done are

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

rotations• Traffic lights

Page 28: Pic18 f4520 and robotics

ROBOTICS

Page 29: Pic18 f4520 and 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.

Page 30: Pic18 f4520 and robotics

Mechanism of Robotics

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

– Open loop– Closed loop

Page 31: Pic18 f4520 and robotics

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.

Page 32: Pic18 f4520 and robotics

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.

Page 33: Pic18 f4520 and robotics

Wheeled robot

Legged robot

Page 34: Pic18 f4520 and robotics

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.

Page 35: Pic18 f4520 and robotics

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.

Page 36: Pic18 f4520 and robotics

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) .

Page 37: Pic18 f4520 and robotics

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

Page 38: Pic18 f4520 and robotics

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.

Page 39: Pic18 f4520 and robotics

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.

Page 40: Pic18 f4520 and robotics

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

Page 41: Pic18 f4520 and robotics

Desired Action

Controller ActuatorO/P

Feedback

Page 42: Pic18 f4520 and robotics

EscapeObstacle Controller DC

MotorsTurned away from

obstacle

Infrared Receiving Module

Page 43: Pic18 f4520 and robotics

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.

Page 44: Pic18 f4520 and 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

Page 45: Pic18 f4520 and robotics

Machine-gun equippedrobot developed by

Samsung

Guide robot in a hosp.

Robot waiter in Hong-Kong

restaurant

Painting Robots

Pipeline

Inspection robot

Page 46: Pic18 f4520 and robotics

MECHANICAL ASSEMBLING

Page 47: Pic18 f4520 and robotics
Page 48: Pic18 f4520 and robotics

PROJECT

Page 49: Pic18 f4520 and robotics

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.

Page 50: Pic18 f4520 and robotics

Transmitter of Robocar

Page 51: Pic18 f4520 and robotics

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);}

Page 52: Pic18 f4520 and robotics

Receiver of Robocar

Page 53: Pic18 f4520 and robotics

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

Page 54: Pic18 f4520 and robotics

WORKING

Page 55: Pic18 f4520 and robotics

APPLICATIONS

• Industries• Home automation

Page 56: Pic18 f4520 and robotics

ANY QUESTIONS ???

Page 57: Pic18 f4520 and robotics