Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 01:43 29 Nov 2024 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : 4 x 4 matrix keypad

     Page 2 of 2    
Author Message
BobD

Guru

Joined: 07/12/2011
Location: Australia
Posts: 935
Posted: 11:48am 04 Feb 2014
Copy link to clipboard 
Print this post

David, there is a weakness in your good idea. That is, you are still having to poll the I2C device to find your keystrokes. You can wildly press keys but unless you poll then you don't know about them. This may be OK in some keyboard operations but sometimes you may want to interrupt a running program without having to always check for a keystroke.

An idea I have seen somewhere (can't remember where) is that the I2C slave has an additional line to the Micromite which can be used as a keystroke available indicator with an interrupt in the Micromite. This way the I2C poll can be used only when needed.

This idea could also be applied to other I2C attached functions. If this idea could be implemented in your I2C slave PICs then your devices could be very useful for certain applications. It would function as a slave with limited pseudo master capabilities.

I think I recall where I've seen the idea. I haven't checked but I think some I2C RTCs can use an interrupt line to indicate an alarm timeout. That is, the alarm has timed out please come and check.
 
Grogster

Admin Group

Joined: 31/12/2012
Location: New Zealand
Posts: 9308
Posted: 12:21pm 04 Feb 2014
Copy link to clipboard 
Print this post

Yes, there is that issue, Bob.

I suppose AGAIN, it depends on what you need your system to do.
In situations where the code knows it is expecting a user input from the keypad, David's system will work, and work well, as well as only using 2 lines!

But, as you say - if you have a situation where the user is pressing a button on the keypad, but the master code is not polling the I2C keypad device at that point in time, then no amount of keypressing will help you.
Smoke makes things work. When the smoke gets out, it stops!
 
MicroBlocks

Guru

Joined: 12/05/2012
Location: Thailand
Posts: 2209
Posted: 05:21pm 04 Feb 2014
Copy link to clipboard 
Print this post

often it is more advantagous to have the maximite be a i2c slave. each device that normally has to be polled can then be a master. the maximite will then get an interrupt that i2c data has arrived and can respond accordingly.

obviously something like a lcd is better as a slave.

Microblocks. Build with logic.
 
kiiid

Guru

Joined: 11/05/2013
Location: United Kingdom
Posts: 671
Posted: 05:48pm 04 Feb 2014
Copy link to clipboard 
Print this post

You could try this.
The total cost of a keyboard with it comes to less than $3 with a few R and C only outside, and it needs only one digital input on the micro.

http://rittle.org

--------------
 
MOBI
Guru

Joined: 02/12/2012
Location: Australia
Posts: 819
Posted: 07:56pm 04 Feb 2014
Copy link to clipboard 
Print this post

  bob said  David, there is a weakness in your good idea. That is, you are still having to poll the I2C device to find your keystrokes. You can wildly press keys but unless you poll then you don't know about them


yes, I understand that it must be polled in its simplistic form. My i2c modules were never meant to be more than what I needed and were/are part of my learning curve. I have never needed an interrupt driven slave however, most of my slave PICs have a spare pin which could be used to fire off an interrupt. Those that don't, I could always pinch one of the slave user address lines (two of) and limit the module to 1 of 2 addresses instead of 1 of 4. Then the master would have to know which slave triggered the interrupt. Not too much of a problem.

As all, (well, almost all) programmes run in a loop, I fit in a line or two of code to reset the slave control byte then re-poll the slave to see if a key is being held down, if so, the programme branches off to perform the "interrupt". Well, it works for me but perhaps I can see about including an interrupt pin and even maybe a reset line.

It is nice to see that there are more people than I thought actively using i2c.


David M.
 
Grogster

Admin Group

Joined: 31/12/2012
Location: New Zealand
Posts: 9308
Posted: 01:24pm 05 Feb 2014
Copy link to clipboard 
Print this post

I have started looking at I2C a lot more then I used to, mainly motivated by your apparent knowledge of it, David.

I plan to do some experiments with the MM chip in the coming months, as both ends of the link can be programmed in MMBasic, and with the chip itself being so cheap for what it can do, it is really too good an opportunity to miss, and also teach myself something about I2C at the same time.
Smoke makes things work. When the smoke gets out, it stops!
 
BobD

Guru

Joined: 07/12/2011
Location: Australia
Posts: 935
Posted: 02:40pm 05 Feb 2014
Copy link to clipboard 
Print this post

  Grogster said   I have started looking at I2C a lot more then I used to, mainly motivated by your apparent knowledge of it, David.

Grogster, are you not convinced. read smiley here.
Bob
 
MOBI
Guru

Joined: 02/12/2012
Location: Australia
Posts: 819
Posted: 02:44pm 05 Feb 2014
Copy link to clipboard 
Print this post

Hi Graeme,

Once you have a few modules (LCD, 7segLED, keypad, data expander, RTC,RAM etc), you'll wonder why you stuffed around trying to fit all your hardware onto the one PIC, Atmel, MM etc with all the firmware/software that went with it.

Plug in the i2c devices you want, set up their addresses and use some simple i2c master commands to read/write the modules. Really quite simple and virtually "plug and play"

I haven't tried using a uM as a slave yet. My feeling is that they are a bit physically large to use as a slave where a small soic pic is easy to solder and takes up little room.

Mind you, with some clever firmware, a uM could be turned into a multifunction slave e.g digital, adc, LCD in one package. Just use the control byte to access the function. Food for thought?

You have a PicKit3? - write your own PIC slaves.

David M.
 
Grogster

Admin Group

Joined: 31/12/2012
Location: New Zealand
Posts: 9308
Posted: 04:06pm 05 Feb 2014
Copy link to clipboard 
Print this post

@ Bob - Yes, convinced, but wanted to have people to fall back on, when I can't make things work!

@ MOBI - Yes, have a PicKit3 unit and the X IDE software all installed, mainly so that I could program and play with the MM chip.

I know nothing at all of the language and/or compilers needed to prigram a PIC using the Microchip native language, and I am NOT learning another language now!


Smoke makes things work. When the smoke gets out, it stops!
 
paceman
Guru

Joined: 07/10/2011
Location: Australia
Posts: 1329
Posted: 03:09am 06 Feb 2014
Copy link to clipboard 
Print this post

  chronic said   There was a scanned keypad + lcd arrangement for the bare-bones MM in the
ideas section of "Silicon Chip" a while ago, I think the basic code was
put on their website (?)

Yes, the edition was Aug 2013 in the 'Circuit Notebook' section, page 72. They quote the software as 'ketpadsc.bas' on the SC website - I think that's probably a typo and should be 'keypadsc.bas'. They used the Mini-Maximite but the new uMaximite could do the same thing.

GregEdited by paceman 2014-02-07
 
viscomjim
Guru

Joined: 08/01/2014
Location: United States
Posts: 925
Posted: 05:05am 06 Feb 2014
Copy link to clipboard 
Print this post

The Silicon Chip article for the lcd and matrix keyboard is EXACTLY what I was looking for. I think I may modify the keyboard routine first to run 16 keys instead of 12 (should be easy) and then incorporate using the micromite interrupt on any pin capability to avoid having to poll the keyboard and only deal with that when an actual key is pressed. If anyone has looked at the code, it seems very efficient and logical, a lot better that what I was coming up with. Jeez, I love this stuff, and when there is a support system, it can't get much better. Due to all the responses about I2C, I am now looking into this for other purposes as it does seem pretty cool to be able to just pound out a pic to do a very dedicated task and not bother the master too much while it is doing it's thing. As one of the posts mentioned, learning yet another language is not the most fun, however, there is alwasy picbasic pro, proton basic and mikrobasic available to write the code in a somewhat familiar syntax and then compile and burn into the pic. It seems that MOBI has a great deal of knowledge on this subject and maybe he could knock off a separate forum subject dedicated to this if there is enough interest. Something like where to start learning and a few SIMPLE examples of code for both ends that we can try to get familiar with I2C and actually be able to try them on the bench. Again, Thanks to all for help, this is a great group of people. BIG thanks to GEOFF, my new hero!
 
paceman
Guru

Joined: 07/10/2011
Location: Australia
Posts: 1329
Posted: 02:12pm 06 Feb 2014
Copy link to clipboard 
Print this post

We like this site too Jim and Glenn (Gizmo) who runs it and has done for quite a few years is a hero too.

When you've got it going, post a description & photo. Also the MMBasic library link which can be found on Geoff's site MM Basic Library is a great place to put generic (or specific) bits of code that you develope for everyone to use. If your code is based on other code make sure you acknowledge the original coder in comments at the top of the code and add "Modified by ........".

Have fun,
Greg
 
viscomjim
Guru

Joined: 08/01/2014
Location: United States
Posts: 925
Posted: 03:07pm 09 Feb 2014
Copy link to clipboard 
Print this post

Hi All,

First off, yes, I agree I have to give a big hand to Gizmo also. This site has helped me so much. I appreciate all the forum members for their input on this great product.

I have been able to get the 20 x 4 LCD to work using 6 pins and slightly modified code from the library (LCD_1) with the 28 pin micromite. Sooo Happy! Now on to the 16 keypad matrix….

Thanks again!



 
MOBI
Guru

Joined: 02/12/2012
Location: Australia
Posts: 819
Posted: 12:08am 10 Feb 2014
Copy link to clipboard 
Print this post

  Jim said  I have been able to get the 20 x 4 LCD to work using 6 pins


Hi Jim, it looks like a handy unit.

Do you have the data sheet for the 20x4 display or details of the display so I can look up the data sheet for myself. I realise there are quite a few of 20x4 displays on ebay and they are probably all the same. However, I'd like to remain compatible. I'd like to see if I can easily alter my i2c LCD driver to handle 4 lines instead of two.

I suspect I won't have to alter the firmware at all, just send different line/position codes.


David M.
 
MicroBlocks

Guru

Joined: 12/05/2012
Location: Thailand
Posts: 2209
Posted: 12:12am 10 Feb 2014
Copy link to clipboard 
Print this post

If i remember correctly the only thing you have to do is take care of the line numbers
they are 1,3,2 and 4. The rest should be the same.
Basically acting as two 2-line displays interleaved with each other.
Edited by TZAdvantage 2014-02-11
Microblocks. Build with logic.
 
MOBI
Guru

Joined: 02/12/2012
Location: Australia
Posts: 819
Posted: 01:12am 10 Feb 2014
Copy link to clipboard 
Print this post

  TZA said  If i remember correctly the only thing you have to do is take care of the line numbers
they are 1,3,2 and 4. The rest should be the same.
Basically acting as two 2-line displays interleaved with each other


Ok then. Based on that, I'll order a couple or three from ebay and see how they go using the PIC1503 14 pin soic chip. Looks like the LCDs are about US$6.00 each.

Do you know if there are versions where pins 1 and 2 are reversed (vss vdd)? @Jim, can you tell me the pinout on yours?
David M.
 
viscomjim
Guru

Joined: 08/01/2014
Location: United States
Posts: 925
Posted: 05:06am 10 Feb 2014
Copy link to clipboard 
Print this post

Mobi,

I will look for the pin out for the 2004 when I get back home. I did get it off ebay for about $7.00 I believe. I would like to know if you can do the 2004 with your setup. If you can, will you send me a link or something to describe how I would implement your method using the 1602 or 2004 display and how to use that with the micromite or maximite? I purchased a pickit 3 to program the micromite and would have to believe I can use it to program the pic you are using for this application. Also interested in the keyboard version. Does it do 3 x 4 and 4 x 4? Thanks for you help.
 
MOBI
Guru

Joined: 02/12/2012
Location: Australia
Posts: 819
Posted: 12:44pm 10 Feb 2014
Copy link to clipboard 
Print this post

@Jim,

  Quote  I will look for the pin out for the 2004 when I get back home. I did get it off ebay for about $7.00 I believe. I would like to know if you can do the 2004 with your setup. If you can, will you send me a link or something to describe how I would implement your method using the 1602 or 2004 display and how to use that with the micromite or maximite? I purchased a pickit 3 to program the micromite and would have to believe I can use it to program the pic you are using for this application. Also interested in the keyboard version. Does it do 3 x 4 and 4 x 4? Thanks for you help.


Both the LCD and Keypad are i2c devices (two wire)and use the standard MM uM i2c commands which makes it easy to communicate.

The keypad arrangement particularly the 4x4 will handle two hex keypads giving you a 32 key arrangement.

Got to go to town, will post more later.

=================
later:
Here are some relevant files for the dual hex keypad (i2c) Post here or PM me if any questions

2014-02-11_011450_hexkey88hex.zip

Edited by MOBI 2014-02-12
David M.
 
MOBI
Guru

Joined: 02/12/2012
Location: Australia
Posts: 819
Posted: 07:27pm 10 Feb 2014
Copy link to clipboard 
Print this post

  Quote   I purchased a pickit 3 to program the micromite and would have to believe I can use it to program the pic you are using


Hi Jim, I meant to reply in the last post - yes, you can use picKit3 to programme a PIC16F88(or 819). I use the MPLAB X IPE to do the programming. "Just" select the correct pic and family, load in the HEX file and click "erase", "programme" and if you like, "verify". I don't have code protect on so you shouldn't get a verify error.

plug the chip into your board and like the 32bit MM chip, it should all go.

My PicKit3 test programming setup. (The 5VDC supply not shown connected to the target board)



Edited by MOBI 2014-02-12
David M.
 
MOBI
Guru

Joined: 02/12/2012
Location: Australia
Posts: 819
Posted: 08:24pm 11 Feb 2014
Copy link to clipboard 
Print this post

Too hot outside to do much today so made up a PCB to suit the 16 key keypad. This one has two rows of headers and so will accommodate two 16 key keypads. In the current firmware, one keypad is all ascii and the other is binary 1 to 16.

Its not pretty, but it works.








David M.
 
     Page 2 of 2    
Print this page


To reply to this topic, you need to log in.

© JAQ Software 2024