Netduino home hardware projects downloads community

Jump to content


The Netduino forums have been replaced by new forums at community.wildernesslabs.co. This site has been preserved for archival purposes only and the ability to make new accounts or posts has been turned off.
Photo

Six Button Interface for LCD Menu System.


  • Please log in to reply
18 replies to this topic

#1 Stuart Crawshaw

Stuart Crawshaw

    Advanced Member

  • Members
  • PipPipPip
  • 60 posts
  • LocationLeeds, United Kingdom

Posted 19 July 2011 - 02:51 PM

Hi all,

Here is the outline,

I want to have a menu system accessible by buttons on my project. The display will be a 20x4 LCD Display and there will be 6 buttons as follows:

  • UP
  • DOWN
  • LEFT
  • RIGHT
  • OK
  • CANCEL

Now the basic idea of how these would work is have an interrupt port setup for each button (but thats 6 ports!). So now the question,

How could i achieve this, but only use the minimal number of ports?

I though about using a PISO Shift Reg, but then remembered it would need a clock etc and someway for the ND to know that data is coming in (i think).

I then there is the Matrix style setup but i would only save 1 pin (2 cols and 3 rows = 5 lines).

Any suggestions, fancy IC's or fancy components that will let be achive this goal?

Thanks for your continued support.
Stuart
Intelligent People Aren't Afraid To Ask For Help.

#2 Stefan

Stefan

    Moderator

  • Members
  • PipPipPip
  • 1965 posts
  • LocationBreda, the Netherlands

Posted 19 July 2011 - 02:53 PM

A few months ago I published a post about multiplexing: http://forums.netdui...h-the-netduino/ Also HD44780 LCDs can work over 74hc595 IC's.
"Fact that I'm a moderator doesn't make me an expert in things." Stefan, the eternal newb!
My .NETMF projects: .NETMF Toolbox / Gadgeteer Light / Some PCB designs

#3 Stuart Crawshaw

Stuart Crawshaw

    Advanced Member

  • Members
  • PipPipPip
  • 60 posts
  • LocationLeeds, United Kingdom

Posted 19 July 2011 - 02:58 PM

A few months ago I published a post about multiplexing:
http://forums.netdui...h-the-netduino/

Also HD44780 LCDs can work over 74hc595 IC's.


Thanks, i shall have a read through that post,

I currently have the LCD working via a 74HC595 using the SPI bus, so its just the buttons i need to get working in a conservative fasion.

So, Ill have a read and get back to you.

Thanks again. :D
Intelligent People Aren't Afraid To Ask For Help.

#4 Stefan

Stefan

    Moderator

  • Members
  • PipPipPip
  • 1965 posts
  • LocationBreda, the Netherlands

Posted 19 July 2011 - 03:05 PM

I currently have the LCD working via a 74HC595 using the SPI bus, so its just the buttons i need to get working in a conservative fasion.

If you want to combine that LCD driver with other SPI devices (which is the case in my sample above) you need to use another LCDTransferProvider. I got one ready for that. Will upload it later today.
"Fact that I'm a moderator doesn't make me an expert in things." Stefan, the eternal newb!
My .NETMF projects: .NETMF Toolbox / Gadgeteer Light / Some PCB designs

#5 Stuart Crawshaw

Stuart Crawshaw

    Advanced Member

  • Members
  • PipPipPip
  • 60 posts
  • LocationLeeds, United Kingdom

Posted 19 July 2011 - 03:10 PM

If you want to combine that LCD driver with other SPI devices (which is the case in my sample above) you need to use another LCDTransferProvider. I got one ready for that. Will upload it later today.


If i understand that correctly, i couldnt use the multiplexing solution as well as have an LCD on the SPI bus?

I read your post and it looks AMAZING! Just want i was looking for, but on a smaller scale :P.
Intelligent People Aren't Afraid To Ask For Help.

#6 Stefan

Stefan

    Moderator

  • Members
  • PipPipPip
  • 1965 posts
  • LocationBreda, the Netherlands

Posted 19 July 2011 - 03:18 PM

If i understand that correctly, i couldnt use the multiplexing solution as well as have an LCD on the SPI bus?


You will get an error because both will try to initialize the SPI bus. I made a MultiSPI-class that covers that issue and wrote a seperate LCDTransferProvider for that.

I read your post and it looks AMAZING! Just want i was looking for, but on a smaller scale :P.


Thanks :D
"Fact that I'm a moderator doesn't make me an expert in things." Stefan, the eternal newb!
My .NETMF projects: .NETMF Toolbox / Gadgeteer Light / Some PCB designs

#7 Stuart Crawshaw

Stuart Crawshaw

    Advanced Member

  • Members
  • PipPipPip
  • 60 posts
  • LocationLeeds, United Kingdom

Posted 19 July 2011 - 03:34 PM

You will get an error because both will try to initialize the SPI bus.


The code I have would (in thory) use a centralised "shared" SPI bus (a static property of the main program, initialized on startup). Could i not modify it to work with the "shared bus"?
Intelligent People Aren't Afraid To Ask For Help.

#8 AJB2K3

AJB2K3

    Advanced Member

  • Members
  • PipPipPip
  • 46 posts

Posted 19 July 2011 - 04:37 PM

Back in the 90's the Parralax stamp used 1 pin for 8 switches.
Bad fritzing but will give you an idea.
Posted Image
Posted Image

In this example (cant find single pin of gnd plane :huh: )
The resistors are connected to an analoge in pin and the capacitor end is connected to gnd (or however the netduino handles it)

The whole thing reads as a potentiometer so is simple to work.
Going by what I have lurned so far you may be able to drop the cap.

I hope this helps with your button issue.

"Maybe it's because you're a crap programmer"


#9 Stuart Crawshaw

Stuart Crawshaw

    Advanced Member

  • Members
  • PipPipPip
  • 60 posts
  • LocationLeeds, United Kingdom

Posted 19 July 2011 - 04:47 PM

Back in the 90's the Parralax stamp used 1 pin for 8 switches.
Bad fritzing but will give you an idea.

In this example (cant find single pin of gnd plane :huh: )
The resistors are connected to an analoge in pin and the capacitor end is connected to gnd (or however the netduino handles it)

The whole thing reads as a potentiometer so is simple to work.
Going by what I have lurned so far you may be able to drop the cap.

I hope this helps with your button issue.



Thats an interesting idea, thank you.
Ill keep this in mind, wouldn't this idea how ever require some slight pre-programming of the values per switch and also, if i press multiple switches at once, would this not cause an issue?
Intelligent People Aren't Afraid To Ask For Help.

#10 AJB2K3

AJB2K3

    Advanced Member

  • Members
  • PipPipPip
  • 46 posts

Posted 19 July 2011 - 05:01 PM

Thats an interesting idea, thank you.
Ill keep this in mind, wouldn't this idea how ever require some slight pre-programming of the values per switch and also, if i press multiple switches at once, would this not cause an issue?


I would assume so, Maybe some sort of array would be required, yes multiple presses would be an issue as this circuit being used without care could create false reading.

I'm still learning electronics after a 7 year leave and this is a 13 year old circuit! (OMG thats old!)

Fyi All the resistors are supposed to be the same value!

A copy of the old note for you information.

"Maybe it's because you're a crap programmer"


#11 Stefan

Stefan

    Moderator

  • Members
  • PipPipPip
  • 1965 posts
  • LocationBreda, the Netherlands

Posted 19 July 2011 - 05:20 PM

The code I have would (in thory) use a centralised "shared" SPI bus (a static property of the main program, initialized on startup). Could i not modify it to work with the "shared bus"?

Yes you can, or use a modified version which saves you some time, your choice :)
Another benefit of the class I wrote is that it can combine multiple 74HC595s daisychained with only one latch pin, enabling more outputs without occupying more pins on the netduino. I even got multiple LCD's connected with one latch pin:

http://www.youtube.com/watch?v=TiGW1MJF3Zc

See attachment for the class.

Attached Files


"Fact that I'm a moderator doesn't make me an expert in things." Stefan, the eternal newb!
My .NETMF projects: .NETMF Toolbox / Gadgeteer Light / Some PCB designs

#12 Stefan

Stefan

    Moderator

  • Members
  • PipPipPip
  • 1965 posts
  • LocationBreda, the Netherlands

Posted 19 July 2011 - 05:23 PM

Thats an interesting idea, thank you.
Ill keep this in mind, wouldn't this idea how ever require some slight pre-programming of the values per switch and also, if i press multiple switches at once, would this not cause an issue?

Actually, you can do that as well. But it's much harder to detect when multiple buttons are pressed. I would not prefer that way, personally.
"Fact that I'm a moderator doesn't make me an expert in things." Stefan, the eternal newb!
My .NETMF projects: .NETMF Toolbox / Gadgeteer Light / Some PCB designs

#13 Dan Morphis

Dan Morphis

    Advanced Member

  • Members
  • PipPipPip
  • 188 posts

Posted 19 July 2011 - 05:41 PM

I want to have a menu system accessible by buttons on my project. The display will be a 20x4 LCD Display and there will be 6 buttons as follows:

  • UP
  • DOWN
  • LEFT
  • RIGHT
  • OK
  • CANCEL


Why not buy an LCD which has all that available? I can't recall the LCD I have at the house, but its 20x4 (IIRC), up,down,left,right,ok,cancel and fits in a 5 1/4" drive bay. I bought it quite a few years ago, so I don't recall the brand off the top of my head, but they had a serial and LCD version. But I will look tonight.

The Matrix Orbital 212 is US $78 which has 7 buttons, 20x4 and fits in a 5.25" drive bay.

-dan

#14 AJB2K3

AJB2K3

    Advanced Member

  • Members
  • PipPipPip
  • 46 posts

Posted 19 July 2011 - 06:06 PM

Actually, you can do that as well. But it's much harder to detect when multiple buttons are pressed. I would not prefer that way, personally.


Just had a re read of the notes and rechecked the diagrams, the circuit will only read the lowest button pressed ( in the event of multipress) due to the way electricity flows.

"Maybe it's because you're a crap programmer"


#15 Mario Vernari

Mario Vernari

    Advanced Member

  • Members
  • PipPipPip
  • 1768 posts
  • LocationVenezia, Italia

Posted 20 July 2011 - 03:51 AM

Just FYI, the analog circuit above (switches and resistors) won't work at all. Even corrected, it has some limitations respect the HC595 version. For example, by pressing two buttons together it's hard to detect for the Netduino. Using the 595 is trivial. A vote up for the Stefan's tip! Cheers
Biggest fault of Netduino? It runs by electricity.

#16 Mike P

Mike P

    Advanced Member

  • Members
  • PipPipPip
  • 41 posts
  • LocationAuckland, New Zealand

Posted 29 August 2011 - 01:37 PM

The resistor network works pretty well. I have a DF Robot shield which uses this. That shield has Up,Dn,Left,Right,Select and Reset(The ultimate cancel?) One thing that may be a limitation is that it needs to be polled. You can't trigger an interrupt from an analog input pin. but you could use 2 pins, one as an interrupt port and the other as an analog input and feed the signal into both. for a digital IO pin voltages over 2.0v are a logic high so arrange the reseistor network so that a voltage of 0v for no keys pressed and voltages of 2.0 - 3.3v for the 6 keys. That's 260mv spacing. I haven't done the math but that sound like plenty of discrimination. The digital pin would be used to trigger an interrupt on a rising edge. Multiple keys being pressed simultaneously can be detected as long as the first key has a lower voltage than the second key. Usually when you use multiple keys simultaneously you hold one and press the second. I think that you should be able to implement more than 6 keys with interrupt on keypress and using only 2 pins.

#17 Mario Vernari

Mario Vernari

    Advanced Member

  • Members
  • PipPipPip
  • 1768 posts
  • LocationVenezia, Italia

Posted 29 August 2011 - 02:31 PM

@Mike P: could you post the actual schematic?
The above Fritzing/schematic absolutely can't work.

EDIT: I have a peek at the Parallax technique for reading the button pressed, but it is not simple as the Netduino can do.
You should set the pin as an Output (high), so that the capacitor will charge. After a *precise* delay, the Output should switched as AnalogPort, and read the value.
I confirm that the circuit can't be applied to the Netduino.
If you don't like the Stefan's idea, you might use a resistor network as well, but connecting the resistors differently.
Biggest fault of Netduino? It runs by electricity.

#18 Mike P

Mike P

    Advanced Member

  • Members
  • PipPipPip
  • 41 posts
  • LocationAuckland, New Zealand

Posted 30 August 2011 - 04:12 PM

Now I've got to put my money where my mouth is! This should work but untested Attached File  6key IF_bb.png   42.54KB   61 downloadsAttached File  6key IF_schem.png   47.5KB   62 downloads I tried to put a table in below but the TABs get stripped out so it's in CSV form instead. The table below gives the resistor values, The total resistance when the button is pressed, The voltage on the analog input, The ADC reading, The difference between the ADC value for this button and the next one up, and the suggested cut-off value to use when deciding which button has been pressed I even managed to keep to common value resistors and get very even separation between the voltages. Vcc=3300mV Button,Resistor,Total R,mV,ADC,delta,cutoff Cancel,1500,1500,3300,1024,,986 Right,120,1620,3056,948,76,908 Left,150,1770,2797,867,81,827 Down,180,1950,2538,787,80,747 Up,220,2170,2281,707,80,668 Select,270,2440,2029,629,78,315 None,,,0,0,629, In the schematic the second analog input pin would actually be used as a digital interrupt pin and could be on any of the GPIO pins. Its not necessary if you don't mind polling the analog input continuously.

#19 Mario Vernari

Mario Vernari

    Advanced Member

  • Members
  • PipPipPip
  • 1768 posts
  • LocationVenezia, Italia

Posted 31 August 2011 - 04:04 AM

Okay, *THAT* circuit works...not the first one! Cheers
Biggest fault of Netduino? It runs by electricity.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

home    hardware    projects    downloads    community    where to buy    contact Copyright © 2016 Wilderness Labs Inc.  |  Legal   |   CC BY-SA
This webpage is licensed under a Creative Commons Attribution-ShareAlike License.