|
|
View previous topic :: View next topic |
Author |
Message |
mrboler
Joined: 24 Dec 2017 Posts: 3
|
Password Lock System |
Posted: Sun Dec 24, 2017 10:53 am |
|
|
Hello guys, I a am newbie and I have a problem.
I can not read the value on the LCD from the Keypad(3*4). I tried to pull up and pull down one by one without looking for logic anymore. But I still can not solve it for this problem.
To summarize, I use 16F877A, the keypad is connected to port B (for internal pull up). When I used a keypad for example 1, LCD gives me 1, 2 or 3 just random. Same for other keys :( . That's why I do pull up/down wrong, but how am I supposed to solve it?
Code and diagram are exported, thanks in advance for those who can help.
Code: |
#include <16f877A.h>
#fuses XT,NOWDT,NOPROTECT
#use delay(clock=4000000)
#include <lcd.c>
#use fast_io(c)
#use fast_io(b)
#use fast_io(d)
#define sut1 pin_B4
#define sut2 pin_B5
#define sut3 pin_B6
#define sat1 pin_B0
#define sat2 pin_B1
#define sat3 pin_B2
#define sat4 pin_B3
#define buzzer pin_c0
#define use_portd_lcd TRUE
unsigned int8 tus,e,a,b,c,d;
unsigned int16 sifre=0;
void tus_al()// yazılım bu fonksiyona geldiğinde buradan bir
{ // tus değeri almadan bu fonksiyondan çıkmaz
don:
output_low(sut1);output_high(sut2);output_high(sut3);
if(input(sat1)==0){tus=1;goto brk;}
if(input(sat2)==0){tus=4;goto brk;}
if(input(sat3)==0){tus=7;goto brk;}
if(input(sat4)==0){tus=15;goto brk;}
output_high(sut1);output_low(sut2);output_high(sut3);
if(input(sat1)==0){tus=2;goto brk;}
if(input(sat2)==0){tus=5;goto brk;}
if(input(sat3)==0){tus=8;goto brk;}
if(input(sat4)==0){tus=0;goto brk;}
output_high(sut1);output_high(sut2);output_low(sut3);
if(input(sat1)==0){tus=3;goto brk;}
if(input(sat2)==0){tus=6;goto brk;}
if(input(sat3)==0){tus=9;goto brk;}
if(input(sat4)==0){tus=14;goto brk;}
goto don;
brk:
while(!input(sat1));
while(!input(sat2));
while(!input(sat3));
while(!input(sat4));
output_high(buzzer);delay_ms(100);output_low(buzzer);
}
void main()
{
set_tris_b(0x0F);//keypad baglı
set_tris_c(0b00000000);
set_tris_d(0b00000000);
port_b_pullups(true);//*** CMOS girişler voltaja hassastır
output_b(0x00);
output_c(0x00);
output_d(0x00);
lcd_init(); // LCD hazırlanıyor
basla:
printf(lcd_putc,"\fsifre:");
delay_ms(100);
all:
tus_al();
a=tus;
lcd_gotoxy(9,1);
printf(lcd_putc,"%u",tus);
if(tus==14||tus==15) {goto basla;}
delay_ms(20);
tus_al();
b=tus;
lcd_gotoxy(10,1);
printf(lcd_putc,"%u",tus);
if(tus==14||tus==15) {goto basla;}
delay_ms(20);
tus_al();
c=tus;
lcd_gotoxy(11,1);
printf(lcd_putc,"%u",tus);
if(tus==14||tus==15) {goto basla;}
delay_ms(20);
tus_al();
d=tus;
lcd_gotoxy(12,1);
printf(lcd_putc,"%u",tus);
if(tus==14||tus==15) {goto basla;}
delay_ms(20);
tus_al();
e=tus;
if(tus==15) {goto basla;}
sifre=(((int16)a*1000)+((int16)b*100)+(c*10)+(d*1));
delay_ms(300);
if(sifre==9876 && e==14)
{
lcd_gotoxy(1,1);
printf(lcd_putc,"\f DOGRU SIFRE");
printf(lcd_putc,"\n PROJE CALISTI");
delay_ms(300);
while(1) // Sonsuz döngü
{
output_high(pin_c1);
delay_ms(100);
output_low(pin_c1);
delay_ms(100);
}
}
else
{
lcd_gotoxy(1,1);
printf(lcd_putc,"\f YANLIS SIFRE");
printf(lcd_putc,"\nTEKRAR DENEYINIZ");
delay_ms(1000);
goto basla;
}
}
|
|
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9221 Location: Greensville,Ontario
|
|
Posted: Sun Dec 24, 2017 2:02 pm |
|
|
caps on xtal clock pins are incorrect |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19498
|
|
Posted: Tue Dec 26, 2017 3:20 am |
|
|
and to go back to Temtronic's comment.
The first thing you should always do, is to get the chip simply working. Forget about keyboards an LCD's. Just the basic 'flash an LED' test.
This must flash, and at the right speed, before anything else.
With the capacitors as shown, the chip will not run. |
|
|
mrboler
Joined: 24 Dec 2017 Posts: 3
|
|
Posted: Tue Dec 26, 2017 9:15 pm |
|
|
Ttelmah wrote: | and to go back to Temtronic's comment.
The first thing you should always do, is to get the chip simply working. Forget about keyboards an LCD's. Just the basic 'flash an LED' test.
This must flash, and at the right speed, before anything else.
With the capacitors as shown, the chip will not run. |
Thanks for advice. I will work more simply for my other works.
Now I found the problem I will send whole code and Proteus file.
Today I will convert to pcb from breadboard then I can upload.
I didnt get it why did you say chip will not run with these capacitors ??
They are goes to ground. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19498
|
|
Posted: Wed Dec 27, 2017 1:36 am |
|
|
Perhaps 1000000 times larger than they want to be....
The loading capacitors on a crystal are typically in the range of 12pF to 33pF. Pico farad. 1E-12. You have 33uF capacitors shown.... 33E-6. Practically a dead short circuit at the crystal operating frequency. |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9221 Location: Greensville,Ontario
|
|
Posted: Wed Dec 27, 2017 6:03 am |
|
|
The xtal caps is just one example as to why NOT to rely upon Proteus as a 'simulator'. A real simulator would have a set of 'design rules' and test before 'compiling and running'. It should report the error of specifying 33 ufd caps where obviously 33 pfd caps would be. A human bench tech would KNOW just by looking at the physical cap..'well that ain't right', investigate the schematic or parts list, and then question the person who specified 33 ufd.
Unfortunately Proteus doesn't do this kind of checking or verifying. If you build according to Proteus schematic , your project will never work.
Sadly there's a LOT of people who put their faith in this product not understanding it has a tremendous number of errors. Even the schematic design portion has 'flaws' that allow errors, something us humans, still using pencil and paper, don't create.
Jay |
|
|
mrboler
Joined: 24 Dec 2017 Posts: 3
|
|
Posted: Wed Dec 27, 2017 3:06 pm |
|
|
Thank you, Jay and @Ttelmah.
First of all I did not care how much I chose the capacitors in proteus. I already set up the circuit on the breadboard with "33pF"...
When you said "it is not work because of capacitors", I did not understandwhat you mean. But I agree with what jay says about proteus, maybe it should be the modes of proteus, for example, very strict rules for beginners, reduced rules for middle level etc.
I will also edit the circuit I'm soldering the printed circuit board. The deadline for submission of the project is friday at the latest Friday, so I will put all the components here so that maybe others can do it. I will also translate some Turkish function names into English.
As far as my limited English is concerned
By the way, I know my code is very weak. I learned from the internet, but I did not enjoy using the goto command. I'm talking as a baby
Thank you guys again. |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9221 Location: Greensville,Ontario
|
|
Posted: Wed Dec 27, 2017 3:34 pm |
|
|
The problem with using the wrong values in the schematic is that if you give the schematic to another technician to build, it cannot work. While YOU know 33mfd is the wrong value, the other person will build according to the schematic.
Sadly, Proteus does NOT do 'error checking' properly otherwise it WOULD have seen the 33mfd and reported an error (perhaps saying 'value out of expected range').
Even I have trouble with English (I'm Canadian, eh) so I'm always impressed with others around the World can actually get PICs to work in their country !
Jay |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|