Menu "blues"

manie

Senior Member
Although the "one wire" analogue keypad works OK, getting the actual characters correctly read into memory needs a bit of software fine tuning. I got that sorted out tonight. I was a bit surprised as to the magnitude of switch bounce and the effect on the analogue voltages. I ended up soldering a 120pF cap across the last resistor for some smoothing. The main work is done in the software though but is quite nice now.

I started writing the software for a menu driven unit to talk to the main chook-house controller. Man, it needs some coding ! But that is working OK now. Here is a pic of the Main Menu.

Any "easy" code for menu's out there ?
 

Attachments

KIGX

Member
Hi Manie,

You're really going to town on this :)

I did a similar itemized menu on an LCD but I used a TV IR remote to send the codes and INFRAIN to catch them. Not as slick as your keyboard but less code intensive I would suspect.
 

lbenson

Senior Member
It's part of other code, but BeanieBots has 2-button LCD menu control in his thread, "Pb switchmode charger/discharger":

http://www.picaxeforum.co.uk/showthread.php?t=10986

With your keyboard, you have many more than the two input options, but the code might help.

Since you can enter numbers, do you need more than nested select/case statements?

Code:
menutop:
  gosub display-mainmenu
  gosub get-key-entry ' returning, for instance, b13 with values of 1, 2, or 3 (perhaps 0 to go back)
  select b13
    case 1
      gosub display-submenu ' based somehow on the value of b13
      gosub get-key-entry
      select b13
        case 1
          ' do something or present another submenu
        case 2
        case 3
        else
          goto menutop
      endselect
    case 2
    case 3
    else
  endselect
 
Last edited:

manie

Senior Member
Ibenson: Exactly what I'm doing, I was hoping there is someone more clever out there, I have one "readkey" subroutine to read the actual keystrokes and then a Select/case 12 deep to decode and assign values to some var's.

KIGX: IR remote ! I'd say thats nifty, how involved is the decoding for key presses ?
 

KIGX

Member
Manie,

Not too sure of your question - each button on the IR remote has a code associated with it, ie, built into the remote. The codes are 'numeric' and run from 0 to 120 or so (?). The PICAXE uses a Sony remote and therefore Sony codes. The INFRAIN command is very similar to SERIN except the PICAXE waits to receive a code from the infrared detector. The PICAXE automatically decodes the code sent. For example, the button 1 on the remote is decoded by the PICAXE to be a 0. Button 2 is a 1. Increase vol is something like 116. On an 18X, INFRAIN stores the code in the variable INFRA. You can then use INFRA as you would any other PICAXE variable. Such as:

If INFRA = 7 then go do this:

or

Use infra in branching statements, etc.

EDIT: Maybe button 1 isn't zero, can't remember now but button 0 is 11 not 0. It's easy to find out, just INFRAIN codes and sertxd them to see what they are... You just need to match the numbers you use on the LCD to the real numbers on the remote to make it user friendly.
 
Last edited:

manuka

Senior Member
Manie: Go IR! Thanks to their inbuilt "INFRA" etc commands, 08Ms near revolutionised both sending & receiving of IR data. With universal IR remotes being almost coin shop items now (I picked up a great one here in NZ recently for ~US$5), use of one for poor mans keypad duties makes real sense. Why you could almost grab a few convex lenses & directly beam it out the door at the chookhouse.

Check sample IR usage in such past programs as => www.picaxe.orconhosting.net.nz/irsense.bas
 

manie

Senior Member
Stan: Your code shows "If > 9 then error". Does that mean that "1" on remote is understood by Picaxe to be "1" (numeric) etc. ? Surely, it can't be THAT EASY ! Why the heck am I doing battle (no, waging war...) with decoding voltages etc. ? Its sorted now, keystrokes decoded VERY well, backspace(*) and Enter(#) and all ! Could have saved some time with such easy IR remote though...

Anyways, the menu/sub menu system is starting to work well too, just some fine tuning and the keypad/display module will have two comms with Main controller which will have four-way comms (with keypad module and PC via RF).

I now believe that anything is possible if I got this far and its still going reasonably well.

Edit:
What would be a good IR receiver and where is it well priced ?
Disregard, I saw the IR thread further down and got the answer there. It will have to be the 38KHz unit for Sony standard yes ?
 
Last edited:

manuka

Senior Member
Manie- I'm unsure if this means you've now gone IR, or have managed success with a keyboard. On my cheap IR remote PICAXE infra (a.k.a. b13) returned values were one number removed from the IR remote key push value I recall. Just go the classic 3 leg VISHAY style 38-40kHz for IR rx- the 08M reads this directly. READ THE MANUAL! They're a standard PICAXE accessory costing ~ US$3. It really couldn't be simpler.
See one in my "dual PICAXE" layout =>http://picaxe.orconhosting.net.nz/duo08m2.jpg

(Extra: Hope your new RSA government reduces import duties for you. At least the PMs name is easy to spell!)
 

moxhamj

New Member
Hey, looking good!!

That display is big enough to actually put some meaningful text on the screen. A thought re menu software - some mobile phones are easier to navigate than others. I like the idea where you have a 'back' key which works in every menu and takes you back up one level. Maybe even make it option 3 on every menu screen. Or button 9 and don't necessarily display that on the LCD but put it on the keypad. Then, no matter how deep in the menu you are, if you are lost, you can always hit 'back' a few times and get back to the main menu.

I'm looking forward to seeing this in the 'completed projects' section. Great work.
 

hippy

Ex-Staff (retired)
Stan: Your code shows "If > 9 then error". Does that mean that "1" on remote is understood by Picaxe to be "1" (numeric) etc. ? Surely, it can't be THAT EASY ! Why the heck am I doing battle (no, waging war...) with decoding voltages etc. ? Its sorted now, keystrokes decoded VERY well, backspace(*) and Enter(#) and all ! Could have saved some time with such easy IR remote though...
There are numerous options for receiving input; keypad matrixing, keypad matrix to single or multiple ADC lines, INFRAIN and KEYIN, even off-loading the interfacing to another PICAXE and using serial, PULSIN or I2C.

Most raw key input values can be swiftly mapped to a more usable value with a LOOKUP or READ of a lookup table in Data Eeprom. It's often possible to rewire the controller to send the data as required.

Ultimately you will have a "GOSUB ReadKeyPressValue" or similar which returns the values for each key as you'd like them to be and it doesn't really matter what interface is used, though they each have their pro's and con's.

One potentially handy project is a PC keyboard connected to a PICAXE and IR LED. That simply runs a KEYIN, lookup value, and INFRAOUT loop. Any project needing input can then use INFRAIN, INFRAIN2 or IRIN in the "ReadKeyPressValue" routine and the keyboard PICAXE programmed with the desired mapping lookup table to send the required key press values. Once everything is working, "ReadKeyPressValue" can be rewritten to use whatever input hardware you want to actually use.

This is the technique of "abstraction" and "modularisation"; allowing specifics not to have to be worried about, allowing focus and progress to be on the primary task at hand. It also allows code to be developed on hardware different to that used in the specific project and code to be developed by others. Regardless of what hardware "ReadKeyPressValue" uses on a specific platform, the same code should work on any.

One can also build a SEROUT version and use SERIN if an IR receiver isn't desirable, or build a separate module which reads INFRAIN from the keyboard and converts that to SEROUT. These are tasks in which the PICAXE excels and is well suited to; a few minutes work, half a dozen lines of code. Built once, used often, they can be invaluable for getting new projects off the ground in very short times.
 

manie

Senior Member
Stan: The matrix keypad on an ADC input using essentially "one wire" (and 0V common) is working perfectly now. However, thinking of mounting the keypad in a suitable enclosure etc. does make the "cheap" IR remote units with IRIN on a Picaxe VERY attractive. There is such a LOT of stuff I have to get my head around still ! I have background "white noise" regarding all the features and commands in my head, I look at specific detail when I think to use something specifically. But that is what makes this forum GREAT ! "The Truth is Out There".... we noobs just need to be pointed in the right direction like this thread has done. ny modification to this project will be SURE to include IR... EDIT: This is a "republic", Pres. is the CEO, its all a circus and the clowns, white-faced and others, are running rife ! "New" gov ?? Were there elections ("free and fair"....) somewhere ? Thats why Boswell-Wilkie does not exist anymore, the circus is in town everyday..........

Hippy: This module is essentially the user-interface, with user-input(keypad) and system output (LCD/RS232 comms). With the experience gained on this whole chook-house project I've come to realise that dedicated function modules will INDEED be a bonus. For now, I'll get this finished and installed and working in the chook-house. It is the "proto" type and I'm sure will show up some design defects. In a modular system these will be easier to correct and replace.

The Senior Members such as yourself/Stan/Westy/Eclectic/Jglenn/Dr.A/Boriz/Womai/ and..... all the members with superior knowledge to us "new starters" must feel terribly IRRITATED by answering the SAME OR SIMILAR questions in different guise, every time. I do realise this and for that I ONCE AGAIN SALUTE YOU ALL !!!!!! To us newbies and not-so-newbies however, it is journey of exploration and discovering NEW THINGS all the time. Like in the posts above.........

Dr.A: I might just put this in the "Completed Projects" section, but NOT as a Look_What_I_Did.... RATHER as a What_I_Should_Have_Done.... Yes, it is comming together and working but could have been done quicker and easier as Hippy explains in his post above. But that is the reason why I try and remain an ACTIVE member and an active electronics EXPLORER. I'm learning such a lot and I hope others, especially younger people are too. I've waited too long before I started with things like the Picaxe.
 
Last edited:
Top