Shop OBEX P1 Docs P2 Docs Learn Events
How to make several menu options with a pushbutton and two RCTIME POTs?? — Parallax Forums

How to make several menu options with a pushbutton and two RCTIME POTs??

Turnbull2112Turnbull2112 Posts: 65
edited 2011-08-26 23:59 in BASIC Stamp
I have a device using a BS2 that performs a few operations and there are some setpoints that need to be adjustable. I have to POTs and caps that are running an RCTIME loop and there is a pushbutton input to the stamp. The stamp also feeds a serial LCD display and I can presently press the button and display a "setpoint" screen that shows the two scaled RCTIME values. Is it possible to represent multiple setpoints with one RCTIME variable by pressing the button one, two or three times to reveal different menus? How do I disassociate the RCTIME value from a direct comparison? Do I write to memory locations? How do I go about this? Thanks,

Comments

  • Tracy AllenTracy Allen Posts: 6,662
    edited 2011-08-24 10:26
    You can use that one pushbutton either with multiple pushes within a time frame, or by holding down the button for a long time to step through options. Feedback on the screen shows the user where they are in the "menu". There are examples of button manipulation, I know I put several in the Applied Sensors text, wherein navigation of options has to work with only one pushbutton and one LED.

    I don't understand what you mean by "disassociate the RCTIME value from a direct comparison".

    To write your set points to memory, use the WRITE and READ commands to an address, starting at address zero. (The program code works down from address 2047, and data works up from address 0).
    '{PBASIC 2.5}
    setpoint1 DATA  Word 1234  ' default setpoints at compile time, each occupies 2 bytes
    setpoint2 DATA  Word 2341
    setpoint3 DATA  Word 3412
    
    setpoint VAR word
    
    main:
         DEBUG CR,"enter set point 1: "
      DEBUGIN DEC setpoint
         WRITE setpoint1, Word setpoint
         READ setpoint1, Word setpoint
         DEBUG CR, DEC setpoint
      END
    
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2011-08-24 12:39
    Hello,

    I don't mean to distract you from your current question of using the two POTs and button for menu navigation. If that is how you want or need to do it then we can certainly help. I did want to mention that Parallax carries a rotary encoder and, combined with a push button can allow you an almost infinite menu/parameter based system. If you would like some more info on this, please say so, or if you'd like more information on using the pots and RCTIME, please say so. Bear in mind that the encoder would be more responsive and less glitchy.
  • Beau SchwabeBeau Schwabe Posts: 6,560
    edited 2011-08-24 15:07
    As Chris mentions, a rotary encoder would work, but it sounds like you only have 3 I/O's to work with (<- A button, and two POTs) so we need to also take that into consideration.


    Assuming only 3 I/O's, then you could use this encoder ... http://www.parallax.com/Portals/0/Downloads/docs/prod/compshop/27804-AbsBinRotaryEndcoder-v1.1.pdf ... and omit the "D" output. This would give you 8 detectable positions, instead of the 16 positions it's capable of.

    We also have a quadrature encoder that would only require 2 I/O's and an provide an infinite number of positions. The caveat using a single threaded processor is that if you rotate the shaft too quickly you could miss a position event. ... http://www.parallax.com/StoreSearchResults/tabid/768/txtSearch/encoder/List/0/SortField/4/ProductID/681/Default.aspx


    Alternatively you could adapt a scheme that uses a single push button. Here is a link that describes how to set the time on a clock using only one button. In the Example a Propeller is used, but this concept could be implemented on any of our micro controllers.
    http://forums.parallax.com/showthread.php?123829-DS-1302-Set-Date-and-Time-using-Push-Buttons
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2011-08-25 09:28
    My thoughts were that 3 I/O pins is exactly enough to handle all menu functions, unless there is a reason to have two adjustment devices. But seeing might help make my point a bit better so here's a video of some friends/colleagues using an encoder with a button to handle the parameters on a SID Organ using a Propeller. The concepts presented here could work on a BASIC Stamp design as well as I show in both the Solder Pot Controller and the Binary Digital Alarm Clock, in which the prototype used an encoder with a button to set the date/time/alarm. Enjoy!
  • Turnbull2112Turnbull2112 Posts: 65
    edited 2011-08-26 09:18
    Thank you all for your responses!! I am running some tests with READ/WRITE today to see how this will work out. Are the settings written to memory volatile? The machines I am building are monitoring oxygen generators and these setpoints are all the alarm and timing parameters. If there is a power failure it would be great if all the settings were retained. I would like to use the encoder in a later revision but I have a couple hundred units in production now with the buttons and pots. Again thank you!!
  • ercoerco Posts: 20,256
    edited 2011-08-26 12:47
    Data stored via a WRITE statement is non-volatile, it survives power-down and stays until you overwrite it.

    Regarding your pots & pushbutton inputs, review Tracy's great info on "one pin, may switches" at the bottom of the page at http://www.emesystems.com/BS2rct.htm

    Another possibility is instead of a pot, you use a rotary switch with multiple positions, which taps into a resistor string. Sort of a pot with discrete hard values. Properly used, it can make selection easier than a simple rotary pot. For instance here's a switch at Radio Shack:

    http://www.radioshack.com/product/index.jsp?productId=2062536 6-position, 2-pole (2 wipers)

    You don't need the two-pole, but that shows whats available at the Shack. A little legwork and you can find a 1-pole, 10 position switch which would work quite nicely.

    http://www.surplussales.com/Switches/SWRotaryAll-1.html

    http://www.futurlec.com/SwRotary.shtml
  • Turnbull2112Turnbull2112 Posts: 65
    edited 2011-08-26 16:59
    This is turning out to be a bit more complicated than I expected. How can I use the pushbutton to scroll through a menu with two displayed variables on each screen and be able to adjust the variables with the two pots? The issue is that if I scroll through I may change the setting just by looking at the options. How can I scroll through the screens and enable the pot to write the setting to EEPROM using just the one button? Am I confusing the issue?? Short example below,

    DO
    HIGH 1
    PAUSE 100
    RCTIME 1,1,SP

    Normal screen
    SEROUT 3,33,["RUNNING"]
    IF PB1 = 1 for 2 seconds THEN
    SEROUT 3,33,["CALIBRATION SCREEN 1",DEC3 SP] 'this setting would be written to EEPROM to be used as a variable for an alarm timer.
    IF PB1= 1 for 4 seconds THEN
    SEROUT 3,33,["CALIBRATION SCREEN 2"DEC3 SP] 'this setting would be written to another EEPROM addr as a variable but would be adjusted by the same RCTIME variable.
    This is what I was trying to ask in the first post about "disassociating" the RCTIME variable "SP" to be used for multiple adjustments. Is this even possible??

    Thanks
  • ercoerco Posts: 20,256
    edited 2011-08-26 17:36
    Study how the menus on most any TV, camera, or consumer product work. Watches and clocks are among the worst examples of user-friendliness, but they do it with just a few buttons and a minimal display.
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2011-08-26 23:59
    If I understand your question, you'll have a loop with RCTIME which is reading the pot and populating a variable with that value. Within the loop you'll monitor the push button. Once pushed you can exit the loop, save your variable into NV storage (EEPROM) and then lookup the value in a table to see what selection you have or value for a parameter. In some (most) cases you'll need to scale your readings to get the range of values you want for a given parameter.
Sign In or Register to comment.