![]() | ![]() | ![]() |
| |||||||
| Micro Controllers Discuss all aspects of micro controllers - building them, coding them, etc. All controllers are welcome - PIC, BASIC, Z8 Encore!, etc. |
![]() |
| | Tools |
| | #1 |
|
Hi, recently I'm doing a project about the infrared security system, which is using keypad(4X3) to key-in the passward and send to the receiver part by infrared. My task is when I recieve the passward, "*" will display on LCD screen one code by code. Also, I've to compare the passward with the original passward that has been set initially. If the codes are correct, it'll call "Correct Code"; on the other hand, if the codes are wrong, it'll "Wrong Code". I have created coding to receive the key-in passward and check the passward, but it's not work what I want. At first, I test the coding by pressing button, if the button is being pressed, "*" will display out, and if correct, "Correct Code" will display out at the second line. However, when I test on the bread board, is not like that. The "*" and "Correct Code" came out together after the LCD flashing. Sometime, LCD will display wrongly like "Correct Cede*". Why it be like that? How can I improve it? My coding is shown below: Code: LIST P=16F877 #INCLUDE <P16F877.INC> errorlevel -302 errorlevel -207 __CONFIG _CP_OFF & _PWRTE_ON & _XT_OSC & _WDT_OFF CBLOCK 0X20 CODE1 ;FOR NUMBER CODE2 ;FOR NUMBER CODE3 ;FOR NUMBER CODE4 ;FOR NUMBER D1 D2 D3 D4 ENDC ORG 0X00 GOTO START WRONG CALL LCD_INIT CALL LCD_LINE2 BSF PORTC,2 ;R/S SET TO '1' MOVLW H'57' MOVWF PORTD CALL CLOCK_E MOVLW H'72' MOVWF PORTD CALL CLOCK_E MOVLW H'6F' MOVWF PORTD CALL CLOCK_E MOVLW H'6E' MOVWF PORTD CALL CLOCK_E MOVLW H'67' MOVWF PORTD CALL CLOCK_E MOVLW H'20' MOVWF PORTD CALL CLOCK_E MOVLW H'43' MOVWF PORTD CALL CLOCK_E MOVLW H'6F' MOVWF PORTD CALL CLOCK_E MOVLW H'64' MOVWF PORTD CALL CLOCK_E MOVLW H'65' MOVWF PORTD CALL CLOCK_E RETURN CORRECT CALL LCD_INIT CALL LCD_LINE2 BSF PORTC,2 ;R/S SET TO '1' MOVLW H'43' MOVWF PORTD CALL CLOCK_E MOVLW H'6F' MOVWF PORTD CALL CLOCK_E MOVLW H'72' MOVWF PORTD CALL CLOCK_E MOVLW H'72' MOVWF PORTD CALL CLOCK_E MOVLW H'65' MOVWF PORTD CALL CLOCK_E MOVLW H'63' MOVWF PORTD CALL CLOCK_E MOVLW H'74' MOVWF PORTD CALL CLOCK_E MOVLW H'20' MOVWF PORTD CALL CLOCK_E MOVLW H'43' MOVWF PORTD CALL CLOCK_E MOVLW H'6F' MOVWF PORTD CALL CLOCK_E MOVLW H'64' MOVWF PORTD CALL CLOCK_E MOVLW H'65' MOVWF PORTD CALL CLOCK_E RETURN SECRET CALL LCD_INIT BSF PORTC,2 ;R/S SET TO '1' MOVLW H'2A' MOVWF PORTD CALL CLOCK_E RETURN START MOVLW D'1' MOVWF CODE1 SETPORTS BSF STATUS,RP0 MOVLW B'00000001' MOVWF TRISB MOVLW B'00000000' MOVWF TRISC MOVLW B'00000000' MOVWF TRISD BCF STATUS,RP0 CLRF PORTA CLRF PORTD CODE1CHK BTFSS PORTB,0 ;I test one code GOTO CODE1CHK CALL SECRET CHECK MOVF CODE1,W SUBLW B'00000001' BTFSS STATUS,Z GOTO WRONGCHK GOTO CORRECTCHK WRONGCHK CALL WRONG CORRECTCHK CALL CORRECT BSF PORTC,0 LCD_INIT BCF PORTC,2 MOVLW B'00110000' MOVWF PORTD ;FUNCTION SET: 8 BIT INTERFACE CALL CLOCK_E MOVLW B'00001100' MOVWF PORTD ;DISPALY & CURSOR: SET TO DISPLAY ON; CURSOR UNDERLINE OFF; CURSOR BLINK OFF CALL CLOCK_E MOVLW B'00111000' MOVWF PORTD ;FUNCTION SET: 8 BIT; 2 LINE MODE; 5X10 DOT FORMAT CALL CLOCK_E MOVWF B'00000001' MOVWF PORTD ;CLEAR DISPLAY CALL CLOCK_E MOVLW B'00000110' MOVWF PORTD ;CHARACTER ENTRY MODE: INCREMENT; DISPLAY SHIFT ON CALL CLOCK_E RETLW 0X00 LCD_LINE2 BCF PORTC,2 ; R/S SET TO '0' MOVLW B'11000000' MOVWF PORTD ; JUMP TO 2ND LINE CALL CLOCK_E RETLW 0X00 CLOCK_E BSF PORTC,1 CALL DELAY2 BCF PORTC,1 RETLW 0X00 DELAY1 MOVLW D'130' MOVWF D2 MOVLW D'221' MOVWF D1 LOOP1 DECFSZ D1,1 GOTO LOOP1 DECFSZ D2,1 GOTO LOOP1 RETLW 0X00 DELAY2 MOVLW D'13' ;DELAY 10ms MOVWF D4 MOVLW D'251' MOVWF D3 LOOP2 DECFSZ D3,1 GOTO LOOP2 DECFSZ D4,1 GOTO LOOP2 RETLW 0X00 END | |
| |
| | #2 |
|
You might try checking my keypad code in the tutorials, one does just such a password check.
| |
| |
| | #3 | |
| Quote:
I couldn't understand.Also, my part is not connecting with keypad, should I need to check and scan key? | ||
| |
| | #4 | |
| Quote:
| ||
| |
| | #5 | |
| Quote:
From your tutorial, your check code is like below: Code: Chk_Code movf code1, w ;test first digit subwf key1, w btfss STATUS, Z goto Wrong Code: CHECK MOVF CODE1,W ;I set CODE1 as one SUBLW B'00000001' BTFSS STATUS,Z GOTO WRONGCHK | ||
| |
| | #6 |
|
No, just that mine uses the password stored in registers, which makes it easier to change - your's uses a password hard coded in the source.
| |
| |
| | #7 |
|
My checking code has no problem, but the displayment got a bit problem. I cannot clear the LCD after displaying characters. How could I make it after displaying due to my coding? I've been use B'00000001', but is not work. | |
| |
| | #8 |
|
You need to send the command to clear the display, and wait long enough for it to complete - details are in my tutorial, or on the datasheets.
| |
| |
| | #9 |
|
Hi, now I'm almost done my part. My coding has been combined with my groupmate, which when I receive any code from transmitter through infrared, I'll check all the codes and display in LCD. But I need to improve my coding, which I can change code for the system. Does anyone can give me some idea?
| |
| |
| | #10 | |
| Quote:
| ||
| |
| | #11 |
|
Hi, I'm trying using the EEPROM coding, but I couldn't store the value in another location. My coding is showing below: Code: list p=16f877,f=inhX32, x=off include <p16f877.inc> __CONFIG _CP_OFF & _PWRTE_ON & _XT_OSC & _WDT_OFF ERRORLEVEL -302 ;Suppress bank warning CBLOCK 0X20 COUNT ADDR VALUE ENDC ORG 2100H DE 00H ORG 0X00 GOTO START READ BSF STATUS, RP1 BCF STATUS, RP0 MOVF ADDR, W MOVWF EEADR BSF STATUS, RP0 BCF EECON1, EEPGD BSF EECON1, RD BCF STATUS, RP0 MOVF EEDATA, W RETURN WRITE BSF STATUS, RP1 BSF STATUS, RP0 BTFSC EECON1, WR GOTO $-1 BCF STATUS, RP0 MOVF ADDR, W MOVWF EEADR MOVF VALUE, W MOVWF EEDATA BSF STATUS, RP0 BCF EECON1, EEPGD BSF EECON1, WREN MOVLW 0x55 MOVWF EECON2 MOVLW 0xAA MOVWF EECON2 BSF EECON1, WR BCF EECON1, WREN RETURN START BSF STATUS,RP0 MOVLW B'00000000' MOVWF TRISB BCF STATUS,RP0 CLRF PORTB MOVLW .2 MOVWF ADDR MOVLW .4 MOVWF VALUE CALL WRITE MOVLW .3 MOVWF ADDR MOVLW .3 MOVWF VALUE CALL WRITE CALL READ END Thanks in advanced. | |
| |
| | #12 |
|
You are accessing your variables that are in bank 0 whilst you are in banks 2 & 3. The simplest way to fix this would be to move your variables to 0x70, the common area. Mike. | |
| |
| | #13 | |
| Quote:
| ||
| |
| | #14 | |
| Quote:
| ||
| |
| | #15 |
|
Just change cblock 0x20 to cblock 0x70 and your code should work. Once you get it working, study the data sheet and try and work out why that made it work. Mike. | |
| |
|
| Tags |
| check, code, facing, lcd, problem |
| Thread Tools | |
| Display Modes | |
| |
Similar | ||||
| Title | Starter | Forum | Replies | Latest |
| LCD 2x16 Demo for the Unicorn (18F4550) | blueroomelectronics | Micro Controllers | 25 | 13th January 2009 03:04 AM |
| Strange problem | tkvenki | Micro Controllers | 1 | 3rd May 2007 12:40 PM |
| info about computes im facing some hardware problem | salman007 | Chit-Chat | 6 | 29th March 2007 07:23 PM |
| Check my Timer code | MrMikey83 | Micro Controllers | 7 | 17th January 2005 07:56 AM |
| pc keyboard interfacing problem | econsyst | Micro Controllers | 0 | 8th November 2003 09:28 PM |