Internet de les coses aplicat a la millora del servei de Bicing de Barcelona Pàg. 1
|
|
- Cecilia Sims
- 6 years ago
- Views:
Transcription
1 Internet de les coses aplicat a la millora del servei de Bicing de Barcelona Pàg. 1 * Program of the TFG: Internet de les Coses Aplicat a la Millora del Servei de Bicing de Barcelona * /****** I N C L U D E S ***************************************************/ #include<p18f4520.h> #include "Configurationbits.h" #include <usart.h> #include <delays.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <math.h> #include<timers.h> #include <pwm.h> #include "definitions.h" /****** D E C L A R A T I O N S ********************************************/
2 Pàg. 2 unsigned char in = 0, out = 0; //Pointers of the FIFO Buffer. const rom unsigned char accel1[] = "ATS650=1,1,1,2,1"; //AT command to turn on the accelerometer with filter const rom unsigned char accel2[] = "ATS650=1,0,1,2,0";//AT command to turn on the accelerometer without filter const rom unsigned char accel3[] = "ATS650=0"; //AT command to turn off the accelerometer const rom unsigned char gps1[] = "AT$GPS=1,4,900,65535,2,0";//AT command to turn on the GPS until a valid fix is obtained const rom unsigned char gps2[] = "AT$GPS=1,4,900,65535,2,2";//AT command to turn on the GPS until a valid fix is obtained and shows it. const rom unsigned char temp1[] = "ATI26";//AT command to get the temperature const rom unsigned char accident_message[] = "AT$SSMS=accident";//AT command to send an accident message const rom unsigned char tracking_message[] = "AT$SSMS=tracking";//AT command to send a tracking message unsigned char coordinate_message[17] = "AT$SSMS=";//AT command to send a coordinate message const rom unsigned char temp_message[] = "AT$SSMS=T_alert";//AT command to send a temperature message const rom unsigned char broken_bycicle_message[] = "AT$SSMS=bike_out";//AT command to send a "bike is broken" message unsigned char latitude[9] = 0;//String containing the latitude unsigned char longitude[9] = 0;//String containing the longitude unsigned char sec[4]=0;//string used to get the seconds of the coordinates unsigned char xaxis[5] = 0, yaxis[5] = 0, zaxis[5] = 0;//Strings containing the axis acceleration. unsigned char cont=0; //Counter. int x = 0, y = 0, z = 0; //Axis acceleration. unsigned int ac1 = 0, ac2=0; //Acceleration (module).
3 Internet de les coses aplicat a la millora del servei de Bicing de Barcelona Pàg. 3 unsigned int dif = 0; //Difference between two consecutive acceleration samples. float ang = 0; //Angle of inclination unsigned int c = 0; //10s counter for accident unsigned int c2 = 0; //10s counter for tracking unsigned char c3 = 0; //10min counter for tracking unsigned char c4 = 0; //2h counter for tracking unsigned int pause=1; //Condition to start c unsigned char k=0; //Used in "for" structures unsigned char desac = 0; //Condition to send the accident message unsigned char temp[4]=0;//string containing the temperature int t = 0; //Temperature struct unsigned tracking_flag:1; //Flag to indicate tracking unsigned temperature_flag:1; //Flag to indicate temperature unsigned broken_flag:1; //Flag to indicate that the bike is broken Flags; #pragma udata section = 0x100//Locate the buffer from address 0x100 unsigned char Buffer[256]; //FIFO buffer with 256 positions #pragma udata unsigned int abval(int val); void ini_buffer(void); void Write(unsigned char r); void send_command(const rom unsigned char *s); void send_command2(unsigned char *s); unsigned char str_in_buffer(unsigned char v); unsigned int acceleration(unsigned char ch);
4 Pàg. 4 float angle(float az); void temperature(void); void send_bike_out_message(void); void pos(void); void InterruptHandlerHigh(void); void send_coordinates(void); /****** M A I N P R O G R A M ********************************************/ void main(void) TRISBbits.TRISB1 = 0; INTCON = 0x00; //Disable all the interrupts OpenTimer0(TIMER_INT_ON & T0_8BIT & T0_SOURCE_INT & T0_PS_1_4); //Open timer0 (8 bits, interrupt enabled, prescaler=4) INTCON2bits.TMR0IP = 1; //High priority for the TMR0 overflow interrupt INTCONbits.TMR0IE = 1; //Enable the TMR0 overflow interrupt TRISCbits.TRISC6 = 0; //Configures RC6 as output (RC6 is the TX-USART pin) //Opens the UART OpenUSART(USART_TX_INT_OFF & USART_RX_INT_OFF & USART_ASYNCH_MODE & USART_EIGHT_BIT & USART_CONT_RX & USART_BRGH_HIGH, 25); OpenTimer2(TIMER_INT_OFF & T2_PS_1_1); //Open timer2 (prescaler=1) OpenPWM1(T); //Configure PWM frequency with Timer2 (period = 230) SetDCPWM1(0); //Fixed Duty Cycle (0%)
5 Internet de les coses aplicat a la millora del servei de Bicing de Barcelona Pàg. 5 IPR1bits.RCIP = 1; //High priority for the UART interrupt PIE1bits.RCIE = 1; //Enable the UART receive interrupt RCONbits.IPEN = 1; //Enable priority levels ini_buffer();//put all characters to 0. Flags.tracking_flag = 0; Flags.temperature_flag = 0; Flags.broken_flag = 0; INTCONbits.GIEH = 1; //Enable high-priority interrupts send_command(gps1); //Activate GPS send_command(accel1); //Activate accelerometer with filter while(1) if(in!= out) //Is the FIFO Buffer empty? Delay10KTCYx(10); ac2=ac1; ac1 = acceleration(0); //Compute acceleration module dif=abval(ac2-ac1); if (dif > min_difference) //Is dif bigger than minimum difference? ac1=0; SetDCPWM1(Ton); //Fixed Duty Cycle (50%, 10 bits, 1024/2) send_command(accel2); //Activate accelerometer without filter
6 Pàg. 6 c = 0; pause = 0; //Activate the alarm desac = 0; while (c < t_limit_to_desactivate) //Time to desactivate the alarm if (in!= out) //Is the FIFO Buffer empty? Delay10KTCYx(10); ang = angle ((float)acceleration(1)/ac_module_motionless);//compute angle of inclination SetDCPWM1(0); //Fixed duty cycle (0%) pause = 1; c=0; if (desac == 0) //Is the alarm still activated? pos();//compute coordinates send_command(accident_message); //Send accident message while (in == out); Delay10KTCYx(10); send_coordinates();//send coordinates send_command(accel1); //Activate accelerometer with filter if (Flags.tracking_flag == 1) //Flag activated each 10min
7 Internet de les coses aplicat a la millora del servei de Bicing de Barcelona Pàg. 7 pressed Flags.tracking_flag = 0; pos(); send_command(tracking_message); //Send tracking message while (in == out); Delay10KTCYx(10); send_coordinates();//send coordinates send_command(accel1); //Activate accelerometer with filter if (Flags.temperature_flag == 1) //Flag activated each 10s Flags.temperature_flag = 0; temperature(); //Compute temperature and send message if (Flags.broken_flag == 1) //Flag activated if de S1 button is Flags.broken_flag = 0; send_bike_out_message();
8 Pàg. 8 /****** F U N C T I O N S ***********************************************/ * Function: int abval(int val) * Input: Signed integer * Output: Unsigned integer * Overview: Compute module from an integer unsigned int abval(int val) return (val<0? (-val) : val); * Function: void ini_buffer(void) * Input: None * Output: None * Overview: Clean the buffer void ini_buffer(void) unsigned char ct = 0; while (ct!= Buffer_max_position) Buffer[ct++] = 0;
9 Internet de les coses aplicat a la millora del servei de Bicing de Barcelona Pàg. 9 * Function: void Write(unsigned char r) * Input: Character to send * Output: None * Overview: Send a character to the TD1204 device void Write(unsigned char r) while(busyusart());//wait while UART is busy Delay10KTCYx(2); WriteUSART(r); //Write the character * Function: unsigned char str_in_buffer(unsigned char v) * Input: Buffer's output pointer * Output: Buffer's output pointer Place the out pointer to the first empty place after * Overview: reading the validation sentence unsigned char str_in_buffer(unsigned char v) unsigned char search[] = 'K',13,10; unsigned char ct=0; while(ct!= Buffer_max_position) if(buffer[v+ct] == search[0] && Buffer[v+ct+1] == search[1] && Buffer[v+ct+2] == search[2])
10 Pàg. 10 return v; ct++; return v+ct+3; * Function: void send_command(const rom unsigned char *s) * Input: Pointer to a ROM buffer containing a command to send * Output: None * Overview: Send a command to the TD1204 device void send_command(const rom unsigned char *s) unsigned char aux; unsigned char cont=0; while (cont < strlenpgm(s)) aux = s[cont++]; Write(aux); Write(carriage_return); Delay10KTCYx(10); * Function: void send_command2(const rom unsigned char *s)
11 Internet de les coses aplicat a la millora del servei de Bicing de Barcelona Pàg. 11 * Input: Pointer to a RAM buffer containing a command to send * Output: None * Overview: Send a command to the TD1204 device void send_command2(unsigned char *s) unsigned char aux; unsigned char cont=0; while (cont < strlen(s)) aux = s[cont++]; Write(aux); Write(carriage_return); Delay10KTCYx(10); * Function: unsigned int acceleration(unsigned char ch) * Input: 0 or 1 This function return the acceleration module if * Output: input=0 or the acceleration's z component if input=1 * Overview: Compute the acceleration unsigned int acceleration(unsigned char ch) while (Buffer[out]!= space) xaxis[cont++] = Buffer[out++];
12 Pàg. 12 cont = 0; out+= 3; while (Buffer[out]!= space) yaxis[cont++] = Buffer[out++]; cont = 0; out += 3; while (Buffer[out]!= carriage_return) zaxis[cont++]=buffer[out++]; cont = 0; out+= 2; x = atoi(xaxis); y = atoi(yaxis); z = atoi(zaxis); while(cont!=5) xaxis[cont] = yaxis[cont] = zaxis[cont] = 0; cont++; cont = 0; return (ch? (z) : (sqrt(pow(x,2)+pow(y,2)+pow(z,2)))); * Function: float angle(float az) * Input: Z axis acceleration value (normalized) * Output: Angle of inclination (in radians)
13 Internet de les coses aplicat a la millora del servei de Bicing de Barcelona Pàg. 13 * Overview: Measure the angle of inclination. float angle(float az) if (0 <= z) return (z > ac_module_motionless? (0) : (acos(az))); else if (0 > z) return (z < -ac_module_motionless? (pi) : (acos(az-16))); * Function: void temperature(void) * Input: None * Output: None Read temperature and send an alarm message if it's * Overview: out of the limits void temperature(void) send_command(accel3); send_command(temp1); out += 2; while (Buffer[out]!= carriage_return) temp[cont++]=buffer[out++];
14 Pàg. 14 cont=0; out+=8; t = atoi(temp); while(cont!=4) temp[cont++] = 0; cont = 0; if (t > t_max t < t_min) send_command(temp_message); while (in == out); Delay10KTCYx(10); send_command(accel1); * Function: void send_bike_out_message(void) * Input: None * Output: None * Overview: Send the message: bike_out void send_bike_out_message(void) send_command(accel3);
15 Internet de les coses aplicat a la millora del servei de Bicing de Barcelona Pàg. 15 send_command(broken_bycicle_message); while (in == out); Delay10KTCYx(10); send_command(accel1); * Function: void pos(void) * Input: None * Output: None * Overview: Compute longitude and latitude void pos(void) send_command(accel3); send_command(gps2); while (in == out); Delay10KTCYx(30); out+=17; latitude[0] = Buffer[out++]; latitude[1] = Buffer[out++]; latitude[2] = degrees; latitude[3] = Buffer[out++]; latitude[4] = Buffer[out++]; latitude[5] = minutes; out++;
16 Pàg. 16 for (k=0;k<4;k+=1) sec[k] = Buffer[out++]; latitude[6] = ((char)(atoi(sec)*v2seconds))/10 + '0'; latitude[7] = ((char)(atoi(sec)*v2seconds))%10 + '0'; latitude[8] = seconds; out+=5; longitude[0] = Buffer[out++]; longitude[1] = Buffer[out++]; longitude[2] = degrees; longitude[3] = Buffer[out++]; longitude[4] = Buffer[out++]; longitude[5] = minutes; out++; for (k=0;k<4;k+=1) sec[k] = Buffer[out++]; longitude[6] = ((char)(atoi(sec)*v2seconds))/10 + '0'; longitude[7] = ((char)(atoi(sec)*v2seconds))%10 + '0'; longitude[8] = seconds; out = in; * Function: void send_coordinates(void) * Input: None * Output: None * Overview: Send two messages containing longitude and latitude
17 Internet de les coses aplicat a la millora del servei de Bicing de Barcelona Pàg. 17 void send_coordinates(void) unsigned char c5 = 0; for (k=8;k<17;k+=1) coordinate_message[k] = longitude[c5++]; send_command2(coordinate_message); while (in == out); Delay10KTCYx(10); c5 = 0; for (k=8;k<17;k+=1) coordinate_message[k] = latitude[c5++]; send_command2(coordinate_message); while (in == out); Delay10KTCYx(10); /****** I N T E R R U P T I O N S ***********************************/ // High priority interrupt vector #pragma code InterruptVectorHigh = 0x08 void InterruptVectorHigh(void)
18 Pàg. 18 _asm goto InterruptHandlerHigh //Jump to interrupt routine (ISR) _endasm // // High priority interrupt routine #pragma code #pragma interrupt InterruptHandlerHigh void InterruptHandlerHigh() //Receive interrupt if(pir1bits.rcif) //Receive interrupt flag PIR1bits.RCIF = 0; //Delete receive interrupt flag Buffer[in++] = ReadUSART();//Read the received character //Timer0 overflow interrupt if(intconbits.tmr0if) //Timer0 overflow interrupt flag INTCONbits.TMR0IF = 0; //Delete timer0 overflow interrupt flag WriteTimer0(PRELOAD); LATBbits.LATB1=!LATBbits.LATB1; //Accident alarm code if (pause == 0) //Is the alarm activated? c++; if ((S0 == 0) && (ang < max_angle)) desac = 1; //Deactivate the alarm
19 Internet de les coses aplicat a la millora del servei de Bicing de Barcelona Pàg. 19 c = t_limit_to_desactivate; //Tracking, temperature and bike_out code c2++; if (c2 == 10000) //Each 10s c2=0; c3++; Flags.temperature_flag = 1; //Activate temperature flag if (c3 == 60) //Each 10min c2 = 0; c3 = 0; c4++; Flags.tracking_flag = 1; //Activate tracking flag if (c4>=12) //From 2h SetDCPWM1(Ton); //Fixed duty cycle (50%, 10 bits, 1024/2) if (S1 == 0) //Is button S1 pressed? Flags.broken_flag = 1; //Activate broken flag
20 Pàg. 20 /****** D E F I N I T O N S ************************************************/ #define S0 PORTDbits.RD1//Define RD1 button as S0 #define S1 PORTDbits.RD0//Define RD0 button as S1 #define PRELOAD 240//Preload to fix the interrupt rate #define T 230//Periode of the square wave #define Ton 512//Duty cycle of the square wave #define min_difference 100//Tinimum difference to turn on the alarm #define t_limit_to_desactivate 10000//Time limit to desactivate the alarm (10s) #define ac_module_motionless 4096//Acceleration module resting #define Buffer_max_position 255//Number of positions of the fifo buffer #define pi //Pi value in radians #define max_angle //(pi/3)//pi/3 value in radians #define carriage_return 13//Carriage_return in ASCII #define space 32//Space in ASCII #define degrees 176//Degrees symbol in ASCII #define minutes 39//Minutes symbol in ASCII #define seconds 34//Seconds symbol in ASCII #define v2seconds 0.006//Value to convert to seconds #define t_max 45//Maximum temperature #define t_min -10//Minimum temperature
GPS Reader. Figure 1: RMC NEMA Tag Definition
Douglas Guardino GPS Reader In this project a PIC 18F452 will be used to get one sentence from a GPS and make that sentence available to another PIC. This is done because the GPS puts out a bunch of sentences
More informationC:\Users\cunningh\StaysOnPC\ME430 Downloads & Projects\exam2_problem1\problem1Cunningham.c
C:\Users\cunningh\StaysOnPC\ME430 Downloads & Projects\exam2_problem1\problem1Cunningham.c / FileName: problem1cunningham.c Processor: PIC18F4520 Compiler: MPLAB C18 v.3.06 This file does the following...
More informationCapture Mode of Pic18F252
Capture Mode of Pic18F252 PIC18F253 has two Capture/Compare/Pulse Width Modulation modules. Some devices such as ADCs, Sensors (position, velocity, accelearstion, temperature [MAX6577 converts the ambient
More informationThe MCU s Pulse. Internal clock or oscillator to synchronize operation. One clock cycle = 1 TOSC = 1/fOSC. t TOSC
The MCU s Pulse Internal clock or oscillator to synchronize operation V 0 t TOSC One clock cycle = 1 TOSC = 1/fOSC Clock Cycle The minimum time to perform any operation is one instruction cycle TCY 1 TCY
More informationInterrupts on PIC18F252 Part 2
Interrupts on PIC18F252 Part 2 Following pages list Special Function Registers (SFRs) involved in interrupt configuration and operation on PIC18F252 microcontroller. (Copied from Microchip s PIC18Fxx2
More informationInterrupts. Embedded Systems Interfacing. 08 September 2011
08 September 2011 An iterrupt is an internal or external event that forces a hardware call to a specified function called an interrupt service routine Interrupt enable must be set (initialization) The
More informationLab 6 RS-232 Communication The following routines are provided for devices with a single USART peripheral:
Still More Lab 6 Considerations; Embedded System Power Issues; Project Information Lab 6 RS-232 Communication The following routines are provided for devices with a single USART peripheral: BusyUSART CloseUSART
More informationTopic 10 10/24/2010. C with Embedded Extension
Topic 10 C with Embedded Extension Compiler MCC 18 Microchip PICC 18 Hi-Tech Concerns in embedded C programming Limited memory resources - always use the smallest possible variable necessary Smaller data
More informationELCT 912: Advanced Embedded Systems
ELCT 912: Advanced Embedded Systems Lecture 10: Applications for Programming PIC18 in C Dr. Mohamed Abd El Ghany, Department of Electronics and Electrical Engineering Programming the PIC18 to transfer
More informationUSART Functions. putsusart puts1usart puts2usart putrsusart putrs1usart putrs2usart. ReadUSART Read1USART Read2USART getcusart getc1usart getc2usart
1 of 11 USART Functions TABLE OF CONTENTS 1 Introduction 2 Function Descriptions 2.1 BusyUSART Busy1USART Busy2USART 2.2 CloseUSART Close1USART Close2USART 2.3 DataRdyUSART DataRdy1USART DataRdy2USART
More informationMPLAB C1X Quick Reference Card
MPLAB C1X Quick Reference Card 34 MPLAB C17 Quick Reference MPLAB C17 Command Switches Command Description /?, /h Display help screen /D[=] Define a macro /FO= Set object file name /FE=
More informationHuman Response Timer
Human Response Timer Matthew Beckler beck0778@umn.edu EE2361 Lab Section 007 March 29, 2006 Abstract In this lab, we create a very useful application, a human response timer. The user s reaction time is
More informationInterrupts on PIC18F252 Part 2. Interrupts Programming in C Language
Interrupts on PIC18F252 Part 2 Interrupts Programming in C Language Programming interrupts in C language using XC8 compiler is significantly simplified compared to C18 compiler. This note explains the
More informationECE 354 Introduction to Lab 2. February 23 rd, 2003
ECE 354 Introduction to Lab 2 February 23 rd, 2003 Fun Fact Press release from Microchip: Microchip Technology Inc. announced it provides PICmicro field-programmable microcontrollers and system supervisors
More informationThe modules in this lab room are 4 line by 16 character display modules. The data sheet/users manual for the module is posted on My.Seneca.
LCD Modules A common output display device used with low cost embedded systems is a character LCD display. The displays are available as complete modules with a standard microprocessor parallel interface.
More informationEmbedded Software TI2726 B. 4. Interrupts. Koen Langendoen. Embedded Software Group
Embedded Software 4. Interrupts TI2726 B Koen Langendoen Embedded Software Group What is an Interrupt? Asynchronous signal from hardware Synchronous signal from software Indicates the need for attention
More informationTimer 32. Last updated 8/7/18
Last updated 8/7/18 Basic Timer Function Delay Counter Load a value into a counter register The counter counts Down to zero (count down timer) Up from zero (count up timer) An action is triggered when
More informationThe MICROPROCESSOR PRINCIPLES AND APPLICATIONS Lab 7
The MICROPROCESSOR PRINCIPLES AND APPLICATIONS Lab 7 Timer, USART Cheng-Chien Su 蘇正建 Home Automation, Networking, and Entertainment Lab Dept. of Computer Science and Information Engineering National Cheng
More informationLecture 9 - C Functions
ECET 264 C Programming Language with Applications Lecture 9 C Functions Paul I. Lin Professor of Electrical & Computer Engineering Technology http://www.etcs.ipfw.edu/~lin Lecture 9- Prof. Paul I. Lin
More informationLearn how to communicate
USART 1 Learn how to communicate Programmed I/O (Software Polling) Interrupt Driven I/O Direct Memory Access (DMA) 2 Programmed I/O (Polling) Processor must read and check I/O ready bits for proper value
More informationInterrupts and Serial Communication on the PIC18F8520
Interrupts and Serial Communication on the PIC18F8520 Kyle Persohn COEN 4720 Fall 2011 Marquette University 6 October 2011 Outline 1 Background Serial Communication PIC18 Interrupt System 2 Customizing
More informationUniversal Asynchronous Receiver / Transmitter (UART)
Universal Asynchronous Receiver / Transmitter (UART) MSP432 UART 2 tj MSP432 UART ARM (AMBA Compliant) Asynchronous operation 7/8 bit transmission Master/Slave LSB/MSB first Separate RX/TX registers 4
More informationSingle thread Scheduler All processes called once each sample
Single thread Scheduler All processes called once each sample void main(void) { init_routines(); done = 0; while (!done) { perform_process1(); // Highest priority process perform_process2(); perform_process3();//
More informationECE 354 Computer Systems Lab II. Interrupts, Strings, and Busses
ECE 354 Computer Systems Lab II Interrupts, Strings, and Busses Fun Fact Press release from Microchip: Microchip Technology Inc. announced it provides PICmicro field-programmable microcontrollers and system
More informationUsing Timers of Microchip PIC18F Microcontrollers
Using Timers of Microchip PIC18F Microcontrollers ARSLAB - Autonomous and Robotic Systems Laboratory Dipartimento di Matematica e Informatica - Università di Catania, Italy santoro@dmi.unict.it L.A.P.
More informationINTERRUPTS in microprocessor systems
INTERRUPTS in microprocessor systems Microcontroller Power Supply clock fx (Central Proccesor Unit) CPU Reset Hardware Interrupts system IRQ Internal address bus Internal data bus Internal control bus
More informationPedometer 3 Click. PID: MIKROE 3259 Weight: 24 g
Pedometer 3 Click PID: MIKROE 3259 Weight: 24 g The Pedometer 3 click is a tri-axis acceleration sensing Click board utilizing the KX126-1063. An advanced three-axis acceleration sensor, the KX126-1063
More informationComputer Systems Lecture 9
Computer Systems Lecture 9 CPU Registers in x86 CPU status flags EFLAG: The Flag register holds the CPU status flags The status flags are separate bits in EFLAG where information on important conditions
More informationEEL 4924 Electrical Engineering Design. (Senior Design) FINAL REPORT. 18 April Project Name: Automatic Camber Adjustment System
EEL 4924 Electrical Engineering Design (Senior Design) FINAL REPORT 18 April 2011 Project Name: Team Members: Name: Nick Tseng Name: Michael Liss Project Abstract: The objective of our project was to develop
More informationEmbedded Systems and Software
Embedded Systems and Software Lecture 11 Interrupts Interrupts Slide 1 Interrupts One way to think of interrupts is that they are hardwaregenerated functions calls Internal Hardware When timer rolls over,
More informationSignature: 1. (10 points) Basic Microcontroller Concepts
EE 109 Practice Final Exam Last name: First name: Signature: The practice final is one hour, ten minutes long, closed book, closed notes, calculators allowed. To receive full credit on a question show
More informationBy the end of Class. Outline. Homework 5. C8051F020 Block Diagram (pg 18) Pseudo-code for Lab 1-2 due as part of prelab
By the end of Class Pseudo-code for Lab 1-2 due as part of prelab Homework #5 on website due before next class Outline Introduce Lab 1-2 Counting Timers on C8051 Interrupts Laboratory Worksheet #05 Copy
More informationP.G.TRB - COMPUTER SCIENCE. c) data processing language d) none of the above
P.G.TRB - COMPUTER SCIENCE Total Marks : 50 Time : 30 Minutes 1. C was primarily developed as a a)systems programming language b) general purpose language c) data processing language d) none of the above
More information80C51 Block Diagram. CSE Overview 1
80C51 Block Diagram CSE 477 8051 Overview 1 80C51 Memory CSE 477 8051 Overview 3 8051 Memory The data width is 8 bits Registers are 8 bits Addresses are 8 bits i.e. addresses for only 256 bytes! PC is
More informationTimer0..Timer3. Interrupt Description Input Conditions Enable Flag
Timer0..Timer3 Timers are pretty useful: likewise, Microchip provides four different timers for you to use. Like all interrupts, you have to Enable the interrupt, Set the conditions of the interrupt, and
More informationThe University of Texas at Arlington Lecture 21_Review
The University of Texas at Arlington Lecture 21_Review CSE 5442/3442 Agenda Tuesday December 1st Hand back Homework 7,8 and 9. Go over questions and answers Exam 3 Review Note: There will be a take home
More informationRicardo Rocha. Department of Computer Science Faculty of Sciences University of Porto
Ricardo Rocha Department of Computer Science Faculty of Sciences University of Porto Adapted from the slides Revisões sobre Programação em C, Sérgio Crisóstomo Compilation #include int main()
More informationC Tutorial: Part 1. Dr. Charalampos C. Tsimenidis. Newcastle University School of Electrical and Electronic Engineering.
C Tutorial: Part 1 Dr. Charalampos C. Tsimenidis Newcastle University School of Electrical and Electronic Engineering September 2013 Why C? Small (32 keywords) Stable Existing code base Fast Low-level
More informationPICC. PDF created with pdffactory Pro trial version PIC C C PIC C C PC PC PC PIC C. PIC Microchip PIC
PI 11.1 PI PI P P P PI PI PI Microchip PI PI Hitech S IAR Bytecraft Hitech PI Hitech PI PI-Lite PI16F84 PI16F877 PI16F628 Flash PI PI PI-Lite Hitech-PI IAR S Byteraft PI www.htsoft.com www.iar.com www.ccsinfo.com/picc.shtml
More informationVariables Data types Variable I/O. C introduction. Variables. Variables 1 / 14
C introduction Variables Variables 1 / 14 Contents Variables Data types Variable I/O Variables 2 / 14 Usage Declaration: t y p e i d e n t i f i e r ; Assignment: i d e n t i f i e r = v a l u e ; Definition
More informationCMPE-013/L. Introduction to C Programming
CMPE-013/L Introduction to C Programming Bryant Wenborg Mairs Spring 2014 What we will cover in 13/L Embedded C on a microcontroller Specific issues with microcontrollers Peripheral usage Reading documentation
More informationC Programming Language
C Programming Language Advantages over assembly language for microcontrollers: More portable Math functions Readability Maintainability Editing C End-of-line ignored Use line breaks/tabs/indent for readability
More informationAccurate Time and Interrupts
Accurate Time and Interrupts Matthew Beckler beck0778@umn.edu EE2361 Lab Section 007 March 7, 2006 Abstract In this lab, we create a very accurate digital clock using one of the microcontroller s timers.
More informationUnderstanding the basic building blocks of a microcontroller device in general. Knows the terminologies like embedded and external memory devices,
Understanding the basic building blocks of a microcontroller device in general. Knows the terminologies like embedded and external memory devices, CISC and RISC processors etc. Knows the architecture and
More informationWriting an ANSI C Program Getting Ready to Program A First Program Variables, Expressions, and Assignments Initialization The Use of #define and
Writing an ANSI C Program Getting Ready to Program A First Program Variables, Expressions, and Assignments Initialization The Use of #define and #include The Use of printf() and scanf() The Use of printf()
More information#define CE_PIN 12 //wireless module CE pin #define CSN_PIN 13 //wireless module CSN pin. #define angleaveragenum 1
/***************************************************************************************************** define statements *****************************************************************************************************/
More informationWrite a program that creates in the main function two linked lists of characters and fills them with the following values:
Write a program that creates in the main function two linked lists of characters and fills them with the following values: The first list will have 3 nodes with the following characters: A,B, and C. The
More informationDepartment of Electronics and Instrumentation Engineering Question Bank
www.examquestionpaper.in Department of Electronics and Instrumentation Engineering Question Bank SUBJECT CODE / NAME: ET7102 / MICROCONTROLLER BASED SYSTEM DESIGN BRANCH : M.E. (C&I) YEAR / SEM : I / I
More information8051 Microcontroller
8051 Microcontroller The 8051, Motorola and PIC families are the 3 leading sellers in the microcontroller market. The 8051 microcontroller was originally developed by Intel in the late 1970 s. Today many
More informationC Language Programming, Interrupts and Timer Hardware
C Language Programming, Interrupts and Timer Hardware In this sequence of three labs, you will learn how to write simple C language programs for the MC9S12 microcontroller, and how to use interrupts and
More informationRS232.C An Interrupt driven Asyncronous Serial Port
/***************************************************************************/ /* RS232.C An Interrupt driven Asyncronous Serial Port */ /* Date : 06/03/2002 */ /* Purpose : Asyncronous Transmitter & Receiver
More informationInterrupts, timers and counters
Interrupts, timers and counters Posted on May 10, 2008, by Ibrahim KAMAL, in Micro-controllers, tagged Most microcontrollers come with a set of ADD-ONs called peripherals, to enhance the functioning of
More informationOperating systems for embedded systems
Operating systems for embedded systems Embedded operating systems How do they differ from desktop operating systems? Programming model Process-based Event-based How is concurrency handled? How are resource
More informationAssignment 2 Arrays and Functions
Assignment 2 Arrays and Functions Assigned TA: Yohai Mandabi. Publication date: 17.11.13. Introduction The geographic coordinate system is a grid allowing the specification of any location on Earth. The
More informationa) (5 points) What is the output of the following code sequence? int *ptr = 0x1050; printf ("%x\n", ptr--); printf ("%x\n", ptr);
Problem 1: Short Answers (25 points) a) (5 points) What is the output of the following code sequence? int *ptr = 0x1050; printf ("%x\n", ptr--); printf ("%x\n", ptr); b) (5 points) What are the three basic
More informationMore Fun with Timer Interrupts
More Fun with Timer Interrupts Chords Objective: Play a musical chord each time you press a button: Button RC0 RC1 RC2 Timer Timer0 Timer1 Timer3 RB0 A3 C4 E4 RB1 B3 D4 F4 RB2 C4 E4 G4 Calculations: Assume
More informationME 6405 Introduction to Mechatronics
ME 6405 Introduction to Mechatronics Fall 2006 Instructor: Professor Charles Ume Microchip PIC Manufacturer Information: Company: Website: http://www.microchip.com Reasons for success: Became the hobbyist's
More informationC Language, Token, Keywords, Constant, variable
C Language, Token, Keywords, Constant, variable A language written by Brian Kernighan and Dennis Ritchie. This was to be the language that UNIX was written in to become the first "portable" language. C
More informationFunctions. Systems Programming Concepts
Functions Systems Programming Concepts Functions Simple Function Example Function Prototype and Declaration Math Library Functions Function Definition Header Files Random Number Generator Call by Value
More informationAnalog Output with a Digital to Analog Converter
Analog Output with a Digital to Analog Converter Matthew Beckler beck0778@umn.edu EE2361 Lab 007 April 5, 2006 Abstract Without help, microcontrollers can have great trouble creating analog signals. Approximations
More informationa data type is Types
Pointers Class 2 a data type is Types Types a data type is a set of values a set of operations defined on those values in C++ (and most languages) there are two flavors of types primitive or fundamental
More informationEE Embedded Systems Design. Lessons Exceptions - Resets and Interrupts
EE4800-03 Embedded Systems Design Lessons 7-10 - Exceptions - Resets and Interrupts 1 - Exceptions - Resets and Interrupts Polling vs. Interrupts Exceptions: Resets and Interrupts 68HC12 Exceptions Resets
More informationCS/ECE 5780/6780: Embedded System Design
CS/ECE 5780/6780: Embedded System Design John Regehr Lecture 10: Interrupts in the 6812 General Features of Interrupts All interrupting systems must have the: Ability for the hardware to request action
More informationRecap. ANSI C Reserved Words C++ Multimedia Programming Lecture 2. Erwin M. Bakker Joachim Rijsdam
Multimedia Programming 2004 Lecture 2 Erwin M. Bakker Joachim Rijsdam Recap Learning C++ by example No groups: everybody should experience developing and programming in C++! Assignments will determine
More informationIntermediate Programming, Spring 2017*
600.120 Intermediate Programming, Spring 2017* Misha Kazhdan *Much of the code in these examples is not commented because it would otherwise not fit on the slides. This is bad coding practice in general
More informationBinghamton University. CS-211 Fall Syntax. What the Compiler needs to understand your program
Syntax What the Compiler needs to understand your program 1 Pre-Processing Any line that starts with # is a pre-processor directive Pre-processor consumes that entire line Possibly replacing it with other
More informationCS201- Introduction to Programming Latest Solved Mcqs from Midterm Papers May 07,2011. MIDTERM EXAMINATION Spring 2010
CS201- Introduction to Programming Latest Solved Mcqs from Midterm Papers May 07,2011 Lectures 1-22 Moaaz Siddiq Asad Ali Latest Mcqs MIDTERM EXAMINATION Spring 2010 Question No: 1 ( Marks: 1 ) - Please
More informationSample Examination. Family Name:... Other Names:... Signature:... Student Number:...
Family Name:... Other Names:... Signature:... Student Number:... THE UNIVERSITY OF NEW SOUTH WALES SCHOOL OF COMPUTER SCIENCE AND ENGINEERING Sample Examination COMP1917 Computing 1 EXAM DURATION: 2 HOURS
More informatione-pg Pathshala Subject : Computer Science Paper: Embedded System Module: Interrupt Handling Module No: CS/ES/13 Quadrant 1 e-text
e-pg Pathshala Subject : Computer Science Paper: Embedded System Module: Interrupt Handling Module No: CS/ES/13 Quadrant 1 e-text 1. Interrupt An interrupt is the occurrence of a condition--an event --
More informationC Language Programming, Interrupts and Timer Hardware
C Language Programming, Interrupts and Timer Hardware In this sequence of three labs, you will learn how to write simple C language programs for the MC9S12 microcontroller, and how to use interrupts and
More informationOperating systems for embedded systems. Embedded Operating Systems
Operating systems for embedded systems Embedded operating systems How do they differ from desktop operating systems? Programming model Process-based Event-based How is concurrency handled? How are resource
More information!"#$% &'($) *+!$ 0!'" 0+'&"$.&0-2$ 10.+3&2),&/3+, %&&/3+, C,-"!.&/+"*0.&('1 :2 %*10% *%7)/ 30'&. 0% /4%./
0!'" 0+'&"$ &0-2$ 10 +3&2),&/3+, #include int main() int i, sum, value; sum = 0; printf("enter ten numbers:\n"); for( i = 0; i < 10; i++ ) scanf("%d", &value); sum = sum + value; printf("their
More information/*Algorithm: This code display a centrifuge with five variable speed RPM by increaseing */
/*Algorithm: This code display a centrifuge with five variable speed RPM by increaseing */ /*the speed the cell which are less dense can float and the cell that are denser can sink*/ /*the user has five
More informationSquareWear Programming Reference 1.0 Oct 10, 2012
Content: 1. Overview 2. Basic Data Types 3. Pin Functions 4. main() and initsquarewear() 5. Digital Input/Output 6. Analog Input/PWM Output 7. Timing, Delay, Reset, and Sleep 8. USB Serial Functions 9.
More informationMICROPROCESSOR TECHNOLOGY
MICROPROCESSOR TECHNOLOGY Assis. Prof. Hossam El-Din Moustafa Lecture 14 Ch.6 The 80186, 80188, and 80286 Microprocessors 21-Apr-15 1 Timers The 80186/80188 contain three fully programmable 16-bit timers
More information8051 Microcontroller memory Organization and its Applications
8051 Microcontroller memory Organization and its Applications Memory mapping in 8051 ROM memory map in 8051 family 0000H 4k 0000H 8k 0000H 32k 0FFFH DS5000-32 8051 1FFFH 8752 7FFFH from Atmel Corporation
More informationET156 Introduction to C Programming
ET156 Introduction to C Programming Unit 1 INTRODUCTION TO C PROGRAMMING: THE C COMPILER, VARIABLES, MEMORY, INPUT, AND OUTPUT Instructor : Stan Kong Email : skong@itt tech.edutech.edu Figure 1.3 Components
More informationUNIVERSITY OF CONNECTICUT. ECE 3411 Microprocessor Application Lab: Fall Quiz II
Department of Electrical and Computing Engineering UNIVERSITY OF CONNECTICUT ECE 3411 Microprocessor Application Lab: Fall 2015 Quiz II There are 5 questions in this quiz. There are 9 pages in this quiz
More informationHoltek C and ANSI C Feature Comparison User s Guide
Holtek C and ANSI C Feature Comparison User s Guide July 2009 Copyright 2009 by HOLTEK SEMICONDUCTOR INC. All rights reserved. Printed in Taiwan. No part of this publication may be reproduced, stored in
More informationEmbedded assembly is more useful. Embedded assembly places an assembly function inside a C program and can be used with the ARM Cortex M0 processor.
EE 354 Fall 2015 ARM Lecture 4 Assembly Language, Floating Point, PWM The ARM Cortex M0 processor supports only the thumb2 assembly language instruction set. This instruction set consists of fifty 16-bit
More informationME 4447/ME Microprocessor Control of Manufacturing Systems/ Introduction to Mechatronics. Instructor: Professor Charles Ume
ME 4447/ME 6405 Microprocessor Control of Manufacturing Systems/ Introduction to Mechatronics Instructor: Professor Charles Ume Lecture on Codewarrior Integrated Development Environment Contents Overview
More informationANSI C Programming Simple Programs
ANSI C Programming Simple Programs /* This program computes the distance between two points */ #include #include #include main() { /* Declare and initialize variables */ double
More informationMicro-Controller: PIC16C74 < Part 5: Interrupt >
Micro-Controller: PIC16C74 < Part 5: Interrupt > I. Overview Introduction PIC16c74 can have many sources of interrupt. These sources generally include one interrupt source for each peripheral module, though
More informationNubotics Device Interface DLL
Nubotics Device Interface DLL ver-1.1 Generated by Doxygen 1.5.5 Mon Mar 2 17:01:02 2009 Contents Chapter 1 Module Index 1.1 Modules Here is a list of all modules: Initialization Functions.............................??
More informationArrays. An array is a collection of several elements of the same type. An array variable is declared as array name[size]
(November 10, 2009 2.1 ) Arrays An array is a collection of several elements of the same type. An array variable is declared as type array name[size] I The elements are numbered as 0, 1, 2... size-1 I
More informationProcess Synchronization
Process Synchronization Organized By: Vinay Arora V.A. Disclaimer This is NOT A COPYRIGHT MATERIAL Content has been taken mainly from the following books: Operating Systems Concepts By Silberschatz & Galvin,
More informationI Introduction to Real-time Applications By Prawat Nagvajara
Electrical and Computer Engineering I Introduction to Real-time Applications By Prawat Nagvajara Synopsis This note is an introduction to a series of nine design exercises on design, implementation and
More informationELEG3923 Microprocessor Ch.9 Timer Programming
Department of Electrical Engineering University of Arkansas ELEG3923 Microprocessor Ch.9 Timer Programming Dr. Jingxian Wu wuj@uark.edu OUTLINE 2 Programming 8051 Timers Counter programming Timer programming
More informationAC OB S. Multi-threaded FW framework (OS) for embedded ARM systems Torsten Jaekel, June 2014
AC OB S Multi-threaded FW framework (OS) for embedded ARM systems Torsten Jaekel, June 2014 ACOBS ACtive OBject (operating) System Simplified FW System for Multi-Threading on ARM embedded systems ACOBS
More informationEC 6504 MICROPROCESSOR AND MICROCONTROLLER
DEPARTMENTOFELECTRONICS&COMMUNICATIONENGINEERING EC 6504 MICROPROCESSOR AND MICROCONTROLLER UNIT I THE 8086 MICROPROCESSOR PARTA 1. What is microprocessor? What is the difference between a MP and CPU?
More informationBasic program The following is a basic program in C++; Basic C++ Source Code Compiler Object Code Linker (with libraries) Executable
Basic C++ Overview C++ is a version of the older C programming language. This is a language that is used for a wide variety of applications and which has a mature base of compilers and libraries. C++ is
More informationunsigned char ReadADC() { /************* start A/D, read from an A/D channel *****************/ unsigned char ADC_VALUE;
/*********************************************************************************************/ /* BME 361 Biomeasurement Lab - PIC18F4525BT Demo */ /* Laboratories 1-8: A/D, D/A, LCD display, ECG simulation,
More informationGeneralised User Interface for Embedded Applications using an LCD screen and keypad.
Generalised User Interface for Embedded Applications using an LCD screen and keypad. This article is concerned with firmware design and implementation for microcontroller-based devices incorporating a
More informationEE4390 Microprocessors
EE4390 Microprocessors Lessons 23, 24 - Exceptions - Resets and Interrupts Revised: Aug 1, 2003 1 - Exceptions - Resets and Interrupts Polling vs. Interrupts Exceptions: Resets and Interrupts 68HC12 Exceptions
More informationAccel 5 click. PID: MIKROE 3149 Weight: 24 g
Accel 5 click PID: MIKROE 3149 Weight: 24 g Accel 5 click features an ultra-low power triaxial accelerometer sensor, labeled as the BMA400. This Click board allows linear motion and gravitational force
More informationIE1206 Embedded Electronics Le2
Le1 Le3 Le4 Le6 Le8 IE1206 Embedded Electronics Le2 Ex1 Ex2 Ex4 Ex5 PIC-block Documentation, Seriecom Pulse sensors I, U, R, P, serial and parallell KC1 LAB1 Pulsesensors, Menuprogram Kirchoffs laws Node
More informationCprE 288 Introduction to Embedded Systems Exam 1 Review. 1
CprE 288 Introduction to Embedded Systems Exam 1 Review http://class.ece.iastate.edu/cpre288 1 Overview of Today s Lecture Announcements Exam 1 Review http://class.ece.iastate.edu/cpre288 2 Announcements
More informationThe 8051 microcontroller has two 16-bit timers/counters called T0 and T1.
Counters and Timers: The 8051 microcontroller has two 16-bit timers/counters called T0 and T1. As their names suggest, timer counts internal clock pulse i.e. machine cycle to provide delay. Counter counts
More informationFundamental concept in computation Interrupt execution of a program to handle an event
Interrupts Fundamental concept in computation Interrupt execution of a program to handle an event Don t have to rely on program relinquishing control Can code program without worrying about others Issues
More informationPersonal SE. Functions, Arrays, Strings & Command Line Arguments
Personal SE Functions, Arrays, Strings & Command Line Arguments Functions in C Syntax like Java methods but w/o public, abstract, etc. As in Java, all arguments (well, most arguments) are passed by value.
More information