anexos - Biblioteca UNET
Transcripción
anexos - Biblioteca UNET
ϴϲ ANEXOS ϴϳ Anexo A. Especificaciones del sensor ultrasónico PING))) ϴϴ ϴϵ ϵϬ ϵϭ ϵϮ Anexo B. Especificaciones del display LCD 20x4 ϵϯ ATM2004D SERIES --------------------- STANDARD CHARACTER LCD MODULES * 5 x 8 with Cursor Dots * Transflective * View Angle (6:00) * STN (Yellow green) * 1/16 Duty, 1/5 Bias, 20CHAR x 4LINE * Controller/Driver (S6A0069 ) * LED Backlight (Yellow green) * Operating Temp (-20~70) ϵϰ Mechanical Specifications Item Item Description(mm) Size Electrical Specifications Supply 98(L)x60(W)x14(H) Voltage for Symbo Mi Ty Ma Uni l n p x t VDD 4.5 5.0 5.5 V 4.0 4.5 5.0 V 1.0 2.0 mA 80 mA Logic V.A 76(L)x25.2(W) Supply Voltage for VLCD LCD Character 3.55 x 5.35 Supply Current for IDD Pitch Dot Size Logic 0.55*0.55 Supply Current for IF LED Interface Signals---- J1 Pi Symbol Lev n 1 2 Description Pin Symbol el VSS VDD 0V Le vel Ground +5V Supply Voltage 7~1 DB0~D H/ 4 B7 L A -- for 15 Logic 3 V0 -- Operating Voltage for 16 LCD 4 R/S H/L H: Data L: Instruction Code 5 R/W H/L H: Data Read L: Data Write 6 E H,H -L Description Enable Signal Data Bus Line Back Light anode:+4.2V K -- Back cathode:0V Light ϵϱ Anexo C. Datasheet del circuito DS1307 ϵϲ ϵϳ ϵϴ ϵϵ Anexo D. Datasheet del emisor TLP434A ϭϬϬ ϭϬϭ Anexo E. Datasheet del receptor RLP434A ϭϬϮ ϭϬϯ Anexo F. Datasheet del amplificador TL084 ϭϬϰ ϭϬϱ ϭϬϲ ϭϬϳ Anexo G. Programa del microcontrolador codificado con el compilador C de CCS. ϭϬϴ #include<18F4550.h> #device adc=10 #include<string.h> #include<math.h> // para cristal de 4 Mhz #fuses XTPLL,MCLR,NOWDT,NOPROTECT,NOLVP,NODEBUG,USBDIV,PLL1,CPUDIV1,NOVREGEN #use delay(clock=48000000) /********************* Definiciones para la configuración USB ************/ #define USB_EP1_TX_SIZE 128 //Buffer de salida #define USB_EP1_RX_SIZE 128//Buffer de entrada #define USB_CON_SENSE_PIN PIN_D0 //Control del USB /******************** LIBRERIAS *****************************/ #include <pic18_usb.h> // Microchip PIC18Fxx5x Hardware layer for CCS's PIC USB driver #include "header.h" // Configuración del USB y los descriptores para este dispositivo #include <usb.c> // handles usb setup tokens and get descriptor reports #include"lcd4x20.h" #include"_ds1307.c" #define protocolo recbuf[0] #define COMMAND_FIRMWARE 99 #define COMMAND_EEPROM 60 //#device ADC=10 //CADs con una resolución de 10-bits para la conversion analogico/digital /************************ VARIABLES GLOBALES *************************/ signed int vel; int modo; // 0 apagado, 1 1ra velocidad, 2 2da velocidad // 1 si es automatico, 0 si es manual signed int hora,minuto; // tiempo de activacion de luces internas signed int hora2,minuto2; // tiempo de apagado de luces internas long set_LDR; // setpoint de fotoresistencia en formato (0-1024) int ind_pwm; // intensidad de brillo por modulacion de ancho de pulso int inc; // setpoint de distancia critica //int aux_in=0; int band=0; int VarMenu=2,i,j; char evento='w'; int sim[18]; int USB=0; int limite; char mensaje[19]; long dist; long v_bat; //long v_LDR; ϭϬϵ //float div; long v_ll,v_lluvia; //int intensidad[5]={0,40,80,120,160}; char operacion[2][10]={ {"manual"}, {"auto"} }; char speed[3][19]={ {"off "}, {"lento "}, {"rapido"} }; //********************* VARIABLES PARA EL USB *******************/ /* #define RecCommand recbuf[0] #define COMMAND_FIRMWARE 99 #define COMMAND_EEPROM 60 const int8 Lenbuf = 128; int recbuf[Lenbuf],enviar[Lenbuf]; int i; int pos,pos2,pos3; */ /******************************************************************/ #include"mes_lcd.c" void iniciar(); void main() { enable_interrupts(GLOBAL); enable_interrupts(INT_EXT); // interrupcion cuando exista señal de retroceso ext_int_edge(L_to_H); setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1); set_timer0(46005); setup_timer_1(T1_DISABLED); setup_timer_2(T2_DIV_BY_1,255,1); enable_interrupts(INT_TIMER0); setup_comparator(NC_NC_NC_NC); setup_vref(FALSE); setup_adc_ports(AN0_TO_AN1); set_adc_channel(10); // activacion por flanco de subida ϭϭϬ setup_adc(ADC_CLOCK_INTERNAL); ds1307_set_date_time(20,5,11,6,10,33,0);// dia, mes, año, numero del dia, hora, minuto, segundo iniciar(); while(true){ check_usb(); ver_tiempo(); ver_sensores(); anti_pulsadores(&evento); if(evento=='e'){ VarMenu=2; do{ limite=7; vDibujaMenu(VarMenu); anti_pulsadores(&evento); metodos(VarMenu,evento); }while(evento!='z'); lcd_clear(); } } } void iniciar(){ init_ds1307(); // iniciamos el reloj atomico lcd_init(); lcd_putc('\f'); set_tris_c(0b11110001); output_low(PIN_C1); output_low(PIN_C2); simbolos(); bienvenida(); bienvenida2(); strcpy(mensaje,"cargando"); barra(); load_set_point(); dist=inc*10; if(modo){ output_high(PIN_B7); }else{ output_low(PIN_B7); } } ϭϭϭ char men[7][19]={ {"**PRINCIPAL**"}, {"1. Est.de bateria"}, {"2. Configurar"}, {"3. Ver imf."}, {"4. Salvar setpoint"} {"5. interfaz USB"}, {"6. prueba reles"} }; char submenu1[5][19]={ {"**CONFIGURAR**"}, {" modo:"}, {" wiper:"}, {" luces"}, {" distancia:"} }; char luz[3][19]={ {"**Ajustar Luces**"}, {" hora on"}, //{" brillo"} ---> por lo que son lamparas fluorescentes {" hora off"} }; char tiempo[3][19]={ {"**Tiempo"}, {" Hora :"}, {" Minutos:"} }; char reles[6][19]={ {"****Reles*****"}, {"exploradora"}, {"primera"}, {"segunda"}, {"M/A"}, {"lamparas"} }; void vDibujaMenu(int VarMen){ ϭϭϮ lcd_clear(); lcd_gotoxy(4,1);printf(lcd_putc,"%s",men[0]); if(VarMen>4){ VarMen=VarMen-3; lcd_gotoxy(1,VarMen);lcd_send_byte(1,3); lcd_gotoxy(2,2);printf(lcd_putc,"%s",men[4]); lcd_gotoxy(2,3);printf(lcd_putc,"%s",men[5]); lcd_gotoxy(2,4);printf(lcd_putc,"%s",men[6]); lcd_gotoxy(20,1);lcd_send_byte(1,1); //flecha subiendo }else{ lcd_gotoxy(1,VarMen);lcd_send_byte(1,3); lcd_gotoxy(3,2);printf(lcd_putc,"%s",men[1]); lcd_gotoxy(3,3);printf(lcd_putc,"%s",men[2]); lcd_gotoxy(3,4);printf(lcd_putc,"%s",men[3]); lcd_gotoxy(20,4);lcd_send_byte(1,0); //flecha bajando } delay_ms(100); } void submenu(int VarMen){ lcd_clear(); lcd_gotoxy(4,1);printf(lcd_putc,"%s",submenu1[0]); if(VarMen>4){ VarMen=VarMen-3; lcd_gotoxy(1,VarMen);lcd_send_byte(1,3); lcd_gotoxy(2,2);printf(lcd_putc,"%s %4ldcm",submenu1[4],dist); lcd_gotoxy(20,1);lcd_send_byte(1,1); //flecha subiendo }else{ lcd_gotoxy(1,VarMen);lcd_send_byte(1,3); lcd_gotoxy(2,2);printf(lcd_putc,"%s %s",submenu1[1],operacion[modo]); lcd_gotoxy(2,3);printf(lcd_putc,"%s %s",submenu1[2],speed[vel]); lcd_gotoxy(2,4);printf(lcd_putc,"%s",submenu1[3]); lcd_gotoxy(20,4);lcd_send_byte(1,0); //flecha bajando } delay_ms(100); } void submenu2(int VarMen){ lcd_clear(); lcd_gotoxy(4,1);printf(lcd_putc,"%s",luz[0]); lcd_gotoxy(1,VarMen);lcd_send_byte(1,3); lcd_gotoxy(2,2);printf(lcd_putc,"%s",luz[1]); ϭϭϯ lcd_gotoxy(2,3);printf(lcd_putc,"%s",luz[2]); delay_ms(100); } void submenu3(int VarMen){ lcd_clear(); lcd_gotoxy(3,1);printf(lcd_putc,"%s on**",tiempo[0]); lcd_gotoxy(1,VarMen);lcd_send_byte(1,3); lcd_gotoxy(2,2);printf(lcd_putc,"%s %d",tiempo[1],hora); lcd_gotoxy(2,3);printf(lcd_putc,"%s %d",tiempo[2],minuto); if(hora<13){ lcd_gotoxy(8,4);printf(lcd_putc,"%d:%02u am",hora,minuto); }else{ lcd_gotoxy(8,4);printf(lcd_putc,"%d:%02u pm",hora-12,minuto); } delay_ms(100); } void submenu5(int VarMen){ lcd_clear(); lcd_gotoxy(3,1);printf(lcd_putc,"%s off**",tiempo[0]); lcd_gotoxy(1,VarMen);lcd_send_byte(1,3); lcd_gotoxy(2,2);printf(lcd_putc,"%s %d",tiempo[1],hora2); lcd_gotoxy(2,3);printf(lcd_putc,"%s %d",tiempo[2],minuto2); if(hora<13){ lcd_gotoxy(8,4);printf(lcd_putc,"%d:%02u am",hora2,minuto2); }else{ lcd_gotoxy(8,4);printf(lcd_putc,"%d:%02u pm",hora2-12,minuto2); } delay_ms(100); } void submenu4(int VarMen){ lcd_clear(); lcd_gotoxy(4,1);printf(lcd_putc,"%s",reles[0]); if(VarMen>4){ VarMen=VarMen-3; lcd_gotoxy(1,VarMen);lcd_send_byte(1,3); lcd_gotoxy(3,2);printf(lcd_putc,"%s",reles[4]); lcd_gotoxy(3,3);printf(lcd_putc,"%s",reles[5]); lcd_gotoxy(20,1);lcd_send_byte(1,1); //flecha subiendo }else{ lcd_gotoxy(1,VarMen);lcd_send_byte(1,3); lcd_gotoxy(3,2);printf(lcd_putc,"%s",reles[1]); lcd_gotoxy(3,3);printf(lcd_putc,"%s",reles[2]); ϭϭϰ lcd_gotoxy(3,4);printf(lcd_putc,"%s",reles[3]); lcd_gotoxy(20,4);lcd_send_byte(1,0); //flecha bajando } delay_ms(100); } void simbolos(){ // creacion de caracteres personalizados for(contador=0;contador<8;contador++){ lcd_send_byte(0,caracter0_direccion[contador]); //modo comando lcd_send_byte(1,caracter0_datos[contador]); // modo dato lcd_send_byte(0,caracter1_direccion[contador]); //modo comando lcd_send_byte(1,caracter1_datos[contador]); // modo dato lcd_send_byte(0,caracter2_direccion[contador]); //modo comando lcd_send_byte(1,caracter2_datos[contador]); // modo dato lcd_send_byte(0,caracter3_direccion[contador]); //modo comando lcd_send_byte(1,caracter3_datos[contador]); // modo dato lcd_send_byte(0,caracter4_direccion[contador]); //modo comando lcd_send_byte(1,caracter4_datos[contador]); // modo dato lcd_send_byte(0,caracter5_direccion[contador]); //modo comando lcd_send_byte(1,caracter5_datos[contador]); } sim[0]=2; sim[17]=3; } void pantalla2(){ i=9; j=10; for(i=9;i>0;i--){ lcd_gotoxy(i,1);printf(lcd_putc," "); lcd_gotoxy(i,2);printf(lcd_putc," "); lcd_gotoxy(i,3);printf(lcd_putc," "); lcd_gotoxy(i,4);printf(lcd_putc," "); lcd_gotoxy(j,1);printf(lcd_putc," "); lcd_gotoxy(j,2);printf(lcd_putc," "); lcd_gotoxy(j,3);printf(lcd_putc," "); lcd_gotoxy(j,4);printf(lcd_putc," "); delay_ms(50); j++; } } // modo dato ϭϭϱ void pantalla3(){ for(i=20;i>0;i--){ lcd_gotoxy(i,1);printf(lcd_putc," "); lcd_gotoxy(i,2);printf(lcd_putc," "); lcd_gotoxy(i,3);printf(lcd_putc," "); lcd_gotoxy(i,4);printf(lcd_putc," "); delay_ms(50); } } void bienvenida(){ lcd_clear(); lcd_gotoxy(4,2);printf(lcd_putc,"CARROCERIAS"); lcd_gotoxy(4,3);printf(lcd_putc,"ANDINAS C.A"); delay_ms(3000); pantalla2(); // vDibujaMenu(2); } void bienvenida2(){ lcd_clear(); lcd_gotoxy(5,1);printf(lcd_putc,"Proyecto TAP"); lcd_gotoxy(3,2);printf(lcd_putc,"Sist. de Control"); lcd_gotoxy(6,3);printf(lcd_putc,"Automatico"); lcd_gotoxy(1,4);printf(lcd_putc,"********UNET********"); delay_ms(3000); pantalla2(); } void barra(){ lcd_clear(); lcd_gotoxy(1,3);printf(lcd_putc,"%s: ",mensaje); lcd_send_byte(1,0b11111111); delay_ms(200); lcd_send_byte(1,0b11111111); delay_ms(200); lcd_send_byte(1,0b11111111); delay_ms(200); lcd_send_byte(1,0b11111111); delay_ms(200); lcd_send_byte(1,0b11111111); delay_ms(200); lcd_send_byte(1,0b11111111); ϭϭϲ delay_ms(200); lcd_send_byte(1,0b11111111); delay_ms(200); lcd_send_byte(1,0b11111111); delay_ms(200); lcd_send_byte(1,0b11111111); delay_ms(250); lcd_clear(); } float volt_out,vbateria,vuc; char even='m',event='m'; float timecount2,distancia; long timecount; // Contador del eco sensor ultrasonico // para la interfaz usb const int8 Lenbuf = 128; int recbuf[Lenbuf],enviar[Lenbuf],datos[Lenbuf]; int pos,pos3,ind[6],indice; void write_eeprom_16bits(int,long val); long read_eeprom_16bits(int); void anti_pulsadores(char *); void ultrasonido(void); void metodos(int,char); void check_usb(void); void ver_tiempo(void); void metodos2(int,char); void metodos3(int,char); void metodos4(int,char); void metodos5(int,char); void metodos6(int,char); void ver_sensores(void); //void brillo(void); void load_set_point(void); void save_set_point(void); void imfo(); void write_eeprom_16bits(int address, long val){ int pLow, pHigh; pLow = val; pHigh = val>>8; ϭϭϳ write_eeprom(address,pHigh); delay_ms(12); ++address; write_eeprom(address,plow); delay_ms(12); } long read_eeprom_16bits(int address){ int pLow, pHigh; long result; pHigh = read_eeprom(address); ++address; pLow = read_eeprom(address); result=(pHigh<<8); result+=pLow; return result; } void anti_pulsadores(char *ev){ char event='m'; if(input(PIN_A2)){ // izquierda delay_ms (120); if(input(PIN_A2)){ do {}while (input(PIN_A2)); } event='x'; } if(input(PIN_A3)){ // derecha delay_ms (120); if(input(PIN_A3)){ do { } while (input(PIN_A3)); } event='y'; } if(input(PIN_E2)){ // arriba delay_ms (120); if(input(PIN_E2)){ do { } while (input(PIN_E2)); } event='n'; ϭϭϴ } if(input(PIN_C0)){ // abajo delay_ms (120); if(input(PIN_C0)){ do { } while (input(PIN_C0)); } event='w'; } if(input(PIN_A4)){ // enter delay_ms (150); if(input(PIN_A4)){ do { } while (input(PIN_A4)); } event='e'; } if(input(PIN_E1)){ // back delay_ms (120); if(input(PIN_A3)){ do { } while (input(PIN_A3)); } event='z'; } switch(event){ case 'w':VarMenu++; if(VarMenu>limite) VarMenu=limite; break; case 'n':VarMenu--; if(VarMenu==1) VarMenu=2; break; } *ev=event; } void ultrasonido(){ band = 0; timecount = 0; timecount2=0; lcd_clear(); // Variable auxiliar // ind_pwmador del eco ϭϭϵ do{ lcd_gotoxy(5,1);printf(lcd_putc,"RETROCESO"); lcd_gotoxy(1,3);printf(lcd_putc,"valor: %.2f ",timecount2); lcd_gotoxy(1,4);printf(lcd_putc,"Distancia(cm): %.1f ",distancia); anti_pulsadores(&evento); set_tris_b(0x00); //configuramos el trisb output_low(PIN_B2); //garantizamos un nivel bajo en el sensor delay_ms(100); timecount=0; // if (!input(PIN_B0)){ // enviamos pulso bajo-alto-bajo para activar sensor timecount=0; set_tris_b(0x00); output_low(PIN_B2); delay_us(1); output_high(PIN_B2); delay_us(3); output_low(PIN_B2); // en espera, escuchando el pulso de eco set_tris_b(0xFF); band=input(PIN_B2); while(band==0){ band=input(PIN_B2); } while(band==1){ band=input(PIN_B2); timecount=timecount+1; } // muestra la lectura del sensor en LCD delay_us(750); /*}else{ set_tris_b(0x00); // garantizamos que el pin este como salida del sensor output_low(PIN_B7); // dejamos un nivel bajo por seguridad delay_us(750); // delay timecount=0; }*/ timecount2=(float)timecount/1000; distancia=(float)((1731*timecount2)-294)/100; if(distancia<dist){ output_high(PIN_A5); output_high(PIN_C2); delay_ms(300); output_low(PIN_A5); output_low(PIN_C2); }else{ ϭϮϬ output_low(PIN_A5); output_low(PIN_C2); } // aux_in=input(PIN_B0); }while(input(PIN_B0)); set_tris_b(0x00); // garantizamos que el pin este como salida del sensor output_low(PIN_B2); // dejamos un nivel bajo por seguridad delay_us(750); // delay timecount=0; lcd_clear(); } void metodos(int Menu,char accion){ char even='m'; if((Menu==2)&&(accion=='e')){ pantalla3(); lcd_clear(); do{ anti_pulsadores(&even); set_adc_channel(1); delay_us(20); v_bat=read_adc(); volt_out=(float)(5*v_bat)/1024; lcd_gotoxy(3,1);printf(lcd_putc,"ESTADO DE BATERIA"); lcd_gotoxy(1,2);printf(lcd_putc,"VuC : %4ld",v_bat); lcd_gotoxy(1,3);printf(lcd_putc,"Voltaje: %.1f",vbateria); vuc=(float)v_bat; if(vuc<256){ vbateria=(float)((2*vuc)-406)/10; } if((vuc>255)&&(vuc<518)){ vbateria=(float)((5*vuc)+9316)/1000; } if(vuc>517){ vbateria=(float)((5*vuc)+9336)/1000; } delay_ms(1000); if(vuc<256){ // menor a 9,6V lcd_gotoxy(4,4);printf(lcd_putc,"bateria baja "); } if((vuc>257)&&(vuc<537)){ // 10,57 a 12V lcd_gotoxy(4,4);printf(lcd_putc,"bateria mitad"); } ϭϮϭ if(vuc>538){ // mayor a 12V lcd_gotoxy(4,4);printf(lcd_putc,"bateria alta "); } if(vuc<10){ vbateria=0; lcd_gotoxy(1,4);printf(lcd_putc,"bat. no conectada"); } }while(even!='z'); } if((Menu==3)&&(accion=='e')){ pantalla3(); lcd_clear(); VarMenu=2; limite=5; do{ submenu(VarMenu); anti_pulsadores(&even); metodos2(VarMenu,even); }while(even!='z'); limite=6; VarMenu=3; } if((Menu==4)&&(accion=='e')){ pantalla3(); lcd_clear(); imfo(); limite=6; VarMenu=4; } if((Menu==5)&&(accion=='e')){ pantalla3(); lcd_clear(); save_set_point(); strcpy(mensaje,"salvando"); barra(); } if((Menu==6)&&(accion=='e')){ strcpy(mensaje,"conectar"); ϭϮϮ barra(); do{ anti_pulsadores(&even); if(usb_enumerated()){ lcd_gotoxy(2,2);printf(lcd_putc,"enlace establecido"); if (usb_kbhit(1)){ usb_get_packet(1, recbuf, Lenbuf); if(protocolo==COMMAND_FIRMWARE){ for(i=0;i<Lenbuf;i++){ if(read_eeprom_16bits(40+(10*i))=='?') pos=i; enviar[i]=read_eeprom_16bits(40+(10*i)); } usb_put_packet(1,enviar,pos+1,USB_DTS_TOGGLE); } if(protocolo==COMMAND_EEPROM){ for(i=0;i<Lenbuf;i++){ if(recbuf[i]=='?') pos3=i; write_eeprom_16bits(40+(10*i),0x00); } for(i=0;i<pos3+1;i++) write_eeprom_16bits(40+(10*i),recbuf[i]); } } }else{ lcd_gotoxy(2,2);printf(lcd_putc,"USB no conectado "); } }while(even!='z'); } if((Menu==7)&&(accion=='e')){ pantalla3(); lcd_clear(); VarMenu=2; limite=6; do{ anti_pulsadores(&even); submenu4(VarMenu); metodos5(VarMenu,even); }while(even!='z'); VarMenu=7; ϭϮϯ } } void metodos2(int Menu,char accion){ char even='m'; if((Menu==2)&&(accion=='e')){ lcd_gotoxy(10,2);lcd_send_byte(1,2); lcd_gotoxy(20,2);lcd_send_byte(1,3); do{ anti_pulsadores(&even); lcd_gotoxy(12,2);printf(lcd_putc,"%s ",operacion[modo]); if(even=='y'||even=='x'){ modo=!modo; } if(modo){ output_high(PIN_B7); }else{ output_low(PIN_B7); } }while(even!='z'); } if((Menu==3)&&(accion=='e')){ lcd_gotoxy(10,3);lcd_send_byte(1,2); lcd_gotoxy(19,3);lcd_send_byte(1,3); do{ anti_pulsadores(&even); lcd_gotoxy(12,3);printf(lcd_putc,"%s",speed[vel]); if(even=='y') vel++; if(even=='x') vel--; if(vel<0) vel=2; if(vel>2) vel=0; if(vel==1){ output_high(PIN_B6); output_low(PIN_B5); } if(vel==2){ output_high(PIN_B5); output_low(PIN_B6); ϭϮϰ } if(vel==0){ output_low(PIN_B5); output_low(PIN_B6); } }while(even!='z'); } if((Menu==4)&&(accion=='e')){ pantalla3(); lcd_clear(); VarMenu=2; limite=3; do{ submenu2(VarMenu); anti_pulsadores(&even); metodos3(VarMenu,even); }while(even!='z'); VarMenu=4; limite=5; } if((Menu==5)&&(accion=='e')){ lcd_gotoxy(13,2);lcd_send_byte(1,2); lcd_gotoxy(20,2);lcd_send_byte(1,3); do{ anti_pulsadores(&even); if(even=='y') inc++; if(even=='x') inc--; if(inc<1) inc=1; if(inc>22) inc=22; dist=inc*10; lcd_gotoxy(14,2);printf(lcd_putc,"%4ldcm",dist); }while(even!='z'); } } void metodos4(int Menu,char accion){ char even='m'; if((Menu==2)&&(accion=='e')){ lcd_gotoxy(13,2);lcd_send_byte(1,2); lcd_gotoxy(20,2);lcd_send_byte(1,3); do{ ϭϮϱ anti_pulsadores(&even); if(even=='y') hora++; if(even=='x') hora--; if(hora<0) hora=23; if(hora>23) hora=0; lcd_gotoxy(16,2);printf(lcd_putc,"%d ",hora); }while(even!='z'); } if((Menu==3)&&(accion=='e')){ lcd_gotoxy(13,3);lcd_send_byte(1,2); lcd_gotoxy(20,3);lcd_send_byte(1,3); do{ anti_pulsadores(&even); if(even=='y') minuto++; if(even=='x') minuto--; if(minuto<0) minuto=59; if(minuto>59) minuto=0; lcd_gotoxy(16,3);printf(lcd_putc,"%d ",minuto); }while(even!='z'); } } void metodos6(int Menu,char accion){ char even='m'; if((Menu==2)&&(accion=='e')){ lcd_gotoxy(13,2);lcd_send_byte(1,2); lcd_gotoxy(20,2);lcd_send_byte(1,3); do{ anti_pulsadores(&even); if(even=='y') hora2++; if(even=='x') hora2--; if(hora2<0) hora2=23; if(hora2>23) hora2=0; ϭϮϲ lcd_gotoxy(16,2);printf(lcd_putc,"%d ",hora2); }while(even!='z'); } if((Menu==3)&&(accion=='e')){ lcd_gotoxy(13,3);lcd_send_byte(1,2); lcd_gotoxy(20,3);lcd_send_byte(1,3); do{ anti_pulsadores(&even); if(even=='y') minuto2++; if(even=='x') minuto2--; if(minuto2<0) minuto2=59; if(minuto2>59) minuto2=0; lcd_gotoxy(16,3);printf(lcd_putc,"%d ",minuto2); }while(even!='z'); } } void metodos3(int Menu,char accion){ char even='m'; /* if((Menu==2)&&(accion=='e')){ pantalla3(); lcd_clear(); brillo(); } */ if((Menu==2)&&(accion=='e')){ pantalla3(); lcd_clear(); VarMenu=2; limite=3; do{ submenu3(VarMenu); anti_pulsadores(&even); metodos4(VarMenu,even); }while(even!='z'); limite=4; VarMenu=2; } if((Menu==3)&&(accion=='e')){ ϭϮϳ // lcd_gotoxy(13,4);lcd_send_byte(1,2); // lcd_gotoxy(20,4);lcd_send_byte(1,3); pantalla3(); lcd_clear(); VarMenu=2; limite=3; do{ submenu5(VarMenu); anti_pulsadores(&even); metodos6(VarMenu,even); }while(even!='z'); limite=4; VarMenu=3; } } void metodos5(int Menu,char accion){ if((Menu==2)&&(accion=='e')){ output_high(PIN_B4); delay_ms(2000); output_low(PIN_B4); } if((Menu==3)&&(accion=='e')){ output_high(PIN_B6); delay_ms(2000); output_low(PIN_B6); } if((Menu==4)&&(accion=='e')){ output_high(PIN_B5); delay_ms(2000); output_low(PIN_B5); } if((Menu==5)&&(accion=='e')){ output_high(PIN_B7); delay_ms(2000); output_low(PIN_B7); } if((Menu==6)&&(accion=='e')){ output_high(PIN_B3); delay_ms(2000); ϭϮϴ output_low(PIN_B3); } } void check_usb(){ usb_task(); //usb_wait_for_enumeration(); if(usb_enumerated()){ USB=1; }else{ USB=0; } } void ver_tiempo(){ // lcd_clear(); datos_rtc(hora,minuto,hora2,minuto2); delay_ms(500); //leemos datos del ds1307 // sin en este retardo el reloj se vuelve loco if(USB){ lcd_gotoxy(4,4);printf(lcd_putc,"USB conectado"); }else{ lcd_gotoxy(4,4);printf(lcd_putc," "); } if(!USB && modo){ lcd_gotoxy(6,4);printf(lcd_putc,"modo auto "); } if(!USB && !modo){ lcd_gotoxy(6,4);printf(lcd_putc,"modo manual "); } } void ver_sensores(){ if(input(PIN_B0)){ ultrasonido(); } /* set_adc_channel(10); delay_us(20); v_ll=read_adc(); v_lluvia=(float)(5*v_ll)/1024;*/ // para la señal de reversa ϭϮϵ // if(v_ll>30){ // para la señal de lluvia if(v_ll){ if(vel==1){ output_high(PIN_B6); output_low(PIN_B5); } if(vel==2){ output_high(PIN_B5); output_low(PIN_B6); } if(vel==0){ output_low(PIN_B5); output_low(PIN_B6); } output_high(PIN_A5); }else{ output_low(PIN_B5); output_low(PIN_B6); output_low(PIN_A5); } /******** valor analogico-tiempo-brillo del LDR** set_adc_channel(0); delay_us(20); v_LDR=read_adc(); volt_out=(float)(5*v_LDR)/1024; if(v_LDR<554){ // noche=1; }else{ // noche=0; } /**************************************************/ } void load_set_point(){ hora=read_eeprom_16bits(0); minuto=read_eeprom_16bits(2); modo=read_eeprom_16bits(4); vel=read_eeprom_16bits(6); set_LDR=read_eeprom_16bits(8); ind_pwm=read_eeprom_16bits(10); ϭϯϬ inc=read_eeprom_16bits(12); hora2=read_eeprom_16bits(14); minuto2=read_eeprom_16bits(16); /* Despues de programar el uC, la memoria EEPROM interna se pone por defecto a '1' int16->0xFF*/ if(hora==65535) hora=0; if(minuto==65535) minuto=0; if(modo==65535) modo=0; if(vel==65535) vel=0; if(set_LDR==65535) set_LDR=0; if(ind_pwm==65535) ind_pwm=0; if(inc==65535) inc=0; if(hora2==65535) hora2=0; if(minuto2==65535) minuto2=0; } void save_set_point(){ write_eeprom_16bits(0,hora); write_eeprom_16bits(2,minuto); write_eeprom_16bits(4,modo); write_eeprom_16bits(6,vel); write_eeprom_16bits(8,set_LDR); write_eeprom_16bits(10,ind_pwm); write_eeprom_16bits(12,inc); write_eeprom_16bits(14,hora2); write_eeprom_16bits(16,minuto2); } void imfo(){ int i; // primero obtengo los limites de cada variable ϭϯϭ for(i=0;i<Lenbuf;i++){ datos[i]=read_eeprom_16bits(50+(10*i)); if(datos[i]=='>') ind[0]=i-1; if(datos[i]==']') ind[1]=i; if(datos[i]==')') ind[2]=i; if(datos[i]=='&') ind[3]=i; if(datos[i]=='}') ind[4]=i; if(datos[i]=='?'){ indice=i; } } //finalmente imprimo en el LCD // menu_datos(evento); lcd_gotoxy(4,1);printf(lcd_putc,"Datos del Dueño"); lcd_gotoxy(2,2);printf(lcd_putc,"nom: "); for(i=0;i<ind[0]+1;i++){ lcd_gotoxy(i+7,2);printf(lcd_putc,"%c",datos[i]); } lcd_gotoxy(2,3);printf(lcd_putc,"ape: "); for(i=0;i<(ind[1]-ind[0])-3;i++){ lcd_gotoxy(i+7,3);printf(lcd_putc,"%c",datos[i+ind[0]+3]); } lcd_gotoxy(2,4);printf(lcd_putc,"ced: "); for(i=0;i<(ind[2]-ind[1])-2;i++){ lcd_gotoxy(i+7,4);printf(lcd_putc,"%c",datos[i+ind[1]+2]); } /* delay_ms(4000); pantalla2(); lcd_gotoxy(4,1);printf(lcd_putc,"Datos del Dueño"); lcd_gotoxy(2,2);printf(lcd_putc,"placa: ");*/ /* for(i=0;i<(ind[3]-ind[2])-2;i++){ lcd_gotoxy(i+1,2);printf(lcd_putc,"%c",datos[i+ind[2]+2]); } for(i=0;i<(ind[4]-ind[3])-2;i++){ lcd_gotoxy(i+1,3);printf(lcd_putc,"%c",datos[i+ind[3]+2]); } for(i=0;i<indice-ind[4]-2;i++){ ϭϯϮ lcd_gotoxy(i+1,4);printf(lcd_putc,"%c",datos[i+ind[4]+2]); }*/ do{ anti_pulsadores(&evento); }while(evento!='z'); pantalla2(); VarMenu=4; } ϭϯϯ Anexo H. Datasheet del optoacoplador 4N32 ϭϯϰ ϭϯϱ ϭϯϲ Anexo I. Código fuente del módulo independiente de radiofrecuencia ϭϯϳ // ETAPA DE TRANSMISION #include<16F628A.h> #fuses INTRC,NOWDT,NOPROTECT,PUT,NOBROWNOUT,NOMCLR #use delay(clock=4000000) #use rs232(baud=2400,parity=N,xmit=PIN_B2,rcv=PIN_B1,bits=8) void main() { set_tris_a (0b00001110); setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1); setup_timer_1(T1_DISABLED); setup_timer_2(T2_DIV_BY_1,255,1); setup_comparator(NC_NC_NC_NC); setup_vref(FALSE); while(true){ if(input(PIN_A2)){ putc('a'); // rojo } if(input(PIN_A3)){ putc('d'); } putc(0xFF); } } // ETAPA DE RECEPCION #include<16F628A.h> #fuses INTRC,NOWDT,NOPROTECT,NOMCLR #use delay(clock=4000000) // verde ϭϯϴ #use rs232(baud=2400,parity=N,xmit=PIN_B2,rcv=PIN_B1,bits=8,sample_early) #use standard_io(B) #use standard_io(A) void main() { int band=0; set_tris_a(0x00); set_tris_b(0x02); enable_interrupts(INT_RDA); enable_interrupts(GLOBAL); setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1); setup_timer_1(T1_DISABLED); setup_timer_2(T2_DIV_BY_1,255,1); setup_comparator(NC_NC_NC_NC); setup_vref(FALSE); port_b_pullups(FALSE); while(true){ valor=getc(); if((valor=='a')&& (band==0)){ output_high(PIN_B0); output_high(PIN_A0); delay_ms(4000); band=1; }else if((valor=='d')&& (band==1)){ output_high(PIN_B7); output_high(PIN_A1); delay_ms(4000); band=0; }else{ output_low(PIN_B0); output_low(PIN_B7); output_low(PIN_A0); output_low(PIN_A1); } output_high(PIN_A7); } } ϭϯϵ Anexo J. Código fuente del software comunicación uC-PC 1.0 ϭϰϬ package javaapp; //import java.awt.event.ActionEvent; //import java.awt.event.ActionListener; import javax.sound.sampled.AudioFormat.*; /** * * @author Sulmar Duran */ public class Principal extends javax.swing.JFrame { public byte cmd_FW = 99; public byte cmd_EEPROM = 77; /** Creates new form Principal */ public Principal() { initComponents(); try { setTitle("Prueba de la comunicacion USB-PIC 1"); } catch (Exception e) { setTitle(e.getMessage()); System.out.println(e.getMessage()); } setLocationRelativeTo(null); setResizable(false); // para centrar pantalla // inabilita el maximizar } /** This method is called from within the constructor to * initialize the form. * WARNING: Do NOT modify this code. The content of this method is * always regenerated by the Form Editor. */ @SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents private void initComponents() { lectura_eeprom = new javax.swing.JButton(); ϭϰϭ pantalla = new javax.swing.JTextField(); escritura_eeprom = new javax.swing.JButton(); boton_borrar = new javax.swing.JButton(); ver = new javax.swing.JLabel(); pantalla2 = new javax.swing.JTextField(); jLabel1 = new javax.swing.JLabel(); jLabel2 = new javax.swing.JLabel(); jLabel3 = new javax.swing.JLabel(); pantalla3 = new javax.swing.JTextField(); pantalla4 = new javax.swing.JTextField(); pantalla5 = new javax.swing.JTextField(); pantalla6 = new javax.swing.JTextField(); jLabel4 = new javax.swing.JLabel(); jLabel5 = new javax.swing.JLabel(); jLabel6 = new javax.swing.JLabel(); jScrollPane1 = new javax.swing.JScrollPane(); TEXTO = new javax.swing.JTextArea(); jMenuBar1 = new javax.swing.JMenuBar(); jMenu1 = new javax.swing.JMenu(); smNew = new javax.swing.JMenuItem(); smOpen = new javax.swing.JMenuItem(); smSave1 = new javax.swing.JMenuItem(); smSave2 = new javax.swing.JMenuItem(); jMenu2 = new javax.swing.JMenu(); smAcerca = new javax.swing.JMenuItem(); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); lectura_eeprom.setText("Obtener datos del uC"); lectura_eeprom.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { lectura_eepromActionPerformed(evt); } }); escritura_eeprom.setText("Enviar datos al uC"); escritura_eeprom.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { escritura_eepromActionPerformed(evt); } }); boton_borrar.setText("limpiar"); boton_borrar.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { boton_borrarActionPerformed(evt); ϭϰϮ } }); pantalla2.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { pantalla2ActionPerformed(evt); } }); jLabel1.setText("Primer nombre"); jLabel2.setText("Primer apellido"); jLabel3.setText("Nro de cedula"); jLabel4.setText("Placa"); jLabel5.setText("serial carroceria"); jLabel6.setText("serial chasis"); TEXTO.setColumns(20); TEXTO.setRows(5); jScrollPane1.setViewportView(TEXTO); jMenu1.setText("archivo"); smNew.setText("nuevo"); smNew.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { smNewActionPerformed(evt); } }); jMenu1.add(smNew); smOpen.setText("abrir archivo"); smOpen.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { smOpenActionPerformed(evt); } }); jMenu1.add(smOpen); smSave1.setText("guardar"); smSave1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { ϭϰϯ smSave1ActionPerformed(evt); } }); jMenu1.add(smSave1); smSave2.setText("guardar como.."); smSave2.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { smSave2ActionPerformed(evt); } }); jMenu1.add(smSave2); jMenuBar1.add(jMenu1); jMenu2.setText("ayuda"); smAcerca.setText("acerca de"); smAcerca.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { smAcercaActionPerformed(evt); } }); jMenu2.add(smAcerca); jMenuBar1.add(jMenu2); setJMenuBar(jMenuBar1); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addContainerGap() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addComponent(lectura_eeprom) .addGap(18, 18, 18) .addComponent(escritura_eeprom, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addGroup(layout.createSequentialGroup() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jLabel4) .addComponent(jLabel5) .addComponent(jLabel6) 125, ϭϰϰ .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) .addComponent(jLabel2) .addComponent(jLabel3) .addComponent(jLabel1))) .addGap(18, 18, 18) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) .addComponent(pantalla6) .addComponent(pantalla5) .addComponent(pantalla) .addComponent(pantalla2) .addComponent(pantalla3) .addComponent(pantalla4, javax.swing.GroupLayout.DEFAULT_SIZE, 166, Short.MAX_VALUE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 18, Short.MAX_VALUE))) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGap(31, 31, 31) .addComponent(boton_borrar, javax.swing.GroupLayout.PREFERRED_SIZE, 138, javax.swing.GroupLayout.PREFERRED_SIZE, 217, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGroup(layout.createSequentialGroup() .addGap(10, 10, 10) .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE))) .addGap(57, 57, 57)) .addGroup(layout.createSequentialGroup() .addGap(87, 87, 87) .addComponent(ver, javax.swing.GroupLayout.PREFERRED_SIZE, 289, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap(196, Short.MAX_VALUE)) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGap(20, 20, 20) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(pantalla, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel1)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(pantalla2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel2)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) ϭϰϱ .addComponent(pantalla3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel3)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(pantalla4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel4)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(pantalla5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel5)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(pantalla6, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel6))) .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(ver) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 13, Short.MAX_VALUE) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(lectura_eeprom) .addComponent(escritura_eeprom) .addComponent(boton_borrar)) .addGap(21, 21, 21)) ); pack(); }// </editor-fold>//GEN-END:initComponents //**********ETAPA PARA LA COMUNICACION CON EL PIC************************* //************************************************************************ private static String getBitString(int x) { StringBuffer buf = new StringBuffer(); for (int i = 1; i <= 128; i++) { buf.append(x >>> (128 - i) & 0x00000001); } return buf.toString(); } public void send_command(byte command) { 198, ϭϰϲ byte[] out = {command}; } public void send_command(byte command, byte param1) { byte[] out = {command, param1}; } //************************************************************************* //************************************************************************* private void lectura_eepromActionPerformed(java.awt.event.ActionEvent evt) {//GEN- FIRST:event_lectura_eepromActionPerformed try { send_command(cmd_FW); String response = new String(read_response(128), "utf-8"); //verificamos que se hallan recibido datos if (response.length() > 0) { // pantalla.setText("" +response.substring(1,response.indexOf(">"))); pantalla.setText(""+response.substring(response.indexOf("<")+1,response.indexOf(">"))); pantalla2.setText(""+response.substring(response.indexOf("[")+1,response.indexOf("]"))); pantalla3.setText(""+response.substring(response.indexOf("(")+1,response.indexOf(")"))); pantalla4.setText(""+response.substring(response.indexOf("#")+1,response.indexOf("&"))); pantalla5.setText(""+response.substring(response.indexOf("{")+1,response.indexOf("}"))); pantalla6.setText(""+response.substring(response.indexOf("%")+1,response.indexOf("?"))); ver.setText(null); TEXTO.setText(""+response.substring(response.indexOf("<")+1,response.indexOf(">"))+"\n"+response.substring(respons e.indexOf("[")+1,response.indexOf("]"))); } else { ver.setText(null); ver.setText("Error: el cable no esta conectado"); } } catch (Exception ex) { System.out.println("ERROR:" + ex.getMessage()); } }//GEN-LAST:event_lectura_eepromActionPerformed private void escritura_eepromActionPerformed(java.awt.event.ActionEvent FIRST:event_escritura_eepromActionPerformed // TODO add your handling code here: byte[] b = new byte[30]; String suma = new String(); String captura = new String(); evt) {//GEN- ϭϰϳ String captura2 = new String(); String captura3 = new String(); String captura4 = new String(); String captura5 = new String(); String captura6 = new String(); captura=pantalla.getText(); captura2=pantalla2.getText(); captura3=pantalla3.getText(); captura4=pantalla4.getText(); captura5=pantalla5.getText(); captura6=pantalla6.getText(); suma='<'+captura+'>'+'['+captura2+']'+'('+captura3+')'+'#'+captura4+'&'+'{'+captura5+'}'+'%'+captura6+'?'; b = suma.getBytes(); ver.setText(null); ver.setText(""+suma.length()); }//GEN-LAST:event_escritura_eepromActionPerformed private void boton_borrarActionPerformed(java.awt.event.ActionEvent evt) {//GEN- FIRST:event_boton_borrarActionPerformed // TODO add your handling code here: pantalla.setText(null); pantalla2.setText(null); pantalla3.setText(null); pantalla4.setText(null); pantalla5.setText(null); pantalla6.setText(null); ver.setText(null); }//GEN-LAST:event_boton_borrarActionPerformed private void pantalla2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN- FIRST:event_pantalla2ActionPerformed }//GEN-LAST:event_pantalla2ActionPerformed private void smOpenActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_smOpenActionPerformed // Abre archivo de texto isnew=tc.Dialog("Open",TEXTO); }//GEN-LAST:event_smOpenActionPerformed private void smSave2ActionPerformed(java.awt.event.ActionEvent FIRST:event_smSave2ActionPerformed // Guarda en un nuevo archivo isnew=tc.Dialog("Save As", TEXTO); evt) {//GEN- ϭϰϴ }//GEN-LAST:event_smSave2ActionPerformed private void smSave1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN- FIRST:event_smSave1ActionPerformed // Guarda modificaciones de un archivo abierto if (isnew) { isnew = tc.Dialog("Save As", TEXTO); } else { isnew=tc.Dialog("Save", TEXTO); } }//GEN-LAST:event_smSave1ActionPerformed private void smNewActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_smNewActionPerformed // TODO add your handling code here: TEXTO.setText(""); isnew=true; }//GEN-LAST:event_smNewActionPerformed private void smAcercaActionPerformed(java.awt.event.ActionEvent FIRST:event_smAcercaActionPerformed // TODO add your handling code here: TEXTO.setText("visitame: http://jc-mouse.blogspot.com/"); }//GEN-LAST:event_smAcercaActionPerformed /** * @param args the command line arguments */ archivo tc = new archivo(); Boolean isnew = true; public static void main(String args[]) { java.awt.EventQueue.invokeLater(new Runnable() { public void run() { new Principal().setVisible(true); } }); } // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JTextArea TEXTO; private javax.swing.JButton boton_borrar; private javax.swing.JButton escritura_eeprom; evt) {//GEN- ϭϰϵ private javax.swing.JLabel jLabel1; private javax.swing.JLabel jLabel2; private javax.swing.JLabel jLabel3; private javax.swing.JLabel jLabel4; private javax.swing.JLabel jLabel5; private javax.swing.JLabel jLabel6; private javax.swing.JMenu jMenu1; private javax.swing.JMenu jMenu2; private javax.swing.JMenuBar jMenuBar1; private javax.swing.JScrollPane jScrollPane1; private javax.swing.JButton lectura_eeprom; private javax.swing.JTextField pantalla; private javax.swing.JTextField pantalla2; private javax.swing.JTextField pantalla3; private javax.swing.JTextField pantalla4; private javax.swing.JTextField pantalla5; private javax.swing.JTextField pantalla6; private javax.swing.JMenuItem smAcerca; private javax.swing.JMenuItem smNew; private javax.swing.JMenuItem smOpen; private javax.swing.JMenuItem smSave1; private javax.swing.JMenuItem smSave2; private javax.swing.JLabel ver; // End of variables declaration//GEN-END:variables