Multiple functions by a single switch - Page 2


Today 09:37
Forum: Proton Plus Compiler v3
Starter: gdesantis
Views: 0
Replies: 1
Yesterday 18:35
Forum: The Lounge
Starter: Les
Views: 0
Replies: 11
+ Reply to Thread
Page 2 of 4 FirstFirst 1234 LastLast
Results 11 to 20 of 34

Thread: Multiple functions by a single switch33 days old

  1. #11
    Prolific Poster joesaliba's Avatar
    Join Date
    Sep 2004
    Posts
    2,374
    Thumbs Up
    Received: 86
    Given: 23
    Total Downloaded
    4.04 GB

    0 Not allowed!

    Default Re: Multiple functions by a single switch

    Quote Originally Posted by craig View Post
    Four different functions is to have a counter attached and lets say one press does task 1, Second Press does task 2 and so on.
    You must de-bounce the switch and have a small delay to stop overlapping.

    Regards
    Craig
    The code in post #4 is what it do!
    Regards

    Joseph

  2. #12
    Junior Member amod's Avatar
    Join Date
    Mar 2018
    Posts
    67
    Thumbs Up
    Received: 43
    Given: 4
    Total Downloaded
    5.95 MB

    0 Not allowed!

    Default Re: Multiple functions by a single switch

    Thanks.Joseph code worked for me.

    I want to add 3 digit thumbwheel switch .Any code for this.
    When I enter 333 on thumbwheel switch my counter should stop on 333.

  3. #13
    Prolific Poster joesaliba's Avatar
    Join Date
    Sep 2004
    Posts
    2,374
    Thumbs Up
    Received: 86
    Given: 23
    Total Downloaded
    4.04 GB

    0 Not allowed!

    Default Re: Multiple functions by a single switch

    Can you please explain connection of thumbwheel switch? And when to start the counter? When you press a push or something similar.
    Regards

    Joseph

  4. #14
    Junior Member amod's Avatar
    Join Date
    Mar 2018
    Posts
    67
    Thumbs Up
    Received: 43
    Given: 4
    Total Downloaded
    5.95 MB

    0 Not allowed!

    Default Re: Multiple functions by a single switch

    When I set 111 on thumbwheel switch the counter starts on power on and stops when it reaches 111.pls check photo.IMG_20181113_192813.jpg
    Last edited by amod; 13th November 2018 at 15:34.

  5. #15
    Prolific Poster joesaliba's Avatar
    Join Date
    Sep 2004
    Posts
    2,374
    Thumbs Up
    Received: 86
    Given: 23
    Total Downloaded
    4.04 GB

    0 Not allowed!

    Default Re: Multiple functions by a single switch

    I came up with some code, not tested but should work.

    Two important things: -

    1. Wheel_Value is the value of your thumb wheel. You have to see how to acquire this setting of the thumb wheel and load variable Wheel_Value.
    2. A way to start the counting. In my example I assumed a push will trigger the counter.

    Code:
    Dim Wheel_Cnt As Word = 0
    
    
    Main:
    
    Wheel_Cnt = Wheel_Value     ' Wheel value is the thumb wheel set. 
                                ' It is up to you how you are going to capture this value
                                
     
    If Switch = 0 Then          ' If switch or push is pressed start counter then
        
        Do                      ' Create a loop
            Inc Wheel_Cnt       ' increase Heel_Count
            DelayMS 100         ' some delay as required
        Loop Until Wheel_Cnt = Wheel_Value ' Redo loop until Wheel_Cnt reac Wheel_Value
        
        GoSub Sub_Rtn           ' goto Sub_Rtn
        Wheel_Cnt = 0           ' clear Wheel_Cnt
    EndIf                       ' End If...Then instruction
    
    GoTo Main                   ' Repeat Main routine
    
    '========================================================================================
    
    Sub_Rtn:                    ' Sub_Rtn label
    
    ' Your code for when the counter reach the thumb wheel value
    '
    '
    '
    
    Return                      ' Return from where it was called
    
    '========================================================================================
    Regards

    Joseph

  6. #16
    Junior Member amod's Avatar
    Join Date
    Mar 2018
    Posts
    67
    Thumbs Up
    Received: 43
    Given: 4
    Total Downloaded
    5.95 MB

    0 Not allowed!

    Default Re: Multiple functions by a single switch

    Thanks Joseph,As Iam out of the city,I will definitely try it on Saturday.
    Last edited by amod; 15th November 2018 at 16:59.

  7. #17
    Junior Member amod's Avatar
    Join Date
    Mar 2018
    Posts
    67
    Thumbs Up
    Received: 43
    Given: 4
    Total Downloaded
    5.95 MB

    0 Not allowed!

    Default Re: Multiple functions by a single switch

    Every thing is working fine except decimal point

    my decimal code is working fine in 16f877A but not in 16f886

    DS3:
    GoSub FND
    DG3=128 | DG <----- this does not work in 16f886 but working fine in 16f877A

    my fuse settings are
    ;**** Added by Fuse Configurator ****
    ; Use the Fuse Configurator plug-in to change these settings


    Device = 16F886


    Config1 FOSC_INTRC_NOCLKOUT, WDTE_OFF, PWRTE_OFF, MCLRE_OFF, CP_OFF, CPD_OFF, BOREN_ON, IESO_ON, FCMEN_ON, LVP_OFF, DEBUG_OFF
    Config2 BOR4V_BOR40V, WRT_OFF


    ;**** End of Fuse Configurator Settings ****
    Last edited by amod; 17th November 2018 at 16:00.

  8. #18
    Prolific Poster See_Mos's Avatar
    Join Date
    Feb 2004
    Posts
    1,212
    Thumbs Up
    Received: 18
    Given: 0
    Total Downloaded
    614.99 MB

    0 Not allowed!

    Default Re: Multiple functions by a single switch

    As you are simply adding the decimal point try

    DG3 = DG + 128
    My RAM is failing

  9. #19
    Junior Member amod's Avatar
    Join Date
    Mar 2018
    Posts
    67
    Thumbs Up
    Received: 43
    Given: 4
    Total Downloaded
    5.95 MB

    0 Not allowed!

    Default Re: Multiple functions by a single switch

    It doesn't work.i tried DS3=128 & DG it worked but it disturb the whole display.Decimal point comes but rest segment doesn't work properly.

  10. #20
    Prolific Poster joesaliba's Avatar
    Join Date
    Sep 2004
    Posts
    2,374
    Thumbs Up
    Received: 86
    Given: 23
    Total Downloaded
    4.04 GB

    0 Not allowed!

    Default Re: Multiple functions by a single switch

  11. Which oin of the PIC are you using for the decimal point? Is it set as digital output?
    Regards

    Joseph

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

     

Similar Threads

  1. TCK106AF, TCK107AF and TCK108AF single-chip load switch ICs
    By normnet in forum New devices and techniques
    Replies: 0
    Last Post: 31st March 2016, 23:19
  2. Multiple button on a single ADC port.
    By wirecut in forum Proton Plus Compiler v3
    Replies: 10
    Last Post: 14th July 2014, 19:52
  3. New ADG5419 single-pole/double-throw (SPDT) switch
    By normnet in forum New devices and techniques
    Replies: 0
    Last Post: 5th April 2014, 23:09
  4. Replies: 0
    Last Post: 5th April 2014, 23:09
  5. Multiple PIC's driven from a single reset
    By knight in forum The Lounge
    Replies: 8
    Last Post: 24th October 2010, 08:56

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts