You are on page 1of 4

ANEXO N°3

LCD1
LM016L

Y
Z

VDD
VSS

VEE

RW
RS

D0
D1
D2
D3
D4
D5
D6
D7
E
RV1
R2 D10

1
2
3

4
5
6

7
8
9
10
11
12
13
14
R6
RV2

35%
330
1k 330
LED-RED
D5 D7

D4
D5
D6
D7
RS

E
50%
DIODE DIODE 10k
R3
330 U1 D3
D1 D2 40 37 R1
DIODE DIODE
D4 D6 Y
41
PB0/XCK0/T0/PCINT8 PA0/ADC0/PCINT0
36
DIODE DIODE Z PB1/T1/CLKO/PCINT9 PA1/ADC1/PCINT1
42 35 330
PB2/AIN0/INT2/PCINT10 PA2/ADC2/PCINT2 LED-BLUE
43 34
PB3/AIN1/OC0A/PCINT11 PA3/ADC3/PCINT3
44 33
int0 P1 1
PB4/SS/OC0B/PCINT12 PA4/ADC4/PCINT4
32 D9
PB5/MOSI/PCINT13 PA5/ADC5/PCINT5 R4
R. 2
PB6/MISO/PCINT14 PA6/ADC6/PCINT6
31
330 C1 C2 C3 DCD
1 3
PB7/SCK/PCINT15 PA7/ADC7/PCINT7
30 330
1nF 1nF 1nF 6 LED-GREEN
DSR
1

2 9 19
RXD
7 10
PD0/RXD0/PCINT24 PC0/SCL/PCINT16
20
D4 D8
RTS
3 11
PD1/TXD0/PCINT25 PC1/SDA/PCINT17
21
D5 R5
TXD int0 PD2/INT0/RXD1/PCINT26 PC2/TCK/PCINT18 D6
8 12 22 330
CTS PD3/INT1/TXD1/PCINT27 PC3/TMS/PCINT19 D7
4 13 23 LED-RED
DTR PD4/OC1B/XCK1/PCINT28 PC4/TDO/PCINT20 RS
9 14 24
RI PD5/OC1A/PCINT29 PC5/TDI/PCINT21
15 25
2 1 0 16
PD6/ICP/OC2B/PCINT30
PD7/OC2A/PCINT31
PC6/TOSC1/PCINT22
PC7/TOSC2/PCINT23
26
E

Disminuir Aumentar Aceptar ERROR


COMPIM
29
27
AREF XTAL1
8
7
AVCC XTAL2
4
RESET
ATMEGA164P
C4
1nF

Fig.1: Diagrama circuital en Proteus.

Fig.2: HMI implementado para la aplicación solicitada.


Fig.3: Diagrama de bloques de Labview.

LCD1
LM016L
VDD
VSS

VEE

RW
RS

D0
D1
D2
D3
D4
D5
D6
D7
E
1
2
3

4
5
6

7
8
9
10
11
12
13
14

RV2
1k
D4
D5
D6
D7
RS

50%

Fig.4: Funcionamiento del circuito con alarma.

LCD1
LM016L
VDD
VSS

VEE

RW
RS

D0
D1
D2
D3
D4
D5
D6
D7
E
1
2
3

4
5
6

7
8
9
10
11
12
13
14

RV2
1k
D4
D5
D6
D7
RS

50%

Fig.5: Funcionamiento del circuito en temperatura normal y otro rango de histéresis.


ANEXO N°2
Código implementado:
/* if (temperatura<setpoint-
* Prepa4_cm.c 50){
* PORTA=0b10010000;
* Created: 4/12/2017 17:17:11 alarma=1;
* Author : karop }else{
*/ PORTA=0b10000000;
alarma=0;
#define F_CPU 8000000UL }}
#include <avr/interrupt.h>
#include <util/delay.h> if (temperatura>(setpoint+3)){
#include <avr/io.h> led=1;
#include "lcdS.c" PORTA=0b01000000;
//DECLARACIÓN DE FUNCIONES Y VARIABLES lcd_gotoxy(3,0);
void USART_Init( unsigned int baud ); lcd_puts("ENFRIANDO");
void USART_Transmit( unsigned char data );
unsigned char USART_Receive( void ); if
int conversion_ad(uint8_t canal); (temperatura>setpoint+50){
void configurar_interrupcion(); PORTA=0b01010000;
void configurar_micro(); alarma=1;
void med_temperatura(); }else{
uint8_t led; PORTA=0b01000000;
uint8_t datorx; alarma=0;
uint8_t alarma; }}
uint8_t setpoint=25;
uint8_t temperatura; lcd_gotoxy(0,1);
int maximo; lcd_puts("T:");
int minimo; lcd_gotoxy(2,1);
int temp_actual; lcd_write_value(temperatura,3);
int pulsador; lcd_gotoxy(8,1);
int valor_ante; lcd_puts("H:");
int i=0; lcd_gotoxy(10,1);
int ambiente=25; lcd_write_value(ambiente,3);
_delay_ms(150);
int main(void) lcd_clrscr();
{ }}
USART_Init(51);
configurar_interrupcion(); int conversion_ad(uint8_t canal){
configurar_micro(); ADMUX=0B01000000;
lcd_init(LCD_DISP_ON); ADMUX|=canal;
lcd_clrscr(); DIDR0=255;
ADCSRA=0B11000110;
valor_ante=temp_actual; while ((ADCSRA & 0b01000000) ==
while(1) 0b01000000);
{ return ADCW;
med_temperatura(); }
if (temp_actual>=valor_ante+2
|| temp_actual<=valor_ante-2){ void configurar_micro (){
temperatura=temp_actual; DDRA=0b11110000;
valor_ante=temp_actual; DDRB=0;
} PORTB=255;
if (temperatura<=(setpoint+3) DDRD=0b00000010;
&& temperatura>=(setpoint-3)){ }
led=2;
PORTA=0b00100000; void configurar_interrupcion(){
lcd_gotoxy(3,0); EICRA=0b00000010; // flanco de bajada
lcd_puts("T.NORMAL "); EIMSK=0b00000001; // int0
} sei();
if (temperatura<(setpoint-3)){ }
led=0;
PORTA=0b10000000; void med_temperatura(){
lcd_gotoxy(3,0); // Para tener una temperatura máxima de 100°C
lcd_puts("CALENTANDO"); // 100/1023=0.09775171065
temp_actual=conversion_ad(1)*0.0977517
1065;
}

void USART_Init( unsigned int baud )


{
UBRR0H = (unsigned char)(baud>>8);
UBRR0L = (unsigned char)baud;
UCSR0B =
(1<<RXEN0)|(1<<TXEN0)|(1<<RXCIE0);
UCSR0C = (0<<USBS0)|(3<<UCSZ00);
}

void USART_Transmit( unsigned char data )


{
while ( !( UCSR0A & (1<<UDRE0)) );
UDR0 = data;
}

unsigned char USART_Receive( void )


{
while ( !(UCSR0A & (1<<RXC0)) );
return UDR0;
}
//VECTOR DE INTERRUPCIÓN
ISR(USART0_RX_vect){
datorx=USART_Receive();
if(datorx=='A'){
USART_Transmit(led);
USART_Transmit(alarma);
USART_Transmit(setpoint);
USART_Transmit(temperatura);

}}

ISR (INT0_vect){
_delay_ms(15);
pulsador=(PINB & 0b00000011);
if (pulsador==0){
setpoint=ambiente;
}
if (pulsador==1){
ambiente++;
}
if (pulsador==2){
ambiente--;
}}

You might also like