Computer Science Summer term 2012 Final Project Team 2.

Slides:



Advertisements
Similar presentations
1 ECE 372 – Microcontroller Design Parallel IO Ports - Outputs Parallel IO Ports E.g. Port T, Port AD Used to interface with many devices Switches LEDs.
Advertisements

Mark Neil - Microprocessor Course 1 Device Drivers – Digital Voltmeter.
Inputs: Digital and 4 configurable for Digital or 10 bit Analog Outputs:4 - 8 amp Relays or 700ma Transistors (1 PWM) 4 Line by 18 Character fully.
Digital Thermostat and Data Logger Brandon Wagner and David Southwick.
Analog to Digital Conversion
Analog/Digital Subsystem
Analog Comparator Positive input chooses bet. PB2 and Bandgap Reference. Negative input chooses bet. PB3 and the 8 inputs of the A/D. ACME= Analog Comparator.
Robotics Research Laboratory Louisiana State University.
1 Lab2: A/D Converter. 2 This circuit connects a variable voltage to an A/D port on the AVR mcu. Your software running on the AVR mcu will read the digital.
USART and Asynchrono us Communica tion The USART is used for synchronous and asynchronous serial communication. USART = Universal Synchronous/Asynchronous.
7-1 Digital Serial Input/Output Two basic approaches  Synchronous shared common clock signal all devices synchronised with the shared clock signal data.
1 ECE 263 Embedded System Design Lessons 2, 3 68HC12 Hardware Overview, Subsystems, and memory System.
ASPPRATECH.
ECE 371- Unit 11 Introduction to Serial I/O. TWO MAJOR CLASSES OF SERIAL DATA INTERFACES ASYNCHRONOUS SERIAL I/O - USES “FRAMING BITS” (START BIT AND.
Robotics Research Laboratory Louisiana State University.
Engineering 1040: Mechanisms & Electric Circuits Fall 2011 Introduction to Embedded Systems.
Overview What kind of LCD Interfacing the LCD Displaying Text and Numbers Common Issues.
Serial Peripheral Interface (SPI) Bus. SPI Bus There is no official specification for the SPI bus. It is necessary to consult the data sheets of the devices.
Objectives How Microcontroller works
Renesas Electronics Europe GmbH A © 2010 Renesas Electronics Corporation. All rights reserved. RL78 Clock Generator.
Embedded System Design Laboratory October 11, 2002Stanford University - EE281 Lecture #4#1 Lecture #4 Outline Announcements Project Proposal AVR Processor.
Digital to Analogue Converter
ELE2MIC Lecture 21 The AVR Sleep Modes ATMEGA128’s Analog to Digital Converter –Features –Block Diagram –Clock Source –Input Sources –Interrupts –BandGap.
Lecture 20: Communications Lecturers: Professor John Devlin Mr Robert Ross.
Page 1 D&C EBV Seminar June 2003 Motor Demo C868 Chevillot/Jansen June 2003 N e v e r s t o p t h i n k i n g. Infineon C868 Hands On Training CAPCOM6.
1 Lab 1: Introduction. 2 Configure ATMEL AVR Starter Kit 500 (STK500), a prototyping/development board for Lab1. ATmega16 ( V) is the chip used.
Robotics Research Laboratory Louisiana State University.
Robotics Research Laboratory Louisiana State University.
Advanced uC Session Speaker : Chiraag Juvekar Jan 13, 2011 Speaker : Chiraag Juvekar Jan 13, 2011.
Computer Science SS2013 Team 5 Final Presentation 26 June © FH AACHEN | FACHBEREICH 08 | Computer Science, SS2013.
Atmel Atmega128 Overview ALU Particulars RISC Architecture 133, Mostly single cycle instructions 2 Address instructions (opcode, Rs, Rd, offset) 32x8 Register.
ATMEL AVR 8 bit RISC MICROCONTROLLERS a general comparison.
ATtiny23131 A SEMINAR ON AVR MICROCONTROLLER ATtiny2313.
Suleyman Demirel University CSS340 Microprocessor Systems – Lecture 2 ATMEGA328P ARCHITECTURE ANALOG INPUTS.
Robotics Research Laboratory Louisiana State University.
Analog to Digital Converter (ADC). Analog to Digital Converters  Microcontroller understands only digital language.  To convert the analog output from.
July 18, UCSD - R.A. de Callafon Short Intro to Micro Processors and I/O functions of our Kinetic Sculpture Control Box Raymond de Callafon.
CSCI1600: Embedded and Real Time Software Lecture 16: Advanced Programming with I/O Steven Reiss, Fall 2015.
SOFTWARE NARRATIVE PRESENTED BY: JUSTIN LINDLEY Team # 15: Acoustic Storm Interweaving the impressive visual power of electricity and the visceral emotion.
Analog to Digital Converter (ADC)
Analog to Digital Conversion - ADC Mark Neil - Microprocessor Course 1 Device Drivers – Measuring Voltages.
Team 6. Guitar Audio Amplifier Audio Codec DSP Wireless Adapter Motor Array PC LCD Display LED Arrays Pushbutton or RPG Input Device
NAM S.B MDLAB. Electronic Engineering, Kangwon National University 1.
Atmega328p Introduction for Digital and PWM Output Brion L Fuller II Robotics Club.
Sensing Algorithm using IR Sensor and ADC Soong-sil University. Robotics 기 정 두 원.
1 Lab 4: D/A Converter Lab 4: D/A Converter This is a simple resistive network for a D/A converter Port 1, Port 0 are digital inputs ==> 00 (minimum),
1. PIC ADC  PIC18F877 has 8 analog input channels i.e. port A pins(RA0 to RA5) and port E pins(RE1 and RE2). These pins are used as Analog input pins.
1 4-Integrating Peripherals in Embedded Systems. 2 Introduction Single-purpose processors  Performs specific computation task  Custom single-purpose.
USING TV REMOTE AS A CORDLESS MOUSE FOR THE COMPUTER
CORDLESS MOUSE FEATURES BY TV REMOTE USING PIC MICROCONTROLLER
Application Case Study Christmas Lights Controller
Servos Elementary Robotics with Servos
Embedded Systems Programming
Application Case Study Security Camera Controller
Analog Comparator An analog comparator is available on pins PE2(AIN0), PE3(AIN1) The comparator operates like any other comparator. -when (+) exceeds (-)
ADC,DAC and sensor interface
Programming Microcontroller
The Arduino Microcontroller: Atmel AVR Atmega 328
Introduction to Microprocessors and Microcontrollers
CENG2400 Revision Q1a A system has an ARM processor with a 32-bit General Purpose Input Output (GPIO) module. Two on/off switches are connected to bit-3.
Introduction to the Atmel AVR Butterfly
Serial Communication Interface: Using 8251
Lecturer: Reza Arjmandi Autumn 2015
ADC and DAC Programming in AVR
AVR – ATmega103(ATMEL) Architecture & Summary
8051 Micro Controller.
Device Drivers – Digital Voltmeter
Introduction to Arduino
Presentation transcript:

Computer Science Summer term 2012 Final Project Team 2

Project Manager (Salvador Reyes) Technical Managed David TecuanhuehueAmri Mohamed Quality Managed Cecilia Cruz Documentation Managed Spandan ShroffAmin Mitul Integration Managed Edgar EscobarRodrigo Gutierrez Team organization

Write an ACUAS μCEasy package for the AVR Butterfly board. The following macros must be available  PROGRAM_INIT  PROGRAM_START  PROGRAM_END  VARIABLE  STRING  WAIT_SEC  ACTIVATE_ADC  BRIGHTNESS  TEMPERATURE  VOLTAGE  BEEP  ACTIVATE_LCD  INIT_UART  DATAFLASH Request

ATMEL AVR Butterfly ATmega169 Low power design Peripherals: ● 120 segment LCD ● 4 Mbit external DataFlash ● Programming Methods: Bootloader, SPI, Parallel, JTAG ● Joystick, 4 directions ● Piezo speaker ● Hz oscillator for real time clock ● RS232 level converter for PC ● Temperature sensor ● Light sensor ● 3V, 600 mA button cell battery ● Request

A macro is a fragment of code which has been given a name. Whenever the name is used, it is replaced by the contents of the macro. There are two kinds of macros. Object-like It looks like a data object in code that uses it function-like Resemble function calls Software development

#define #define PROGRAM_INIT() ( )parentheses immediately after the macro name Macro Arguments To define a macro that uses arguments, to insert parameters between the pair of parentheses in the macro definition is necessary. The parameters must be valid C identifiers, separated by commas and optionally whitespace. Software development

JOYSTICK PORT/PIN CONFIGURATION UpPB6 DownPB7 RightPE3 LeftPE2 Joystick port/pin configuration

Pin configuration from the pin diagram were observed. ///Execute the following instruction if the joystick up button is pressed #define ON_JOYSTICK_UP if(!(PINB & (1 << 6))) ///Execute the following instruction if the joystick up button is not pressed #define OFF_JOYSTICK_UP if(PINB & (1 << 6)) ///Wait until the joystick up button is pressed #define WAIT_FOR_JOYSTICK_UP while(PINB & (1 << 6)); ///Wait until the joystick up button is released #define WAIT_FOR_RELEASE_JOYSTICK_UP while(!(PINB & (1 << 6))); Joystick Macros

#include "projectdefinitions.h" PROGRAM_INIT PROGRAM_START ON_JOYSTICK_UP PORTA = PORTA | 0b ; OFF_JOYSTICK_UP PORTA = PORTA & 0b ; ON_JOYSTICK_DOWN PORTA = PORTA | 0b ; OFF_JOYSTICK_DOWN PORTA = PORTA & 0b ; ON_JOYSTICK_RIGHT PORTA = PORTA | 0b ; OFF_JOYSTICK_RIGHT PORTA = PORTA & 0b ; ON_JOYSTICK_LEFT PORTA = PORTA | 0b ; OFF_JOYSTICK_LEFT PORTA = PORTA & 0b ; ON_JOYSTICK_CENTER PORTA = PORTA | 0b ; OFF_JOYSTICK_CENTER PORTA = PORTA & 0b ; PROGRAM_END Example:

// The volume must be between a value of 0 to 100, this macro must be used to allow the sound be heard #define BEEP_VOLUME(v) {OCR1AH = 0; OCR1AL = v;} OCR1A is a 16 bit register. In order to modify the value of the volume of the speaker the value of this register must be modified. This register controls the PWM pulse width. Thereby it controls the power of the signal (volume). Buzzer Macros

//The tone is a vale between 20 and in Hz (the “audible” frequencies), duration in seconds in values between 0.1 and 25 #define BEEP(tone,duration) {InitBuzzer(tone,duration);} BEEP macro calls InitBuzzer function. Buzzer Macros

void InitBuzzer(int f, int d) { int icr1; icr1 = /(2*f); ICR1 = icr1; // Top value of the Timer1 TCCR1A = (1<<COM1A1);// Set OC1A when upcounting, clear when downcounting TCCR1B = (1<<WGM13); // Phase/Freq-correct PWM, top value = ICR1 SET_BIT(TCCR1B, CS10)// Start Timer1, prescaler=1 WAIT_SEC(d)// Waits d seconds CLEAR_BIT(TCCR1B, CS10)// Stop Timer1 } Buzzer Macros

ACTIVATE_ADC ADCSRA = (1<<ADEN); ADMUX |= (0<<REFS1) | (1<<REFS0); autoADCps(); Set ADEN bit to activate AD Converter. Reference voltage AVCC = 5V Function that sets the ADC prescaler value depending from clock frequency. ADC Macros To switch on the AD converter This instruction has to be executed only one time (in the PROGRAM_INIT part).

ADC_CHANNEL(ch) ADMUX &= 0b ; ADMUX |= (ch-1); PORTF &= ~(1 << (ch-1)); initialize channel bits (0-3) Clear PORTF selected channel bit -->switch off pull up resistor “ch-1” set channel “ch”. ADC Macros To chose for analogue input (from 1 to 8) ADC_CHANNEL(1) // pin 0 of port A is chosen for analogue input

ADCONVERT(x) ADCSRA |= (1<<ADSC); loop_until_bit_is_clear(ADCSRA,ADSC); ADCSRA |= (1<<ADSC); loop_until_bit_is_clear(ADCSRA,ADSC); x=ADCW; start a single conversion Wait for completion of ADC x acquires the value of the AD conversion ADC Macros The result is of 10 bit resolution and will be stored in the 16 bit variable. This variable has to be previously declared The actual conversion is started

ADCONVERTlow(x) ADCSRA |= (1<<ADSC); loop_until_bit_is_clear(ADCSRA,ADSC); ADCSRA |= (1<<ADSC); loop_until_bit_is_clear(ADCSRA,ADSC); x=ADCW >> 2; ADC Macros start a single conversion Wait for completion of ADC Shifting bit to show only 8 bits value The actual conversion is started The 8 most significant bits of the 10 bit result will be stored in the 8 bit variable.

ADCONVERT_MV(x) ADCSRA |= (1<<ADSC); loop_until_bit_is_clear(ADCSRA,ADSC) ; x=ADCW*5./1.024; start a single conversion Wait for completion of ADC Shifting bit to show only 8 bits value ADC Macros The actual conversion is started Performs a 10 bit AD conversion and store the result in mV in an integer or float variable x.

Example: #include “easybutterfly.h“ // library for Buterfly PROGRAM_INIT VAR16(mvolt) // Declares a 16 bit unsigned variable ACTIVATE_ADC// To switch on the AD converter ADC_CHANNEL(1)// Select pin 0 of the ADC multiplexer PROGRAM_START ADCONVERT_MV(mvolt)//The AD conversion is executed and store in //the variable “mvolt” PROGRAM_END ADC Macros

// Perform a 10 bit AD conversion from the value of the brightness sensor and store the value in a 8 bit variable #define BRIGHTNESS(x) {ACTIVATE_ADC ADC_CHANNEL(3) ADCONVERTlow(x)} The BRIGHTNESS macro uses the macros of the ADC previously defined, the output of the brightness sensor is input in the PORTF2, the result of the conversion is a 8 bits value. Brightness

// Perform a 10 bit AD conversion from the value of the V_in pin and store the result in volts in an integer (or double or float) variable #define VOLTAGE(x) {ACTIVATE_ADC ADC_CHANNEL(2) ADCSRA |= (1<<ADSC); loop_until_bit_is_clear(ADCSRA,ADSC); ADCSRA |= (1<<ADSC); loop_until_bit_is_clear(ADCSRA,ADSC); x=ADCW*5.0/1023.0;} The VOLTAGE macro uses some macros of the ADC previously defined, the input for the V_in pin is the PORTF1, the result of the conversion is a float value that can be stored in an integer (or double or float) variable. Voltage Measurement

#define TEMPERATURE(x) {ACTIVATE_ADC ADC_CHANNEL(1) ADCSRA |= (1<<ADSC); loop_until_bit_is_clear(ADCSRA,ADSC); ADCSRA |= (1<<ADSC); loop_until_bit_is_clear(ADCSRA,ADSC); int adc=ADCW; float t=adc/(1024-adc); float r=log(t); x=4250/(r )-273;} The TEMPERATURE macro uses some macros of the ADC previously defined, the output of the temperature sensor is input in the PORTF0, the result of the conversion is a float value that can be stored in an integer (or double or float) variable. Temperature Measurement

LCD Macros #define ACTIVATE_LCD LCD_Init (); //Macro to initialize the LCD #define CLEAR_LCD LCD_Clear(); //Macro to clear the LCD #define LCD_CHAR(character) LCD_putc(character); //Macro to write a character on the LCD #define LCD_TEXT(pStr) LCD_puts(pStr); //Macro to write a string on the LCD #define LCD_NUMBER(v) {itoa(v,lcd_str,10); LCD_puts(lcd_str);}; //Macro to write a number on the LCD #define LCD_D_NUMBER(v,w,p) {dtostrf((v),w,p,lcd_str); LCD_puts(lcd_str);}; //Macro to write a float on the LCD

LCD Macros Key Variables char gTextBuffer[TEXTBUFFER_SIZE]; // Buffer that contains the text to be displayed char gScroll; // Only six letters can be shown on the LCD. unsigned int LCD_character_table[] PROGMEM = { 0x0A51, // '*' (?) 0x2A80, // '+' 0x0000, // ',' (Not defined) 0x0A00, // '-' 0x4000, // '.' Degree sign

LCD Macros LCD Segments Connections on the STK502 The LCD glass has in total 120 segments

LCD Macros LCD digit segment mapping into the LCD Data Registers

#include "projectdefinitions.h" PROGRAM_INIT ACTIVATE_LCD // initialize the LCD. The output begins at the first position of the display. CLEAR_LCD// Clears the LCD screen. PROGRAM_START LCD_TEXT("HALLO WIE GEHTS") WAIT_SEC(25) CLEAR_LCD// Clears the LCD screen. LCD_CHAR (‘G') WAIT_SEC(10) CLEAR_LCD// Clears the LCD screen. LCD_D_NUMBER(11.31,1,2) WAIT_SEC(5) CLEAR_LCD// Clears the LCD screen. PROGRAM_END Example LCD Macro :

UART:

UART is Available on pin header J406 With level converters Connections : Just connect TxD, RxD and GND with Vcc min 2.0V

uart.c File Reference : Uart Macros: UART_TEX T UART_TEXT_CO NST UART_NUMBER UART_CHAR UART_CRL F UART_READ_CHA R UART_READ_LI NE

#define INIT_UART {uart_init( UART_BAUD_SELECT(UART_BAUD_RATE,F_CPU) ); sei();} Initialises the UART. Must be invoked in the PROGRAM_INIT part. Sets frame format: asynchronous, 8 data bits, no parity, 1 stop bit #define UART_TEXT(string) uart_puts((char*) string); Sends a string which is located in SRAM over UART #define UART_TEXT_CONST(string) uart_puts_p(string); Sends a string which is located in flash ROM over UART. The string must be declared as: static const char PText[] PROGMEM = "text" Macros definition:

#define UART_NUMBER (x) {itoa( x, (char*)uart_str, 10); uart_puts((char*)uart_str);} Used to ”Sends a number over UART“ #define UART_CHAR(c) uart_putc(c); Used to ”Sends one character over UART“ #define UART_CRLF uart_putc(13) ; uart_putc(10) ; Used to ”Sends a linefeed over UART“ #define UART_READ_CHAR(c) c = uart_getc(); Used to ”Reads one character from UART“ #define UART_READ_LINE(c_array,max_char) uart_read_line((c_array), (max_char), 3) Used to ”Reads a Line from UART“

DataFlash is a low pin-count serial interface for flash memory compatible with the SPI standard. The DataFlash only supports the most commonly used SPI modes, 0 and 3. Dataflash Memory

INIT_DF Initialize the communication with the dataflash via SPI END_DF Disable the communication with the dataflash Dataflash Macros

WRITE_BYTE_BUFFER(IntPageAdr, Data) Writes a byte in the buffer WRITE_STR_BUFFER(IntPageAdr, NB, string) Writes a string in the buffer BUFFER_TO_DF(PageAdr) Sends the buffer information in to a page address of the dataflash Dataflash Macro for writing

DF_TO_BUFFER(PageAdr) Reads the data in a page address of the buffer and sends the information to the buffer. READ_STR_BUFFER(IntPageAdr, NB, string) Reads a string in the internal address of the buffer to save it into an array READ_BYTE_BUFFER(IntPageAdr) Reads a byte from the buffer Dataflash Macro for reading

#include "projectdefinitions.h" #include int main(void) { INIT_DF unsigned char Word[4]; Word[0]= ‘T'; Word[1]= 'e'; Word[2]= ‘a'; Word[3]= ‘m'; WRITE_STR_BUFFER(1,8,Word) _delay_ms(100); BUFFER_TO_DF(1) END_DF Example Dataflash Macro : unsigned char FRIEND[8] = {0}; while(1) { ACTIVATE_LCD CLEAR_LCD INIT_DF DF_TO_BUFFER(2) READ_STR_BUFFER(1, 8, FRIEND) LCD_TEXT(FRIEND) _delay_ms(2000); END_DF } }

Good Can be improved Team work experience