Serial LCD
fzeitgeist
Posts: 20
I am trying to get an example code for programming a serial 4X20 LCD with the BS2p/40. Does any one know where I can find one on the parallax website(I already found one for a parallel LCD).
Thank You.
Thank You.
Comments
Here is a sample code that will work for you.· You 'll need to change the baud rate to 16624 in the SEROUT command and this will configure it for the BS2p.· This will only work if it has the Hitachi 44780 chip.
Dave
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Dave Andreae
Tech Support
dandreae@parallax.com
www.parallax.com
Thank You.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Sid Weaver
Do you have a Stamp Tester?
http://hometown.aol.com/newzed/index.html
·
Dave
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Dave Andreae
Tech Support
dandreae@parallax.com
www.parallax.com
·
Based upon my reading of the specs, there is no special wiring, just use the cable that they sell to plug the keypad into the LCD controller. Key presses are then transmitted to the Stamp on whatever interface you have defined between the LCD controller and the Stamp.
Jim
Jim
Thank You. [noparse]:)[/noparse]
I'm somewhat of a novice at the hardware side of things. But this is what I think might work.
According to the data sheet, the 74C922 passes the key pressed as a 4 bit binary number through 4 data lines. I'd be inclined to start with something along this line:
In the above, INA is a nibble which maps to the same space as pins 0-3. There is also INB, C, and D, if you wish to use different pins. The LOOKUP you'll have to figure out for yourself as I don't have the keypad and don't feel like digging up the data sheet. But the concept is to translate the binary code the 74C922 passes you into the actual key pressed on the keypad. I specified "value" as a byte, because you'll probably be wanting to return ASCII codes for the non numeric keys that are pressed. Although you could go with a nibble to save 4 bits if necessary and use tokens for the non numeric keys.
Jim
Post Edited (Jim McCorison) : 2/19/2005 3:50:14 PM GMT
Anyway, I think the following code will do instead:
The sequence of the characters in the keypad DATA statement is the same as my post above about NSLOOKUP. The key thing is that you map the sequence of the keypad characters with the binary values returned by the data lines.
Sorry about the earlier brain fart.
Jim
While reviewing the column, I noticed that they used the NSLOOKUP command to solve the translation problem, assigning numeric tokens to the non-numeric keys. So I guess I was on the right track with NSLOOKUP. Although I still like the DATA / READ solution better.
Jim
·· I have been watching this discussion, and I only just now decided to offer this...I once used the 74C922 in a project a long time ago.· It's been a long time, so I could be wrong, but I believe that was the cause of much grief in a project due to the way it scans the keypad.
·· If memory serves the 74C922 continually scans the keypad generating noise.· As I recall, when we first had this problem I replaced that chip with a 74LS374 & 74LS244.· That was fine for what were doing, and later adpated to a Commodore Surplus keyboard that Radio Shack used to carry (Or any C= VIC or 64 keyboard).
·· Later when I needed to scan a keypad for the Stamp, I thought about the 74C922, but instead went to the EDE1144 by E-Labs.· This chip is basically a pre-programmed pic, and so it requires a crystal.· However it does not scan the keypad continuously.· Instead it waits for a state change, then performs a scan, reducing EMI noise.· I think the price is less than, or equal to the price of the 74C922, and the EDE1144 can output either 4-bit parallel, or serial (TTL), making a great choice for the BASIC Stamp.· I believe it also has key repeat.
Just my $.02
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
--==<{Chris}>==--
So I guess it depends on how much noise fzeitgeist can tolerate and whether or not the 74C922 is a requirement (i.e. school project) or just the chip in mind.
Jim
THANK YOU ONCE AGAIN EVERYONE.
Jim
· Oddly enough, I only just realized that the LCD Display mentioned above has a keypad decoder built-in!· I guess I should've read back a little bit before my first post.· I caught the part about the 74C922 and jumped in.· Well, I'm sure there were some people who may have been reading along and learned about 2 new chips!·
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
--==<{Chris}>==--
No worries, mate. Fzeitgeist first mentioned the 74C922 anyway as he also wanted to do a version without the LCD module. But I sure learned about a bunch of new stuff which is why I read all of this.
Jim
BUT.. its not over yet. I am trying to interface athe pcf8583 chip with with the bs2p40. it runs fine when i use the pcf8583 sample program i found on parallax. but i am trying to integrate it with my previous program, where the user is prompted to set the time and date using the lcd and keypad. when i run the program, it says not enough memory, where it points to a variable (VAR) which cannot be send to RAM. any help on this. i guess i need more memory space.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
--==<{Chris}>==--
The stamp only has 26 bytes for variables. The error you are getting is what happens when you try and exceed this limit. I don't know if multi-bank Stamps like the BS2P have 26 bytes for each bank or not. I'm just a lowly BS2 owner.
You'll need to conserve memory somewhere along the line. Use only as large a variable as you really need. In otherwords, don't use a word variable (2 bytes) for a variable that only counts from 1 to 10, where a nibble (4 bits) would work instead. Also reuse or generalize variable where you can.
Jim
Take a look in the PBASIC Stamp Manual at the GET and PUT commands.
Bruce Bates
The PCF8583 also has about 200 Bytes of spare RAM inside that you could use. If you put a little battery (3V Lithium) or a large capacitor (0.1 to 1 Farad to the PCF the extra RAM will not get lost when you switch off the Stamp and the clock will stay running. This way there will be no need to enter time and date every time you start your system.
Regards,
Klaus
here is how the code looks like:
GET 0, temp1
DEBUG "before temp1 = ", temp1, CR
temp1 = temp1 * 10
DEBUG "after temp1 = ", temp1, CR
'before temp1' displays the number pulled from the scratch pad, for example, if i punched in 1 on the keypad it stores 1 on the scratch pad, then i GET this values and store it in temp1. when i display it using DEBUG it shows 1... but after multiplication a wierd character is displayed. any help on this. btw... temp1 is assigned as a byte.
Try this, to convert the key to a number that multiplies the way you expect, and display it using the DEC modifier.
GET 0, temp1
temp1=temp1-48 ' convert to number
DEBUG "before temp1 = ", DEC temp1, CR
temp1 = temp1 * 10
DEBUG "after temp1 = ", DEC temp1, CR
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tracy Allen
www.emesystems.com
Jim