movwf prevcod ; a new button is pressed - rcnt=3 movwf (mtx_buffer+1) movlw 3 movwf rcnt

Similar documents
Lecture (04) PIC16F84A (3)

Assembly Language Instructions

PIC 16F84A programming (II)

Instuction set

Dept. of Computer Engineering Final Exam, First Semester: 2016/2017

16.317: Microprocessor Systems Design I Fall 2013 Exam 3 Solution

EECE.3170: Microprocessor Systems Design I Summer 2017

/* PROGRAM FOR BLINKING LEDs CONEECTED TO PORT-D */

UNIVERSITY OF ULSTER UNIVERSITY EXAMINATIONS : 2001/2002. Semester 2. Year 2 MICROCONTROLLER SYSTEMS. Module Code: EEE305J2. Time allowed: 3 Hours

PIC16F87X 13.0 INSTRUCTION SET SUMMARY INSTRUCTIONS DESCRIPTIONS

UNIVERSITY OF ULSTER UNIVERSITY EXAMINATIONS : 2001/2002 RESIT. Year 2 MICROCONTROLLER SYSTEMS. Module Code: EEE305J1. Time allowed: 3 Hours

D:\PICstuff\PartCounter\PartCounter.asm

Chapter 4 Sections 1 4, 10 Dr. Iyad Jafar

Embedded Systems. PIC16F84A Sample Programs. Eng. Anis Nazer First Semester

CENG 336 INT. TO EMBEDDED SYSTEMS DEVELOPMENT. Spring 2006

Embedded Systems Programming and Architectures

ECE Test #1: Name

Application Note - PIC Source Code v1.1.doc

EEE111A/B Microprocessors

Chapter 13. PIC Family Microcontroller

Week1. EEE305 Microcontroller Key Points

TOPIC 3 INTRODUCTION TO PIC ASSEMBLY LANGUAGE. E4160 Microprocessor & Microcontroller System. Prepared by : Puziah Yahaya JKE, POLISAS / DEC 2010

EECE.3170: Microprocessor Systems Design I Spring 2016

S w e d i s h c r. w e e b l y. c o m j a l i l a h m e l i v e. c o m Page 1

LAB WORK 2. 1) Debugger-Select Tool-MPLAB SIM View-Program Memory Trace the program by F7 button. Lab Work

Arithmetic,logic Instruction and Programs

Flow Charts and Assembler Programs

University of Jordan Faculty of Engineering and Technology Department of Computer Engineering Embedded Systems Laboratory

Chapter 11: Interrupt On Change

Lesson 14. Title of the Experiment: Introduction to Microcontroller (Activity number of the GCE Advanced Level practical Guide 27)

SOLUTIONS!! DO NOT DISTRIBUTE PRIOR TO EXAM!!

SOLUTIONS!! DO NOT DISTRIBUTE!!

Hardware Interfacing. EE25M Introduction to microprocessors. Part V. 15 Interfacing methods. original author: Feisal Mohammed

DHANALAKSHMI COLLEGE OF ENGINEERING, CHENNAI DEPARTMENT OF ELECTRICAL AND ELECTRONICS ENGINEERING. EE6008 Microcontroller based system design

16.317: Microprocessor-Based Systems I Spring 2012

Outlines. PIC Programming in C and Assembly. Krerk Piromsopa, Ph.D. Department of Computer Engineering Chulalongkorn University

APPLICATION NOTE 2361 Interfacing an SPI-Interface RTC with a PIC Microcontroller

Timer2 Interrupts. NDSU Timer2 Interrupts September 20, Background:

16.317: Microprocessor-Based Systems I Summer 2012

PIC16F84A 7.0 INSTRUCTION SET SUMMARY INSTRUCTIONS DESCRIPTIONS

Embedded System Design

Performance & Applications

EECE.3170: Microprocessor Systems Design I Summer 2017 Homework 5 Solution

Section 11. Timer0. Timer0 HIGHLIGHTS. This section of the manual contains the following major topics:

Arithmetic and Logic Instructions. Hsiao-Lung Chan Dept Electrical Engineering Chang Gung University, Taiwan

The University of Texas at Arlington Lecture 5

Section 31. Instruction Set

EE6008-Microcontroller Based System Design Department Of EEE/ DCE

Introduction to PIC Programming

President Alan VK6ZWZ Acting Sec. Don VK6HK Vice President Terry VK6ZLT Treasurer Ces VK6AO

APPLICATION NOTE Wire Communication with a Microchip PICmicro Microcontroller

16.317: Microprocessor Systems Design I Fall Exam 3 December 15, Name: ID #:

SOLAR TRACKING SYSTEM USING PIC16F84A STEPPER MOTOR AND 555TIMER

When JP1 is cut, baud rate is Otherwise, baud rate is Factory default is that JP1 is shorted. (JP1 is jumper type in some model)

which means that writing to a port implies that the port pins are first read, then this value is modified and then written to the port data latch.

Weekly Report: Interactive Wheel of Fortune Week 4 02/014/07-02/22/07 Written by: Yadverinder Singh

PIC16C63A/65B/73B/74B

TM57PA20/ TM57PA40. 8 Bit Microcontroller. User Manual. Tenx reserves the right to change or discontinue this product without notice.

CENG-336 Introduction to Embedded Systems Development. Timers

ME 6405 Introduction to Mechatronics

AN587. Interfacing to an LCD Module. Interfacing to an LCD Module INTRODUCTION OPERATION CONTROL SIGNAL FUNCTIONS TABLE 2: CONDITIONAL ASSEMBLY FLAGS

More (up a level)... Connecting the Nokia 3510i LCD to a Microchip PIC16F84 microcontroller

ECE Homework #3

PIC16C84. 8-bit CMOS EEPROM Microcontroller PIC16C84. Pin Diagram. High Performance RISC CPU Features: CMOS Technology: Peripheral Features:

A Better Mouse Trap. Consumer Appliance, Widget, Gadget APPLICATION OPERATION: Ontario, Canada

PIC PROGRAMMING START. The next stage is always the setting up of the PORTS, the symbol used to indicate this and all Processes is a Rectangle.

Interfacing PIC Microcontrollers. ADC8BIT2 Schematic. This application demonstrates analogue input sampling

PTK8756B 8 Bit Micro-controller Data Sheet

NH-67, TRICHY MAIN ROAD, PULIYUR, C.F , KARUR DT. DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING COURSE MATERIAL

Embedded Systems Design (630470) Lecture 4. Memory Organization. Prof. Kasim M. Al-Aubidy Computer Eng. Dept.

Introduction to PIC Programming

Binary Outputs and Timing

Figure 1: Pushbutton without Pull-up.

Fortune. Semiconductor Corporation 富晶半導體股份有限公司. 8-bit MCU with 1k program ROM, 64-byte RAM, 1 R2F module and 3 13 LCD driver. TD Rev. 1.

Laboratory Exercise 5 - Analog to Digital Conversion

Chapter 5 Sections 1 6 Dr. Iyad Jafar

Section 13. Timer0 HIGHLIGHTS. Timer0. This section of the manual contains the following major topics:

Section 4. Architecture

/ 40 Q3: Writing PIC / 40 assembly language TOTAL SCORE / 100 EXTRA CREDIT / 10

PIC16F8X 18-pin Flash/EEPROM 8-Bit Microcontrollers

M PIC16F84A. 18-pinEnhanced FLASH/EEPROM 8-Bit Microcontroller. High Performance RISC CPU Features: Pin Diagrams. Peripheral Features:

Outline. Micriprocessor vs Microcontroller Introduction to PIC MCU PIC16F877 Hardware:

Input/Output Ports and Interfacing

Here is a sample of the Hellschrieber sent by this project: Following is the PIC MPASM Source Code for Version 0.03 of the Beacon:

4.5.1) The Label Field ) The Mnemonic Field. 4.5) Assembly Language Program Structure A PIC18 ALP consists of 3 type of statements:

ECE 354 Computer Systems Lab II. Interrupts, Strings, and Busses

PIC16F8X. 8-Bit CMOS Flash/EEPROM Microcontrollers PIC16F8X PIC16CR8X. Pin Diagram. Devices Included in this Data Sheet:

PIC Discussion. By Eng. Tamar Jomaa

Chapter 10 Sections 1,2,9,10 Dr. Iyad Jafar

Hi Hsiao-Lung Chan Dept Electrical Engineering Chang Gung University, Taiwan

PIC16F84A. 18-pin Enhanced Flash/EEPROM 8-Bit Microcontroller. Devices Included in this Data Sheet: Pin Diagrams. High Performance RISC CPU Features:

Discrete Logic Replacement Message Dispatch Engine

Interfacing PIC Microcontrollers to Peripherial Devices

Computer Engineering Capstone Design Summer A : Handheld Video Games

ECE 354 Introduction to Lab 2. February 23 rd, 2003

Introduction to PICL and PICLab

CONNECT TO THE PIC. A Simple Development Board

Experiment 7:The USART

PIC16C432 OTP 8-Bit CMOS MCU with LIN bus Transceiver

PIN DESCRIPTION Name I/O Description VDD P VSS P 5V Power from USB cable Ground RC6M O X1 I Test/OTP mode clock in Internal clock output (6MHz) VPP I

Transcription:

movlw 0x20 #endif call scan movlw 0xfd tris PORTB ; select colb (RB1) #ifdef MODE_CH8 movlw 0x04 #endif #ifdef MODE_CH4 movlw 0x30 #endif call scan movf cod, W bz loop2 ; if no buton is pressed, skip subwf prevcod, W ; if the same button is pressed, skip bz loop2 movf cod, W movwf prevcod ; a new button is pressed - rcnt=3 movwf (mtx_buffer+1) movlw 3 movwf rcnt movlw 0x40 ; new button - new transmission addwf tcnt, F loop2 movlw 0xf7 1

tris PORTB ; select ID (RB3) call scanid movf cod0, W movwf (mtx_buffer) loop3 movf (mtx_buffer+1), W andlw 0x3f iorwf tcnt, W movwf (mtx_buffer+1) call mtx_send movf rcnt, W bz loop_done decfsz rcnt, F goto loop loop_done movf cod, W btfsc STATUS, Z goto loop0 ; no button was pressed, go sleep ; if the same button is being hold, repeat the transmission goto loop scan movwf cod0 ;movlw 0xc0 scandelay ;addlw 1 ;bnz scandelay movlw 0xf0 2

andwf PORTB, W movwf rowstate incf cod0, F btfss rowstate, 4 goto pressed incf cod0, F btfss rowstate, 5 goto pressed incf cod0, F btfss rowstate, 6 goto pressed incf cod0, F btfss rowstate, 7 goto pressed retlw 0 pressed movf cod0, W movwf cod return scanid clrf cod0 clrw scandelay2 addlw 1 bnz scandelay2 3

movlw 0xf0 andwf PORTB, W movwf rowstate btfss rowstate, 7 bsf cod0, 3 btfss rowstate, 6 bsf cod0, 2 btfss rowstate, 5 bsf cod0, 1 btfss rowstate, 4 bsf cod0, 0 return end RF RECEIVER Filename: decoder.asm NOTES PA0-PA3-> outputs PA4 -> valid reception PA5 <- RX input PB0-PB3<- address bits PB4-PB7-> outputs 4

list p=16f628 CONFIG _CP_OFF & _WDT_OFF & _PWRTE_ON & _HS_OSC & _LVP_OFF & _MCLRE_OFF & _BODEN_ON #include <p16f628.inc> #include "mrxv4.inc" EXPIRE_TIMER EQU 0x12 LATCH_MASK EQU B'11110000' VALID_BIT EQU 4.mainda UDATA 0x20 savew1 res 1 savestatus res 1 savepclath res 1 savefsr res 1 bt res 1 expire_cnt res 1 cur_seq res 1 cur_ch res 1 cur_state res 1 vectors CODE 0 goto main ; go to beginning of program nop nop nop 5

goto itr ; interrupt vector location prog CODE 5 channel_lookup andlw 0x07 addwf PCL, F dt 0x1, 0x2, 0x4, 0x8 dt 0x10, 0x20, 0x40, 0x80 itr movwf savew1 movf STATUS,w clrf STATUS movwf savestatus movf PCLATH,w movwf savepclath clrf PCLATH movf FSR,w movwf savefsr btfsc INTCON, T0IF call t0_int_handler movf savefsr,w movwf FSR 6

movf savepclath,w movwf PCLATH movf savestatus,w movwf STATUS swapf savew1,f swapf savew1,w retfie main ;HARDWARE INIT movlw 7 movwf CMCON movlw (1<<VALID_BIT) MOVWF PORTA clrf PORTB BANKSEL TRISA movlw 0x20 ; A5=input movwf TRISA MOVLW 0x0f ; B0-B3=input movwf TRISB 7

; setup TMR0 interrupt clrwdt ; changing default presc. assignment movlw 0x03 ; prescaler 1:16 assigned to TMR0 movwf OPTION_REG ; T0CS selects internal CLK bsf INTCON, T0IE ; enable TMR0 int BANKSEL TMR0 clrf TMR0 clrf expire_cnt call mrx_init bsf INTCON, GIE warm clrf cur_seq clrf cur_state incf cur_seq, F loop call mrx_receive andlw 0xff bnz loop call mrx_chk_buf andlw 0xff bnz loop movf PORTB, W andlw 0x0f subwf (mrx_buffer), W 8

bnz loop rx_ok movlw EXPIRE_TIMER ; indicate packet reception movwf expire_cnt movf (mrx_buffer+1), W ; if (seq==cur_seq) skip (only expire timer is updated) andlw 0xc0 subwf cur_seq, W bz loop movf (mrx_buffer+1), W andlw 0xc0 movwf cur_seq movf (mrx_buffer+1), W andlw 0x3f bz loop ; illegal channel data addlw 0xff andlw 0x0f movwf bt btfsc bt, 3 goto loop ; ch>=8: illegal with this model call channel_lookup movwf cur_ch bcf INTCON, GIE btfsc (mrx_buffer+1), 5 9

goto state_on_off ; 00-0f: toggle or momentary ON movf cur_ch, W andlw LATCH_MASK bz state_on_off ; momentary ON state_toggle movf cur_ch, W xorwf cur_state, F goto state_done state_on_off movf cur_ch, W xorlw 0xff andwf cur_state, F ; 20-2f: latch ON movf cur_ch, W btfss (mrx_buffer+1), 4 ; 30-3f: latch OFF iorwf cur_state, F goto state_done state_done bsf STATUS, C ; set valid led ON call state_out bsf INTCON, GIE goto loop t0_int_handler bcf INTCON, T0IF movf expire_cnt, F bnz valid_on 10

movlw LATCH_MASK ; clear momentary outputs andwf cur_state, F bcf STATUS, C ; set valid led OFF state_out ; C: turn valid bit on or off? movlw ~(1<<VALID_BIT) andwf cur_state, W ; set valid led ON btfss STATUS, C iorlw (1<<VALID_BIT) ; set valid led OFF movwf PORTA movf cur_state, W movwf PORTB return valid_on decf expire_cnt, F ;;bsf RX_LED return end PROGAM FOR PIC16F690 SERVO MOTOR CONTROL #include <htc.h> /* PIC Configuration Bit: ** INTIO - Using Internal RC No Clock ** WDTDIS - Wacthdog Timer Disable ** PWRTEN - Power Up Timer Enable 11

** MCLREN - Master Clear Enable ** UNPROTECT - Code Un-Protect ** UNPROTECT - Data EEPROM Read Un-Protect ** BORDIS - Borwn Out Detect Disable ** IESODIS - Internal External Switch Over Mode Disable ** FCMDIS - Monitor Clock Fail Safe Disable */ CONFIG(FOSC_INTRCIO & WDTE_OFF & PWRTE_ON & MCLRE_ON & CP_OFF & CPD_OFF & BOREN_OFF & IESO_OFF & FCMEN_OFF); // Using Internal Clock of 8 Mhz #define FOSC 8000000L // Servo definition and variables #define MAX_VALUE 200 #define CCW_ROTATION MAX_VALUE - 20 #define CW_ROTATION MAX_VALUE - 10 #define STOP_ROTATION MAX_VALUE #define THRESHOLD_VALUE 50 unsigned char pulse_max=0; unsigned char pulse_top=0; unsigned char top_value = 0; static void interrupt isr(void) { if(t0if) { // TIMER0 Interrupt Flag pulse_max++; // Pulse Max Increment pulse_top++; // Pulse Top Increment /* MAX_VALUE=200 turn off the pulse */ 12

if (pulse_max >= MAX_VALUE) { pulse_max=0; pulse_top=0; RC2=0; // Turn off RC2 } /* top_value = MAX_VALUE - n, n=10: 10 x 0.1ms = 1.0ms, n=20: 20 x 0.1ms = 2.0ms */ /* 2ms -> CCW Rotation, 1ms -> CW Rotation */ if (pulse_top == top_value) { RC2=1; // Turn On RC2 } TMR0 = 156; // Initial Value for 0.1ms Interrupt T0IF = 0; // Clear TIMER0 interrupt flag } } void main(void) { unsigned char ldr_left; unsigned char ldr_right; int ldr_diff; OSCCON=0x70; // Select 8 Mhz internal clock /* Initial Port Used */ TRISC = 0x03; // Set RC0 and RC1 as input others as Output ANSEL = 0x30; // Set PORT AN4 and AN5 as analog input ANSELH = 0x00; // Set PORT AN8 to AN11 as Digital I/O PORTC = 0x00; // Turn Off all PORTC /* Init Servo Pulse */ 13

pulse_max=0; pulse_top=0; top_value = MAX_VALUE; // top_value = MAX_VALUE: Servo Motor Stop /* Initial ADC */ ADCON1=0b00110000; // Select the FRC for 8 Mhz /* Init TIMER0: Period: Fosc/4 x Prescaler x TMR0 0.0005 ms x 2 * 100 = 0.1 ms */ OPTION_REG = 0b00000000; // 1:2 Prescaller TMR0=156; // Interupt every 0.1 ms T0IE = 1; // Enable interrupt on TMR0 overflow GIE = 1; // Global interrupt enable for(;;) { /* Read the ADC here */ ADCON0=0b00010001; // select left justify result. ADC port channel AN4 GO_DONE=1; // initiate conversion on the channel 4 while(go_done) continue; // Wait for ldr_left conversion done ldr_left=adresh; // Read 8 bits MSB, Ignore 2 bits LSB in ADRESL ADCON0=0b00010101; // select left justify result. ADC port channel AN5 GO_DONE=1; // initiate conversion on the channel 5 while(go_done) continue; // Wait for ldr_right conversion done ldr_right=adresh; // Read 8 bits MSB, Ignore 2 bits LSB in ADRESL 14

/* Get the different */ ldr_diff=ldr_left - ldr_right; if ((ldr_diff >= -THRESHOLD_VALUE) && (ldr_diff <= THRESHOLD_VALUE)) { top_value = MAX_VALUE; // Stop the Servo Motor } else { if (ldr_diff > THRESHOLD_VALUE) { top_value = CCW_ROTATION; // Counterclockwise Rotation } else { top_value = CW_ROTATION; // Clockwise Rotation } } } } /* EOF: servo.c */ 15

PCB LAYOUT RF TRANSMITTER RF RECEIVER: 16

Created by Simpo PDF Creator Pro (unregistered version) http://www.simpopdf.com MAIN PROJECT 2012 ESC DRIVER: RUDDER: 17

Created by Simpo PDF Creator Pro (unregistered version) http://www.simpopdf.com MAIN PROJECT 2012 FLAPRON RIGHT AND ELEVATOR: FLAPRON LEFT: 18

DATA SHEETS 19

20

21

22

23

If you are really interested in this projetct,then for any help pls feel free to contact : pradu333@gmail.com 24