Hi again Al
Thank you again for the reply :-)
Adding OPTION_REG.7 = 0 ' Enable PORTB pull-ups
Shows a compile error in Microstudio
Does not compile
I am using an 18F4520
So I am back to square one
Any suggestions
Hi again Al
Thank you again for the reply :-)
Adding OPTION_REG.7 = 0 ' Enable PORTB pull-ups
Shows a compile error in Microstudio
Does not compile
I am using an 18F4520
So I am back to square one
Any suggestions
"Each of the PORTB pins has a weak internal pull-up. A single control bit can turn on all the pull-ups. This is performed by clearing bit, RBPU (INTCON2<7>). The weak pull-up is automatically turned off when the port pin is configured as an output. The pull-ups are disabled on a Power-on Reset."Code:INTCON2.7 = 0 'switch pull-ups ON
(Page 96 on PIC18F4520 manual)
BR,
-Gusse-
Last edited by Gusse; - 20th November 2009 at 20:08.
Dennis not all pic has the internal pullup, could be that your mcu has not pullup.Adding OPTION_REG.7 = 0 ' Enable PORTB pull-ups
Shows a compile error in Microstudio
Does not compile
I am using an 18F4520
(Check the datasheet).
Since you will need the pullups (otherwise the keypad will not work), so add four external 10K resistors.
Al.
Edit:
Gusse has read the datasheet for you: Replace OPTION_REG.7 = 0 with INTCON2.7 = 0
Last edited by aratti; - 20th November 2009 at 20:16.
All progress began with an idea
Al, Gusse
Thank you both I implemented mister e's keypad using the whole of port B as an input had to perform some pin swaps on row and column order and it's working .
I have two more questions :
1.How do I set the keys to display the correct characters as per the keypad
my matrix key's are labeled is as follows:
1 2 3 A
4 5 6 B
7 8 9 C
* 0 # D
but when I press the keys for example 1,2,3,A
My readout is 1,2,3,4
Would I have to do a lookup or re-assignment ?
2. How do i capture a number ending with a hash for example
The reason I am asking is because I would like to type in a number for example 135 end it with a # to signify an enter and then store and send the number (TX).
Any further help would be appreciated
I am not familiar with mister e's keypad program, but if you get the sequence from 1 to 16, then use an array to code out what you need.1 2 3 A
4 5 6 B
7 8 9 C
* 0 # D
but when I press the keys for example 1,2,3,A
My readout is 1,2,3,4
Would I have to do a lookup or re-assignment ?
Code:Kp_Array var byte [17] Kp_Array[1] = "1" Kp_Array[1] = "2" . . . Kp_Array[15] = "#" Kp_Array[16] = "D"If Kp_Array[keypress] = "#" then ........2. How do i capture a number ending with a hash for example
Al.
All progress began with an idea
Thanks again for the tip Al :-)
I was thinking along the same lines although I don't think this is exactly what I'm after.
You see the keypad code only allows for a single keypress at a time at the moment.
So the largest number you can type in is 16 (the highest key on the keypad)
I want to be able to type in a number like 124 and end it with a #
So this number (the actual number 124) can be transmitted.
If you could imagine a cellphone or cordless landline...
As you type in the numbers on the keypad you can see them on the screen and then you press dial or possibly C(clear or *) to backspace one digit.
And when you are happy with the number on screen you press dial (in my case #) then your number is dialled (in my case TX'd)
Does this make sense ?
Kind regards
Dennis
So that means that now the keypad works correctly, and when you press the wanted key you obtain the correct caracter.I want to be able to type in a number like 124 and end it with a #
So this number (the actual number 124) can be transmitted.
If you could imagine a cellphone or cordless landline...
As you type in the numbers on the keypad you can see them on the screen and then you press dial or possibly C(clear or *) to backspace one digit.
And when you are happy with the number on screen you press dial (in my case #) then your number is dialled (in my case TX'd)
To acheive what you want, you will need an additional array and a few variables:
The array will retain the numbers you key in and a variable should keep track of the number of time you have pressed the keys.
Here a snippet
I set the array Ret_Char to 10 elements, if you need more then adjiust it for your need. The snippet is not tested so some adjustment could be necessary.Code:Ratain var byte Ret_Char var byte [10] Ret_Count var byte Ret_Prnt var byte Ret_Clst var byte Ret:Prnt = "#" Ret_Clst = "*" Loop: Ret_Char[Ret_Count]=Key_Char ' here you transfer the char of the key pressed If Retain = 0 then ' Retain is a flag then if set will do your job Hserout [Ret_Char[Ret_Count]] else If Ret_Char[Ret_Count] = Ret_Clst then ' if key = "*" then step-back counter Ret_Count = Ret_Count - 1 goto Clear_Count endif If Ret_Char[Ret_Count] = Ret_Prnt then ' if key = "#" then send string Hserout [str Ret_Char \ Ret_count-1] RetCount = 0 goto Clear_Count endif Ret_Count = Ret_Count + 1 Clear_Count: endif return
Al.
Last edited by aratti; - 21st November 2009 at 21:02.
All progress began with an idea
Al
:-)
WOW thank you ... wasn't expecting you to code it for me :-)
The array idea is perfect for capturing the keypresses and also the option to loop until we see a # or *
The code snippet raises a few questions though....
On receipt of a # it sends off a string of characters (those encountered before the #..not so ?
For example I key in 134#
First keypress to first variable in the array [1]
Second to the second variable [3]
Third to third variable [4]
Then the # is encountered and we do an hserout
Will we send a total of a 3 character string using hserout (in other words 24bits)
Apologies if I have the workings of the code wrong ...I am not clued up on the workings of hserout yet but I am reading up.
Once again any suggestions or guidance would be appreciated.
Kind regards
Dennis
Bookmarks