Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

reading a 4x4 switch matrix

Status
Not open for further replies.
MrDEB,

I built a prototype of your project with a PIC18F2520 (sorry I don't have a PIC18F24K20 handy).

This is my schematic:
**broken link removed**

You can find my complete project on GitHub **broken link removed**.

The source code is done with the Microchip XC8 compiler. It will also compiler for the PIC18F24K20 but I do not have any to validate it. Every thing works with a PIC18F2520 so I believe that it will work for the PIC you selected.

Be warned that my circuit is similar to yours but not the same. I assigned the pins in a way to make In-Circuit-Debug possible.
Is the R/W grounded by the pic? why connect it to a pin unless your reading from the display? I assume the lcd is near enough same as the Hitachi controller ones? Final question why 20MHz when he is trying to save power? the 32.7KHz should be more than fast enough and save a fair bit of power for him.

I appreciate it isnt optimized for Mr Deb and its nice of you to do it, but not having read the entire thread, i am unsure why you have 2 crystals etc.
 
Unless I'm really short of pins, I always connect the R/W line so I can check the busy flag.

Dan, nice schematic. Only change I would make would be to use the internal oscillator as, I assume, timing can use the 32k crystal.

Mike.
 
according to the HD44780 data sheet it says 300-600ua power supply current.
Maybe I just need to switch the backlight using a BJT?
 
according to the HD44780 data sheet it says 300-600ua power supply current.
Maybe I just need to switch the backlight using a BJT?


Obviously, that does not include the backlight. If everyone is telling you the backlight is a major current draw, perhaps you should appreciate they have a good understanding of the subject.
 
Unless I'm really short of pins, I always connect the R/W line so I can check the busy flag.

Dan, nice schematic. Only change I would make would be to use the internal oscillator as, I assume, timing can use the 32k crystal.

Mike.
Sorry my reply was tailored to the OP, but yes i utterly agree if your going to do things properly then the flag can save just guessing at timing etc. Now back in the altered reality of this project...... The what flag?? :D

Plus the project is in C...............ten of my British £ against one of your Aus $ that the project is totally ignored.

1 It contains 2 crystals and crystals cost money.
2 Its written in C so cant be messed with
3 It works

Not a chance its going to get used.
 
Last edited:
I realize the backlight has the largest current draw. My plan is to shut the Vdd source to the LCD off.
using a mosfet or a simple NPN transistor or similar.
 
If you turn off the LCD then you will need to reinitialise it. Just turn off the backlight or, better still, turn it really dim.

Mike.
 
Hopefully, MrDEB's LCD data sheet will look something like this. This first mandatory requirement is that the LCD be rated to operate at 3.3 volts. 5 volt LCDs will operste at 3.3 volts, but Vo for contrast adjustment may need to be negative to have a viewable display.

The next item to note is LCD Module or LCD Logic current drain. This us the current draw for the brain of the LCD module, neglecting the backlight which is always listed separately (as it's not an integral part of the module). Here, the module current is typically 1.5mA, which is negligible if left on during game play.

The next important number is the current draw of the LCD's LED backlight. For the module shown, it's a modest 15mA - modest, but 10× the draw of the logic. This can be controlled for a significant reduction in power useage. Since this will be controlled by a transistor or MOSFET, control this with a PWM output and make the brightness adjustable.

The 15mA draw of this backlight is quite modest. I have some beautiful bright 4×20 modules that want 240mA for the backlight. Huge current drain, but they look so nice!

MrDEB, don't forget the LED's current limiting resistor!


Screenshot_20180311-075631.jpg
 
These posts can be very difficult to ignore :lurking: Guess we all have various ways and means , 4x4 pad is one where there are many possible solutions... I found using a I2C port expander works extremely well with either pad and or lcd ( asm or C ) and can have the added benefit of a single interrupt for any key pressed and no need for mcu to scan...
I2CEX.JPG
 
Last edited:
I am a huge believer in port expanders (MCP23017 and MCP23008) and LED driver chips (usually the MAX7219). Let them take care of the heavy lifting and leave the micro free to do what it needs to without a bunch of busy work.
 
for the modest amount of current draw, an NPN transistor is on the menu as they are considerably cheaper. I haven't forgot the backlight resistor.
Looking at Dave Soze schematic(post#59), I see no backlight connection? and the code is really long compared to using Swordfish.
 
MrDEB, don't forget the LED's current limiting resistor!

He may want check for one first I don't think I've got a LCD in the past 4 years that didn't have one made in to the board soldered on the back close to the led you can even tell by looking it inline with it make sure it's not 0 ohm some are LOL on older LCD with backlights But most newer ones have a 220 to 330 ohm on them.

Or we be here for a year why my LCD so dim.
 
I see no backlight connection? and the code is really long compared to using Swordfish.
Don't really need backlight much most are readable without one.
That's cause he took the time to write his own
That includes the needed library's
See mom know backlight

 
Last edited:
Better to have a location for an in-line resistor and jump it out if not needed then not to have it.
 
Jon Not what i said if he doesn't check for one then adds a big ass resistor it them not light up what's going to happen.
He needs to check the lcd first to see if he needs one next problem will be his 3 volts as pointed out .

He would probably be better getting a LCD that is 3 volt they are a lot easier to find nowadays

lcdc2.png
 
Looking at Dave Soze schematic(post#59), I see no backlight connection? and the code is really long compared to using Swordfish.
OK, MrDEB we should discuss the true size of code.
Code:
LCD.bas             Lines: 494
keypad.bas          Lines: 119
System.bas          Lines: 125
utils.bas           Lines: 417
setdigitalio.bas    Lines: 232
convert.bas         Lines: 807
MrDEB.bas           Lines: 65
--------------------Total: 2259
Code:
lcd.c               Lines: 324
lcd.h               Lines: 68
keypad.c            Lines: 217
keypad.h            Lines: 48
tick.c              Lines: 23
tick.h              Lines: 13
init.c              Lines: 130
init.h              Lines: 49
main.c              Lines: 143
main.h              Lines: 11
--------------------Total: 1026
When you look at all of the code, Swordfish BASIC has more than twice the number of lines of code.

As for the LCD back light my LCD module does not have one so my schematic symbol for an LCD module does not have one either.

We could quibble for months over choices of pin assignments and firmware implementations. I would submit that my choices resulted in working prototype hardware in a few days, functional enough to take measurements of the power required and predict a maximum operating time on batteries.

I have taken a long look at the Swordfish BASIC compiler. It does come with many library implementations to support a variety of peripherals. For my development methods Swordfish BASIC is not useful enough.

I wish you luck with your project, hope you do not get lost chasing irrelevant details and can complete a functional prototype soon.
 
Last edited:
...Jon Not what i said if he doesn't check for one then adds a big ass resistor it them not light up what's going to happen...

Bert, will you please get over taking everything I say as a challenge, insult or attack?

All I said was it's a good idea to have a position for a resistor just in case it's needed. Not all LCDs have the resistor built in.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top