Well Toni... you have to make some kind of decisions here...
I'm going to ask you to close your eyes and think of the number of digits I'm holding up in my left hand right now. Not easy to guess is it? Same with your PIC. It's trying to guess how many digits you want to enter... so basically we have these choices...
1. Fixed Length
The PIC waits until you've entered a fixed number of Digits... say three or five or whatever, and then goes away to process the result. This is the method used for typically Pass-Key applications for Door-Entry or those cheap worthless safes you see with Digital Locks.
A more advanced (and proper) version of this incorporates a timeout, so that once entry begins, it must be completed within a set time period, otherwise everything is reset back to the beginning. For example if you have a 3-digit door entry code, but somebody only enters two digits and walks away, you don't want those two-digits to remain 'in the system' forever, so the next user gets a fresh start at entering three digits cleanly.
2. Variable Length - Record Delimited Method
Here you enter as many digits as you want, and then you terminate your data-entry with an 'Enter' (Return) Key or similar (eg the way you send AT commands to your modem). this is called the Record Delimiter, and on receipt the host will know that you've finished entering your variable-length data and it now has to go away and process it. If you have a numeric keypad, then the chances are you've got a '*' or '#' key which you can assign to this task. So, now for example if you want to enter the numeric value 671, you would key '671*' or '671#'. This is the kind of method employed by automated telephone Credit-Card or Banking applications... "Please enter your account number followed by the Hash or Square Key"... and by the more technically advanced telephone drug dealers... "If you want to buy Marijuana please press the Hash key".
That last comment will probably go over the heads of our American friends as they know it as the "Pound" key. Why?
3. Variable Length - Timeout Method
Here the method is as I described in section 2 above, however the Record delimiter here is TIME. For example four seconds after you've entered your last digit the host decides that since no more keys have been pressed, this is all that is to be accepted. The drawback here is that you can't hesitate too long between digits as the host will assume (rightly or wrongly) you're not going to enter any more. If you leave the timeout too long, then the user gets bored waiting for his front door to open and he'll climb in thru the window.
That's basically all your choices. Fixed length is easy... everybody uses it. Variable length has to be delimited by some method so the host knows when it can start processing the entered data.
There is actually a fourth method... rarely used and difficult to impliment correctly...
4. Variable Length - Lookup Method
As the user types in the data, the host is performing lookup in real-time... and performs its programmed action if the lookup matches the entered data. The critical factor here is TIME, otherwise (say it's a door-entry application), if the user enters 333741 and the door unlock code is 3337, the host will unlock the door incorrectly after the fourth digit has been entered. Therefore you normally employ the Lookup "in arrears" that is after allowing some finite time to see if another digit is going to be entered. So really this method when implimented correctly, actually becomes a variation of Method 3.
Melanie
Bookmarks