assembly program for a pic based packing line pr306

3
Assembly program for a packing line. (Assignment in the page 7 of “Microcontroller Programming ” lab sheet) Using PIC16F84A microcontroller PORTA, Bit0sensor0S0(input) PORTA,Bit1sensor1S1(input) PORTB, Bit0Motor0M0(output) PORTB,Bit1Piston1P1(output) Steps of the program. 1. Check for S01 a. When S01, M01 2. Check for S11 a. When S11, P11 3. Wait for 2seconds. 4. Switch off M0. 5. Go back to step 1. Program STATUS equ 03h PORTA equ 05h PORTB equ 06h TRISA equ 85h

Upload: dilupa-herath

Post on 19-Jan-2016

10 views

Category:

Documents


0 download

DESCRIPTION

A program for a packing line, in assembly language. Works for PIC16F84A and PIC16F877 microcontrollers. Uses a conveyor belt, pneumatic piston and two proximity sensors. No circuit diagram.(For PR306 - Introduction to Industrial Automation, offered by the Department of Production Engineering, Faculty of Engineering, University of Peradeniya. )

TRANSCRIPT

Page 1: Assembly Program for a PIC based Packing Line PR306

Assembly program for a packing line. (Assignment in the page 7 of “Microcontroller Programming ” lab

sheet)

Using PIC16F84A microcontroller

PORTA, Bit0sensor0S0(input)

PORTA,Bit1sensor1S1(input)

PORTB, Bit0Motor0M0(output)

PORTB,Bit1Piston1P1(output)

Steps of the program.

1. Check for S01

a. When S01, M01

2. Check for S11

a. When S11, P11

3. Wait for 2seconds.

4. Switch off M0.

5. Go back to step 1.

Program

STATUS equ 03h

PORTA equ 05h

PORTB equ 06h

TRISA equ 85h

Page 2: Assembly Program for a PIC based Packing Line PR306

TRISB equ 86h

COUNT1 equ 21h ; any two general purpose registers

COUNT2 equ 22h

BSF STATUS,5 ; Go to bank 1

MOVLW 0b00000011

MOVWE TRISA ; make PORTA bit 0 and 1 inputs

MOVLW 0b00000000

MOVWF TRISB ;make PORTB bit0 and 1 outputs

BCF STATUS,5 ; Go back to bank 0

Start MOVLW 0x00

MOVWF PORTA ; make sure PORTA and PORTB are zero in start

MOVWF PORTB

Loop1 BTFSS PORTA,0

GOTO Loop1 ;check for sensor0.

BSF PORTB,0 ; switch on motor0

Loop2 BTFSS PORTA,1 ; check for sensor 1

GOTO Loop2

BSF PORTB,1 ; switch on piston1

CALL Delay ; wait for 2s

BCF PORTB,0 ;switch off motor

GOTO Start

Delay

MOVLW 0xFF

MOVWF COUNT1

MOVWF COUNT2

Loop3 DECFSZ COUNT1,1

GOTO Loop3

DECFSZ COUNT2,1

GOTO Loop3

RETURN

Page 3: Assembly Program for a PIC based Packing Line PR306

END

This delay is not 2seconds. Timing generation is not covered in our course. The delay I

have used here is (255x2)x(1/1000000)seconds, if the microcontroller is running at a

4MHz clock frequency.