Vous êtes sur la page 1sur 4

D1

DIODE

Vcc

RL1
5V

B1
Vcc

BR1

R3
delmicro 10k

Q1
2N3904 9V

SW1
SW-SPST

U1 L1
1 10uH 7805 VI
GND

VO

330
330

+12.3
AC Volts

C1
2W005G 100uF

C2
100uF

C3
100uF +5.00
Volts

D2
LED-RED

L2
10uH

BR2 R1
100 2 1

Vcc

U2
6 5

R2
5.6k

4 2W005G OPTOCOUPLER-NPN

almicro

A B C D 40 41 42 43 44 1 2 3 9 10 11 12 13 14 15 16 29 27 4

AVR1
PB0/XCK0/T0/PCINT8 PB1/T1/CLKO/PCINT9 PB2/AIN0/INT2/PCINT10 PB3/AIN1/OC0A/PCINT11 PB4/SS/OC0B/PCINT12 PB5/MOSI/PCINT13 PB6/MISO/PCINT14 PB7/SCK/PCINT15 PD0/RXD0/PCINT24 PD1/TXD0/PCINT25 PD2/INT0/RXD1/PCINT26 PD3/INT1/TXD1/PCINT27 PD4/OC1B/XCK1/PCINT28 PD5/OC1A/PCINT29 PD6/ICP/OC2B/PCINT30 PD7/OC2A/PCINT31 AREF AVCC RESET ATMEGA164P PA0/ADC0/PCINT0 PA1/ADC1/PCINT1 PA2/ADC2/PCINT2 PA3/ADC3/PCINT3 PA4/ADC4/PCINT4 PA5/ADC5/PCINT5 PA6/ADC6/PCINT6 PA7/ADC7/PCINT7 PC0/SCL/PCINT16 PC1/SDA/PCINT17 PC2/TCK/PCINT18 PC3/TMS/PCINT19 PC4/TDO/PCINT20 PC5/TDI/PCINT21 PC6/TOSC1/PCINT22 PC7/TOSC2/PCINT23 XTAL1 XTAL2 37 36 35 34 33 32 31 30 19 20 21 22 23 24 25 26 8 7 delmicro

CONTROL CON MICROPROCESADORES CUASQUER VERONICA


almicro

RESPALDO DE ALIMENTACION
R12
5.6k

C12
0.1uF

SEGUNDO CIRCUITO

3.- Realizar el circuito completo y el programa de control para realizar un control acceso a un bus de la siguiente manera:

El sistema debe contar el nmero de personas que suben o bajan del bus Se debe mostrar todo el tiempo el nmero de pasajeros en el interior del bus y el nmero total de pasajeros trasportados El sistema debe contar el nmero de veces que se ha desconectado la alimentacin primaria, en cuyo caso deber conmutar a alimentacin secundaria. Si el sistema esta alimentado con alimentacin secundaria se debe encender un led amarillo Adicionalmente el sistema debe contar el nmero de veces que ha sido reseteado de manera manual. Al resetear el microcontrolador se debe almacenar el contador de pasajeros transportados en un contador auxiliar (el cual solo puede ser visto desde el pc), y encerar el contador de pasajeros transportados En cualquier momento el Administrador del sistema puede saber el nmero de veces que se ha desconectado la alimentacin primaria, el nmero de veces q ha sido reseteado de forma manual, encerar el contador de resets, revisar el contador auxiliar de pasajeros y cambiar la contrasea utilizando comunicacin serial. Los contadores no se deben borrar si el microcontrolador est sin alimentacin
CDIGO Writeeeprom Contapagon , &H02 apagones Datoeprom = Contapagon End If Mcucsr = 0 'configuro int externas Config Int0 = Rising On Int0 Almicro Enable Int0 Config Int1 = Falling On Int1 Padelante Enable Int1 Config Int2 = Falling On Int2 Patras Enable Int2 On Urxc Llegodato Enable Urxc Enable Interrupts 'SALIDA PARA EL RELE DE LA BATERIA Config Timer1 = Timer , Prescale = 64 Timer1 = 0 ' 'incrementamos contador de

$regfile "m164pdef.dat" $crystal = 8000000 $baud = 9600 $eeprom Config Portc = Output 'para el lcd Ddrb.2 = 0 'PUERTA DE ATRAS Portb.2 = 1 'PUULUP Ddrd.3 = 0 'PUERTA ADELANTE Portd.3 = 1 'ACTIVO PULLUP Config Portd.2 = Input 'PIN PARA INTERRUPCION Config Porta.0 = Output 'CONFIGURO COM SERIAL Config Com2 = 9600 , Synchrone = 0 , Parity = None , Stopbits = 1 , Databits = 8 'CONFIGURACION DEL LCD Config Lcd = 16 * 2 Config Lcdbus = 4 Config Lcdpin = Pin , Db4 = Portc.4 , Db5 = Portc.5 , Db6 = Portc.6 , Db7 = Portc.7 , E = Portc.3 , Rs = Portc.2 Cls Cursor Off 'DECLAROVARIBLES Dim Cont As Integer Dim Contreset As Byte Dim Datoeprom As Eram Byte Dim Contapagon As Byte Dim Aux As Byte Dim Apagon As Integer Dim Ingreso As Byte Dim Subieron As Byte Dim Bajaron As Byte Dim Actuales As Byte Dim Clave As String * 3 Dim Claveact As String * 3 Dim pc As String * 1 'dato recibido RX Dim Dig1 As String * 1 Dim Dig2 As String * 1 Dim Dig3 As String * 1 'contador de resets manuales Aux = Mcucsr Aux = Aux And 3 'analizamos si bandera de external reet esta levantada If Aux = 2 Then Writeeeprom Subieron , &H04 Datoeprom = Subieron Subieron = 0 contreset = datoeprom Readeeprom contreset , &H01 'leemos dato anterior Contreset = Contreset + 1 'incrementamos en 1 Writeeeprom Contreset , &H01 'volvemos a guardar en eeprom Datoeprom = Contreset Contapagon = 0

Principal: Cls Do Enable Interrupts Actuales = Subieron - Bajaron Locate 1 , 1 Lcd "Actual:" ; Actuales ; "personas" Locate 2 , 1 Lcd "Total:" ; Subieron ; "personas" Loop

Almicro: Cont = Timer1 Apagon = Apagon + 1 If Cont > 1035 Then Timer1 = 0 Porta.0 = 0 Else Timer1 = 0 Porta.0 = 1 Apagon = Apagon + 1

'registro de apagones

End If Enable Interrupts Contapagon = Datoeprom Readeeprom Contapagon , &H02 Contapagon = Contapagon + 1 Writeeeprom Contapagon , &H02 Datoeprom = Contapagon Return

'leemos dato anterior 'incrementamos en 1 'volvemos a guardar en eeprom

If Clave = Claveact Then Print "Clave Correcta" Else Print "Clave Incorrecta" End If End If Encerar: Contreset = 0 Writeeeprom Contreset , &H01 comunicacion serial Contapagon = 0 Writeeeprom Contapagon , &H02 Print "Los contadores han sido reseteados" Return

'enceramos contadores por

Padelante: Subieron = Subieron + 1 Return Patras: Bajaron = Bajaron + 1 Return

Llegodato: Pc = Inkey() If Pc = "2" Then Gosub Ingreso If Pc = "3" Then Gosub Apagones If Pc = "4" Then Gosub Verresets If Pc = "5" Then Gosub Encerar If Pc = "6" Then Gosub Ptotales If Pc = "7" Then Gosub Cambioclave If Pc = "8" Then Gosub Enter

Apagones: Contapagon = Datoeprom Readeeprom Contapagon , &H02 'leemos dato anterior de eeprom Print "Total de cortes de energa:" ; Contapagon Return Ptotales: 'leemos dato anterior de eeprom Print "Total de pasajeros transportados:" ; Subieron Return Cambioclave: Print "Ingrese la nueva clave" Dig1 = Waitkey() Clave = Dig1 Dig2 = Waitkey() Clave = Clave + Dig2 'almacenamos nueva clave Dig3 = Waitkey() Clave = Clave + Dig3 Print Clave Writeeeprom Clave , &H3 Print "La clave ha sido cabiada con xito" Return 'almacenamos nueva clave Verresets: contreset = datoeprom Readeeprom Contreset , &H01 Print "# de reseteos manuales:"; Contreset Return

Ingreso: Print "Ingrese contrasea" Ingreso = 1 Return Enter: If Ingreso = 1 Then Dig1 = Waitkey() Clave = Dig1 Dig2 = Waitkey() Clave = Clave + Dig2 Dig3 = Waitkey() Clave = Clave + Dig3 Print Clave Readeeprom Claveact , &H3

'leemos dato anterior de eeprom

Vcc

D1
DIODE

RL1
5V

B1
9V

CONTROL CON MICROPROCESADORES CUASQUER VERONICA


delmicro 10k 2N3904

330
330

SW1 BR1
SW-SPST

D2
LED-YELLOW

U1
7805 VI
GND

L1
1 10uH +12.4
AC Volts

VO

C1
2W005G 100uF

C2
100uF

C3
100uF +5.00
Volts

L2
10uH

P1 BR2 R1
100 2 4 2W005G OPTOCOUPLER-NPN ERROR COMPIM almicro 1 Vcc

U2
6 5

R2
5.6k RX TX

1 6 2 7 3 8 4 9

DCD DSR RXD RTS TXD CTS DTR RI

AVR1
ATRAS 40 41 42 43 44 1 2 3 9 10 11 12 13 14 15 16 29 27 4 PB0/XCK0/T0/PCINT8 PB1/T1/CLKO/PCINT9 PB2/AIN0/INT2/PCINT10 PB3/AIN1/OC0A/PCINT11 PB4/SS/OC0B/PCINT12 PB5/MOSI/PCINT13 PB6/MISO/PCINT14 PB7/SCK/PCINT15 PD0/RXD0/PCINT24 PD1/TXD0/PCINT25 PD2/INT0/RXD1/PCINT26 PD3/INT1/TXD1/PCINT27 PD4/OC1B/XCK1/PCINT28 PD5/OC1A/PCINT29 PD6/ICP/OC2B/PCINT30 PD7/OC2A/PCINT31 AREF AVCC RESET ATMEGA164P PA0/ADC0/PCINT0 PA1/ADC1/PCINT1 PA2/ADC2/PCINT2 PA3/ADC3/PCINT3 PA4/ADC4/PCINT4 PA5/ADC5/PCINT5 PA6/ADC6/PCINT6 PA7/ADC7/PCINT7 PC0/SCL/PCINT16 PC1/SDA/PCINT17 PC2/TCK/PCINT18 PC3/TMS/PCINT19 PC4/TDO/PCINT20 PC5/TDI/PCINT21 PC6/TOSC1/PCINT22 PC7/TOSC2/PCINT23 XTAL1 XTAL2 37 36 35 34 33 32 31 30 19 20 21 22 23 24 25 26 8 7 delmicro

PUERTA DE ADELANTE

LCD1
LM016L

ADELANTE 0.1uF

C129
VSS VDD VEE RS RW E

PUERTA DE ATRAS
B A RS E D4 D5 D6 D7

ATRAS
E

R12
5.6k

C4

10k

C12
0.1uF

REFERENCIAS BIBLIOGRFICAS
http://avrperu.blogspot.com/ Apuntes de Clase Ing. Sotomayor Nelson Manual de ATMEGA164P, pgs.: 27-28

RS

D4 D5 D6 D7

0.1uF

75%

RX TX almicro ADELANTE

RV1

1 2 3

4 5 6

7 8 9 10 11 12 13 14

D0 D1 D2 D3 D4 D5 D6 D7

Vcc

RESPALDO DE ALIMENTACION

R3

Q1

Vous aimerez peut-être aussi