Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

i need help for proteus and microbasic

Status
Not open for further replies.

eng soso

Newbie level 5
Joined
Jan 17, 2011
Messages
10
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,356
hi, when i tried to run this code on this schematic diagram not all the program work ,i want to ask why the input from the keypad not recognized in the degsin,i.e no input from keypad although i press the keys?! iguess that the problem in the microbasic code,thanks
 

delay_ms(2000)

I don't use microbasic but in a quick look at you code i saw the delay above and you are using it 2 times,
while the mcu is in the above delay function it is not scanning for any key press,
you should not use a big delay like this in the loop that scans the keypad, use a few ms if you want.
Also the loop that you use runs the entire initialization code for the ports and the display (every 2+2 seconds),
this should be run only one time and the loop should be for the scan and display part only.

Alex
 

I don't use Microbasic, The code looks ok to me, At a geuss I would say the keypad is wired wrong, What you can try first is set the resistors to digital instead of analog in the properties of the resistor when you double click on it, when I have used keypad in isis I only placed resistors in the A,B,C,D line to the pic with a value between 220R-330R same again they have to be set to digital and Normally I use PortB with the pull_ups enabled (weak pull_ups) PORTC does have this feature
 

The code looks ok to me

This is the code
Code:
program soso_test
dim text as char[20]
dim text2 as char[20]
dim kp as integer
dim txt as string[5]
main:
[COLOR="red"][B]l1:[/B][/COLOR]
[COLOR="blue"][B]TRISB=0
TRISC=%11111111
Lcd_Init(PORTB)
keypad_Init(PORTC)
Lcd_Cmd(Lcd_CURSOR_OFF)[/B][/COLOR]

text="general:press1"
text2="private:press2"
Lcd_Out(1,1,text)
Lcd_Out(2,1,text2)
[COLOR="seagreen"][B]delay_ms(2000)[/B][/COLOR]
Lcd_Cmd(LCD_CLEAR)

 kp=keypad_Released
 WordToStr(kp,txt)
Lcd_Out(1,1,txt)
[COLOR="seagreen"][B]delay_ms(2000)[/B][/COLOR]
Lcd_Cmd(LCD_CLEAR)
if kp=1 then
Lcd_Out(1,1,"11")
else if kp=2 then
Lcd_Out(1,1,"12")
end if
end if
[COLOR="red"][B]goto l1[/B][/COLOR]

end.

This crates a loop using the goto (marked red in the above code) which runs the port and LCD initialization code (marked with blue) every few seconds, do you consider this to be a good practice?

He also uses these 2 second delays (marked with green) which actually freeze to execution of the program for the given time, bottom line he checks for a pressed key once every 4sec, do you also think that this is correct?

Alex
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top