Discussion in "Project Help" started by    Deepakvaishu    Mar 20, 2017.
Mon Mar 20 2017, 01:54 pm
#1
hello,
I am using a keypad to type the text message,I am using a 8051 microcontroller and a 4X4 matrix keypad . I tried too much,But not getting the exact logic to use a single key to type 3 different alphabets ,eg key 1 is used to type a, b, c depending upon the number of times the key is pressed.
I have used a variable 'count ' to check the number of times key pressed, again I have to display the letter on the lcd .....plz give me the idea how actually the multiple letters are identified depending upon the key pressed.
Since the Col are input(1) and Row are output(0).
Is the key released() before it is pressed second time to print the 'b' letter,
Plz help for the coding of this program.

Tue Mar 21 2017, 08:25 pm
#2
HI,
There are two ways I'd tackle thiss.

Key down only - Use a timer and have 3 consecutive time slots - read 1=character, If read 2 = read 1 then use second character on the key, If read 3 also= reads 1 and 2 use third character associated with that key, read 4 resets read counter and goes back to character 1.

Key up then down - Read matrix, use character, start a timer on key up, if timer not run out and read 2=read 1 then use second character on that key. etc.

Hope that helps.
Steve



Thu Mar 23 2017, 11:04 am
#3
hello,
I can type the letters now when the particular key is pressed.But the problem now I am facing is that when the same key is pressed twice after a long delay I want the second letter to be printed to the adjacent position, How to recognise that the delay is more and the key should be printed at the next position on lcd.
How should recognise the delaybetween two keys pressed..If the delay is more than I want to increament the position on my lcd...
Plz help.

Deepakvaishu
Fri Mar 24 2017, 02:44 am
#4
You have largely answered your own question.
Use one of the timers to track time, say in 10mS counts.
Note the count each time a key is pressed.
Calculate the interval.
A short interval is to select values for the same key.
A long interval is a new selection.


[ Edited Fri Mar 24 2017, 07:04 am ]
 Deepakvaishu like this.
Fri Mar 24 2017, 10:52 am
#5
Hi,
I got that we should use timer......But I am a little bit confused that we can use timer to create the delay of particular time interval....But I really dont know , how to track the time ?
I am new in this field...should I use a timer as a counter to count the delay?
plz help.
Fri Mar 24 2017, 11:35 pm
#6
The best way is to use an interrupt to run the counter.
What software are you using ?
Sat Mar 25 2017, 01:29 pm
#7
I am using Keil and 8051 microcontroller
Sun Mar 26 2017, 03:19 am
#8
I have attached code showing one method you could use.
It deals with timing, you will have to add the code to
scan a matrix to read a key.


Attachment


[ Edited Sun Mar 26 2017, 03:23 am ]
 Deepakvaishu like this.
Thu Apr 06 2017, 01:25 pm
#9
hello,
Thanks for the attachment.
I have gone through your code . I did not got how the variable Keytime is updated.
Is it initially assigned as '0', and then when the timer interrupt occurs then it is incremented ??
plz help.

Thu Apr 06 2017, 11:08 pm
#10


Is it initially assigned as '0', and then when the timer interrupt occurs then it is incremented ??

Deepakvaishu


Yes, the timer interrupt is called about 50 times a second
and increments keyTime.
The main program continuously monitors and resets keyTime.

This bit of code starts Timer 0 and enables its Interrupt.

ET0 = 1;                      /* Enable Timer 0 Interrupts */
TR0 = 1;                      /* Start Timer 0 Running */
EA = 1;                       /* Global Interrupt Enable */


This is the Timer 0 Interrupt handler.
It reloads the timer counters then increments keyTime
up to KEY_REPEAT_TIME (200).
void timer0_ISR (void) interrupt 1
{
	 TL0=0;  //reload timer
	// TH0=0xdc;  //values give 10mS period
	 TH0=0xbc;  //longer time for Proteus simulation
	
	if (keyTime < KEY_REPEAT_TIME)   //hold at limit
	{
		keyTime++; 
	}
}
 Deepakvaishu like this.

Get Social

Information

Powered by e107 Forum System

Downloads

Comments

Robertrip
Fri Apr 26 2024, 11:20 am
ArnoldDiant
Fri Apr 26 2024, 03:53 am
RodneyKnorb
Thu Apr 25 2024, 07:08 pm
Williamjef
Thu Apr 25 2024, 02:08 pm
SamuelSmise
Thu Apr 25 2024, 09:56 am
DustinErele
Thu Apr 25 2024, 08:44 am
ztaletpzca
Wed Apr 24 2024, 11:19 pm
IrardlPex
Wed Apr 24 2024, 08:42 pm