![]() | ![]() | ![]() |
| |||||||
| 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 everyone, I'm having a problem with the verification of a key code that i set for my Burglar Alarm system . When i first power up the circuit a key is automatically pressed and the key counter automatically increments to 1 instead of staying at 0. Instead of entering 4 keys to verify the code it allows only 3 key presses since the key that was automatically pressed counted as 1 of the keys pressed. After the 1st attempt at entering the code the circuit doesn't do this anymore as i am able to enter 4 key presses. i cant figure out the problem that the hardware or the program code is having at power up. Please see the attachment to see the code im using. Thanks in advance Last edited by pic_programm3r; 28th March 2008 at 04:11 PM. | |
| |
| | #2 |
|
Where's the rest of the code? Are you sure this a code problem and not hardware? Can you show your schematic? Torben | |
| |
| | #3 |
|
Your compiler should have given you a warning with this code, Code: if(correct==4) //correct code was entered
{
Alarm_enabled();
correct=0;
else //the code is incorrect
{
incorrect_key(); //show that the incorrect code was entered
correct =0; //reset the code comparing bit to its default
}
Even when this is corrected, consider what will happen when correct=1. Looking at the rest of the code, braces seem to be missing everywhere. Try indenting your code correctly and see if this helps you spot the errors. Mike. | |
| |
| | #4 |
|
the code builds and it works alright in the simulator. As for the schematic i cant attach it because the forum says its a invalid file, being a .sch file. this is just a portion of the code that i copied from the main code which is a lot larger. also im using a 3x4 keypad and for some reason the column that has the key numbers 7,8,9 when i press the key a random number appears such as 0,2,1. those keys seem to rotate around those number (0,1,2) on each key press and then at a random time the correct key number actually shows up. it only happens to this column. same with the previous problem it works fine in the simulator but when used in the hardware it screws up. Because of this my keycode can be unlocked even though i appear to be pressing the wrong key. since 7,8,9 are replaced with 0,1,2 Thanks Last edited by pic_programm3r; 29th March 2008 at 06:11 AM. | |
| |
| | #5 | |
| Quote:
__________________ ========================= Futz's Microcontrollers & Robotics ========================= | ||
| |
| | #6 |
|
i thought that may have been a problem but i've got a 150mS delay in the keypad scan routine and also another 200mS in that for loop
| |
| |
| | #7 |
|
With the code posted above, the variable "correct" will never get above 1. You have the equivalent of, Code: if correct = 4
correct=0
else
correct=0
endif
I assume you based this on the code I posted on your other thread. Did that not work as expected? Mike. Last edited by Pommie; 29th March 2008 at 06:13 AM. | |
| |
| | #8 |
|
yes i have based it around that other thread. the variable increments each time a correct key has been pressed. This is for a different part of the code that i had previously thought was working perfectly. i had to use a for loop to make sure that i could get exactly 4 digits to compare with the 4 digit code that i had set. | |
| |
| | #9 | |
| Quote:
Can you please post the entire file exactly as it compiles for you? Torben | ||
| |
| | #10 |
|
here is pretty much all the code that is required to run this program
| |
| |
| | #11 |
|
ermm..how to attached files in this forum?
| |
| |
| | #12 |
|
Hello there.. I really need your help for my project. I design automatic fish feeder. I used alarm clock concept. I use PIC16F690 and need to program it in assembly language. I try to work on it but it doesn’t work in my circuit. I really need help as soon as possible.. Here I give you my coding and my circuit. Hope you can help me and get my coding function on my circuit.. Thank you
| |
| |
| | #13 |
|
I think your original problem is caused by not turning on the WPUs on PortB. Your delay routine does turn them on but this isn't called until after the first key read. Try adding OPTION=2; to your setup routine. Mike. | |
| |
| | #14 |
|
fza, You diagram shows a 4MHz crystal but your config selects the internal oscillator at 32k. Mike. | |
| |
| | #15 |
|
what is the WPU? Is it the pull up resistors? If it is i have enabled them in a couple of previous keypad programs and it caused some other problem. But i'll try it anyway. Or how about adding in a 100mS delay routine straight after the setup routine. Cheers | |
| |
|
| Tags |
| code, keypad, problem |
| Thread Tools | |
| Display Modes | |
| |
Similar | ||||
| Title | Starter | Forum | Replies | Latest |
| Code problem: bypass not working? | hotrodhed120 | Micro Controllers | 9 | 11th June 2007 03:23 PM |
| Problem in making assembly code | ahsanbilal | Electronic Projects Design/Ideas/Reviews | 2 | 11th September 2006 07:21 AM |
| Question about the PIC chip lineup | mramos1 | Micro Controllers | 23 | 31st May 2006 08:51 AM |
| Problem; Random pic performance | timothyjackson | Micro Controllers | 7 | 19th February 2005 07:20 PM |
| Tough assembly program for the PIC16F84 | asmpic | Micro Controllers | 34 | 3rd December 2004 07:50 PM |