mrauf57
Guest
|
|
« on: March 02, 2011, 04:09:22 04:09 » |
|
hi every one, i m new in proton compiler. i connect LCD16x2 and keypad (4x4) with 16f877A. my problem is that , in LCD, it can show from 0-15 on pressing from first till last key, while i want to print what is exactly written in keypad. like 1-9, 0, A to D.? my second problem is that i can see the number only while pressing, i want that pressed no. to show untill i press new no.? and third problem is that,i want to save the pressed digits from key pad , to send them wirelessly too, but thats a later task, first i need to save the digits in any variables. many thinks and regards to all, plz waiting for the reply my code is here, '**************************************************************** '* Name : UNTITLED.BAS * '* Author : [select VIEW...EDITOR OPTIONS] * '* Notice : Copyright (c) 2011 [select VIEW...EDITOR OPTIONS] * '* : All Rights Reserved * '* Date : 27.01.2011 * '* Version : 1.0 * '* Notes : * '* : * '**************************************************************** Device = 16f877a XTAL 4 ALL_DIGITAL=true
Declare LCD_TYPE 0 Declare LCD_DTPIN PORTD.4 Declare LCD_ENPIN PORTD.3 Declare LCD_RSPIN PORTD.2 Declare LCD_INTERFACE 4 Declare LCD_LINES 2 Dim var1 As Byte dim KEY as byte
High PORTd.1 DECLARE KEYPAD_PORT PORTb Cls
main: var1 = INKEY Key = LOOKUP VAR1,[255,1,2,3,"A",4,5,6,"B",7,8,9,"C","*",0,"#","D"] delayms 100 Print At 2,1, @var1,"Rauf" goto main
|
|
|
Logged
|
|
|
|
TomJackson69
Active Member
Offline
Posts: 218
Thank You
-Given: 26
-Receive: 63
|
|
« Reply #1 on: March 02, 2011, 06:48:44 06:48 » |
|
In your main loop, after read a key (var1 = INKEY), you should compare to an old key. If NEW key <> OLD key then you have new key pressed. Otherwise, either same key pressed or no new key pressed. Let have a variable called OldVar1. Then your main loop looks something like this: main: var1 = INKEY // IS function INKEY returns 0-15 if (var1 != OldVar1) // CHECK THE SYNTAX FOR BASIC // Print on LCD only have a new key pressed{ Key = LOOKUP VAR1,[255,1,2,3,"A",4,5,6,"B",7,8,9,"C","*",0,"#","D"] Print At 2,1, @var1,"Rauf" OldVar1 = var1 // Save the key value for later} delayms 100 goto main I write program in C, but the logic is same as basic Tom
|
|
« Last Edit: March 02, 2011, 06:53:15 06:53 by TomJackson69 »
|
Logged
|
Con Rong Chau Tien
|
|
|
pickit2
Moderator
Hero Member
Offline
Posts: 4658
Thank You
-Given: 832
-Receive: 4301
There is no evidence that I muted SoNsIvRi
|
|
« Reply #2 on: March 02, 2011, 11:22:47 11:22 » |
|
If you choose 16F887 as your device and add your keypad and lcd as per PIC16_ALCD_VHB.DSN in proton. then you can try it out in proton. Device = 16F877 Xtal 4 All_Digital=true
Declare LCD_Type 0 Declare LCD_DTPin PORTD.4 Declare LCD_ENPin PORTE.1 Declare LCD_RSPin PORTE.0 Declare LCD_Interface 4 Declare LCD_Lines 2 Dim var1 As Byte Dim KEY As Byte
High PORTD.1 Declare Keypad_Port PORTB Cls
main: var1 = InKey KEY = LookUp var1,[255,1,2,3,"A",4,5,6,"B",7,8,9,"C","*",0,"#","D"] DelayMS 100 Print At 2,1, @var1,"Rauf" GoTo main works for me as far as to see what your code is doing.
|
|
« Last Edit: March 02, 2011, 11:30:15 11:30 by pickit2 »
|
Logged
|
Note: I stoped Muteing bad members OK I now put thier account in sleep mode
|
|
|
mrauf57
Guest
|
|
« Reply #3 on: March 09, 2011, 04:05:55 04:05 » |
|
@TomJackson69, hi, i used ur way but still no progress, means still my problem to save pressed button in any variable, could not done. Still untill i pressed any botton, it appear, when i release, it shows 16 on LCD. second problem also remain unsolved, seems lookup table is not working, showing 0-15 while pressing from first till last button, not show what is written on the keypad. here is my revised code on ur logic. main: var1 = INKEY if var1 <> oldkey then Key = LOOKUPl VAR1,[1,2,3,"A",4,5,6,"B",7,8,9,"C","*",0,"#","D"] delayms 100 Print At 2,1, @var1, "Rauf" var1 = oldkey delayms 100 else goto main endif @pickit2, hi, what is meant by "PIC16_ALCD_VHB.DSN", i dont have this file, can u send me or guid me how can i get this file or example? many thanks and waiting for reply
|
|
|
Logged
|
|
|
|
o2
Moderator
Hero Member
Offline
Posts: 505
Thank You
-Given: 40
-Receive: 405
Top Topic Starter
|
|
« Reply #4 on: March 09, 2011, 03:31:39 15:31 » |
|
@mrauf57 Your print(var1) not result from lookup,result lookup is "key",variable from keypad 0-15,when press 1 var1=0,change var1 1-16 with +1 sorry if wrong,i'm not use proton. main: var1 = InKey var1=var1+1 KEY = LookUpL var1,[255,"1","2","3","A","4","5","6","B","7","8","9","C","*","0","#","D"] DelayMS 100 Print At 2,1, KEY,"Rauf" GoTo main
|
|
|
Logged
|
|
|
|
pickit2
Moderator
Hero Member
Offline
Posts: 4658
Thank You
-Given: 832
-Receive: 4301
There is no evidence that I muted SoNsIvRi
|
|
« Reply #5 on: March 09, 2011, 04:10:54 16:10 » |
|
PIC16_ALCD_VHB.DSN is in sample folder, It is part of the Demo boards made by crownhill, and installed when proton is. maybe you need to read proton help file. your code works if you change the ports to match above board.
|
|
|
Logged
|
Note: I stoped Muteing bad members OK I now put thier account in sleep mode
|
|
|
TomJackson69
Active Member
Offline
Posts: 218
Thank You
-Given: 26
-Receive: 63
|
|
« Reply #6 on: March 09, 2011, 04:58:59 16:58 » |
|
mrauf57,
Why don't you draw a circuit in Proteus to simulate to see if your program works. I will help you to get this project done.
One of my mistake in the program that I had suggested you is: { Key = LOOKUP VAR1,[255,1,2,3,"A",4,5,6,"B",7,8,9,"C","*",0,"#","D"] Print At 2,1, @var1,"Rauf" OldVar1 = var1 // Save the key value for later } It should be: { Key = LOOKUP VAR1,[255,1,2,3,"A",4,5,6,"B",7,8,9,"C","*",0,"#","D"] Print At 2,1, @Key,"Rauf" OldVar1 = var1 // Save the key value for later }
Try that to see if it works. Sorry for the mistake.
Anyways, draw your circuit in Proteus. Post your circuit and program, I will work on.
Tom
|
|
« Last Edit: March 09, 2011, 05:07:32 17:07 by TomJackson69 »
|
Logged
|
Con Rong Chau Tien
|
|
|
pickit2
Moderator
Hero Member
Offline
Posts: 4658
Thank You
-Given: 832
-Receive: 4301
There is no evidence that I muted SoNsIvRi
|
|
« Reply #7 on: March 09, 2011, 07:28:09 19:28 » |
|
Its all in my 3rd post above, I even the rewrote mrauf57's code so it works with crownhill development board.
Your missing my point crownhill have Development and Prototype boards. the also have all the above ciruit on one of them. They have sample code, and most Importantly a copy of Proteus (copy is even loaded if you have full proteus). so no need to leave PDS to test your code. so easy way to try your code is 1. write it. 2. compile it. 3. run it via proton.
EDIT: run proton load the code from my post above complie code cilck on ISIS in tool bar of proton select PIC16_ALCD_VHB.DSN protues opens job done.
|
|
« Last Edit: March 09, 2011, 07:33:43 19:33 by pickit2 »
|
Logged
|
Note: I stoped Muteing bad members OK I now put thier account in sleep mode
|
|
|
mrauf57
Guest
|
|
« Reply #8 on: March 10, 2011, 02:07:59 02:07 » |
|
@TomJackson69 and o2, thaaaaaaaaaaaaank u guys.... u r absolutely right, my approach was wrong, now my lookup table is working, now i can print as written on my key pad.. i changed my program using ur approach and ok... @PICKIT2, m new in proton,dont know how to use proteus even, untill now i could not find the Development and Prototype boards and the circuits your talking about. also i want to use 18f4550 but the my proton is not supporting. Only supporting until 16f series. now m downloading it (proteus lite free) and will learn , then surly i would need ur help to resolve some of problem... Many Many thanks
|
|
|
Logged
|
|
|
|
pickit2
Moderator
Hero Member
Offline
Posts: 4658
Thank You
-Given: 832
-Receive: 4301
There is no evidence that I muted SoNsIvRi
|
|
« Reply #9 on: March 10, 2011, 12:17:27 12:17 » |
|
You must be using a very old version if it don't support 18Fxxx chips. You need bunions Proton, it supports most if not all the 18Fxxx chips. and as for Proteus try P7.8i both in this forum.
|
|
|
Logged
|
Note: I stoped Muteing bad members OK I now put thier account in sleep mode
|
|
|
fernandodiaz
Junior Member
Offline
Posts: 73
Thank You
-Given: 1
-Receive: 18
|
|
« Reply #10 on: May 22, 2011, 05:18:42 17:18 » |
|
Hi comunity Some have sample code of 22 BIT A/D converter MCP3550 PROTON PLUS
|
|
|
Logged
|
|
|
|
pickit2
Moderator
Hero Member
Offline
Posts: 4658
Thank You
-Given: 832
-Receive: 4301
There is no evidence that I muted SoNsIvRi
|
|
« Reply #11 on: May 22, 2011, 07:16:22 19:16 » |
|
Hi comunity Some have sample code of 22 BIT A/D converter MCP3550 PROTON PLUS
And has this to do with Topic? EDIT:Don't Hi-Jack Topics, If you have something to post, post it, if something to ask, Ask it. Start your Topic with [Req] works for most people here.
|
|
|
Logged
|
Note: I stoped Muteing bad members OK I now put thier account in sleep mode
|
|
|
|