Motor Led RGB Con Atmega328

UNIVERSIDAD NACIONAL DE CHIMBORAZO FACULTAD DE INGENIERÍA ESCUELA DE ELECTRÓNICA Y TELECOMUNICACIONES CATEDRA MICROPROCE

Views 85 Downloads 0 File size 2MB

Report DMCA / Copyright

DOWNLOAD FILE

Recommend stories

Citation preview

UNIVERSIDAD NACIONAL DE CHIMBORAZO FACULTAD DE INGENIERÍA ESCUELA DE ELECTRÓNICA Y TELECOMUNICACIONES CATEDRA MICROPROCESADORES Y LAB. PROYECTO FINAL DE MICROPROCESADORES Héctor Cajilema [email protected] Javier LoLópez [email protected]

Tema: Motor Led RGB, Sensor de Temperatura mediante Atmel Studio 6.2 y Arduino con el Atmega 328. Resumen—En este informe muestra el diseño e implementación del motor led con RGB de la palabra PARADA que será programado mediante el software AVRStudio 6.2, también se realizara un sensor de temperatura mediante Arduino y AVR Studio los tres serán programados con el Atmega 328.

A. OBJETIVO GENERAL



Realizar Un Motor Led, Sensor De Temperatura Mediante Atmel Studio 6.2 Y Arduino Con El Atmega 328.

I. MARCO TEORICO PIC ATmega328P Microcontrolador de 8 bits basados en los procesadores AVR., 23 pines I/O disponibles, memoria de programa flash 32 kB, SRAM 2 kB, EEPROM de datos 1 kB, ADC de 10 bits y 6 canales, 3 timers/comparadores/contadores, 6 canales PWM, programador de modo USART, SPI puerto serial, TWI (I2C compatible), comparador análogo, "watchdog timer" programable con oscilador interno, y cinco modos de ahorro de energía seleccionables por software.

Figure 1_Pic Atmega328

B. OBJETIVOS ESPECIFICOS. 

 



Realizar la respectiva programación mediante el hardware AVR Studio 6.2. Probar la programación en el simulador Proteus. Quemar y comprobar en el pic Atmega328 el correcto funcionamiento de la programación y simulación. Proceder a sacar las respectivas conclusiones.

El dispositivo opera entre 1.8 y 5.5 voltios. Por medio de la ejecución de poderosas

instrucciones en un solo ciclo de reloj, el dispositivo alcanza una respuesta de 1 MIPS, balanceando consumo de energía y velocidad de proceso. Figure 2_Puertos

Registros del CPU Cada registro 4ene asignada una dirección en memoria. Se utilizan las primeras 32 localidades del espacio de memoria para datos. Los registros X, Y y Z se utilizan también como apuntadores de 16 bits. Características eléctricas        

Arquitectura RISC Operación entre 1.8 y 5.5 voltios 131 instrucciones 32 registros de propósito general 1 Kbyte de EEPROM Protección de código programable Cumple directivas RoHS Encapsulado PDIP de 28 pines

Figure 4_lcd

Las siglas LCD significan “Liquid Cristal Display” ó pantalla de cristal líquido. Es una pantalla plana basada en el uso de una sustancia liquida atrapada entre dos placas de vidrio, haciendo pasar por este una corriente eléctrica a una zona específica, para que así esta se vuelva opaca, y además cuenta (generalmente) con iluminación trasera.

Figure 3_Mikroc

LCD

Figure 5_carateristicas_LCD

II. PROCEDIMIENTO a) PROGRAMACION AVR STUDIO 6.2 Programación En Ensamblador Del Motor Led Con La Palabra ‘PARADA’. .include .def Temp1 = r17 .def Temp2 = r18 .def Temp3 = r19 .def data = r20 .def byte = r21 .equ INPUT = 0x00 ; .equ OUTPUT = 0xFF ; .org 0x0000 rjmp RESET ; Reset Handler reti loop_for_ever: rjmp loop_for_ever RESET1: ldi r16, high(RAMEND); Main program start out SPH,r16 ; Set Stack Pointer to top of RAM ldi r16, low(RAMEND) out SPL,r16 sei ; Enable interrupts

;-------------------------------------------------------------delay500ms: ;-*****CALCULADO 8MHZ***************** ; delay loop generator ; 80000 cycles: ; ----------------------------; delaying 7998 cycles: ldi temp1, $1F WGLOOP0: ldi temp2, $55 WGLOOP1: dec temp2 brne WGLOOP1 dec temp1 brne WGLOOP0 ; ----------------------------; delaying 2 cycles: nop nop ; =============================

ret ;--------------------------------------------------------------

RESET: ldi Temp1, low(RAMEND) out SPL, Temp1 ldi Temp1, high(RAMEND) out SPH, Temp1 ldi temp1,0xFF out DDRB,temp1 out DDRC,temp1 out DDRD,temp1 sei ; ****************************************** ** ; Bucle Principal ; ****************************************** ** final: ;P call delay500ms ldi temp1,0b1111110 out portb,temp1

call delay500ms ldi temp1,0b0001001 out portb,temp1 call delay500ms ldi temp1,0b0001001 out portb,temp1 call delay500ms ldi temp1,0b1111110 out portb,temp1 call delay500ms ;R call delay500ms ldi temp1,0b1111110 out portb,temp1 call delay500ms ldi temp1,0b0010001 out portb,temp1 call delay500ms ldi temp1,0b0010001 out portb,temp1 call delay500ms ldi temp1,0b0101001 out portb,temp1 call delay500ms ldi temp1,0b1000110 out portb,temp1 call delay500ms ldi temp1,$00 out portb,temp1 call delay500ms call delay500ms ;A call delay500ms ldi temp1,0b1111110 out portb,temp1 call delay500ms ldi temp1,0b0001001 out portb,temp1 call delay500ms ldi temp1,0b0001001 out portb,temp1 call delay500ms ldi temp1,0b0001001 out portb,temp1 call delay500ms ldi temp1,0b1111110 out portb,temp1 call delay500ms ldi temp1,$00 out portb,temp1 call delay500ms call delay500ms ;D call delay500ms ldi temp1,0b1111111 out portb,temp1 call delay500ms ldi temp1,0b1000001 out portb,temp1 call delay500ms ldi temp1,0b1000001 out portb,temp1 call delay500ms ldi temp1,0b0100010 out portb,temp1 call delay500ms ldi temp1,0b0011100 out portb,temp1

call delay500ms ldi temp1,0b0010001 out portb,temp1 call delay500ms ldi temp1,0b0010001 out portb,temp1 call delay500ms ldi temp1,0b0010001 out portb,temp1 call delay500ms ldi temp1,0b0001110 out portb,temp1 call delay500ms ldi temp1,$00 out portb,temp1 call delay500ms call delay500ms

call delay500ms ldi temp1,$00 out portb,temp1 call delay500ms call delay500ms ;A call delay500ms ldi temp1,0b1111110 out portb,temp1 call delay500ms ldi temp1,0b0001001 out portb,temp1 call delay500ms ldi temp1,0b0001001 out portb,temp1 call delay500ms ldi temp1,0b0001001 out portb,temp1 call delay500ms ldi temp1,0b1111110 out portb,temp1 call delay500ms ldi temp1,$00 out portb,temp1 call delay500ms call delay500ms

;A call delay500ms ldi temp1,0b1111110 out portb,temp1 call delay500ms ldi temp1,0b0001001 out portb,temp1 ldi temp1,$00 out portb,temp1 call delay500ms call delay500ms

Programación En AVR Studio6.2 Mikroc Del Sensor De Temperatura. /* * LCD_4.c * * Created: 31/07/2015 19:46:18 * Author: User */ #define F_CPU 16000000UL

// Reset the LCD controller

lcd_write_4(lcd_FunctionRes et); // first part of reset sequence

#include #include #include // LCD interface (should agree with the diagram above) // make sure that the LCD RW pin is connected to GND #define lcd_D7_port PORTD // lcd D7 connection #define lcd_D7_bit PORTD7 #define lcd_D7_ddr DDRD

lcd_write_4(lcd_FunctionRes et); // second part of reset sequence _delay_us(200); // 100uS delay (min)

lcd_write_4(lcd_FunctionRes et); // third part of reset sequence _delay_us(200); // this delay is omitted in the data sheet

#define lcd_D6_port PORTD D6 connection #define lcd_D6_bit PORTD6 #define lcd_D6_ddr DDRD

// lcd

#define lcd_D5_port PORTD D5 connection #define lcd_D5_bit PORTD5 #define lcd_D5_ddr DDRD

// lcd

lcd_write_4(lcd_FunctionSet4 bit); // set 4-bit mode _delay_us(80); // 40uS delay (min)

#define lcd_D4_port PORTD D4 connection #define lcd_D4_bit PORTD4 #define lcd_D4_ddr DDRD

// lcd

// Function Set instruction

#define lcd_E_port Enable pin #define lcd_E_bit #define lcd_E_ddr

PORTD

// lcd

PORTD1 DDRD

#define lcd_RS_port PORTD Register Select pin #define lcd_RS_bit PORTD0 #define lcd_RS_ddr DDRD // LCD module information #define lcd_LineOne 0x00 of line 1 #define lcd_LineTwo 0x40 of line 2

// lcd

// start // start

lcd_write_instruction_4d(lcd_ FunctionSet4bit); // set mode, lines, and font _delay_us(80); // 40uS delay (min) // lcd_write_instruction_4d(lcd_ DisplayOff); // turn display OFF _delay_us(80); // 40uS delay (min) // Clear Display instruction

lcd_write_instruction_4d(lcd_ Clear); // clear display

// LCD instructions #define lcd_Clear 0b00000001 // replace all characters with ASCII 'space' #define lcd_Home 0b00000010 // return cursor to first position on first line #define lcd_EntryMode 0b00000110 // shift cursor from left to right on read/write #define lcd_DisplayOff 0b00001000 // turn display off #define lcd_DisplayOn 0b00001100 // display on, cursor off, don't blink character #define lcd_FunctionReset 0b00110000 // reset the LCD #define lcd_FunctionSet4bit 0b00101000 // 4-bit data, 2-line display, 5 x 7 font #define lcd_SetCursor 0b10000000 // set cursor position //**************************************** ************************ #include #define PORT_ON(port,pin) port |= (1