Multiple functions by a single switch - Page 3


Today 11:49
Forum: The Lounge
Starter: Oldhack
Views: 0
Replies: 41
Today 09:08
Forum: The Lounge
Starter: normnet
Views: 0
Replies: 1
Today 00:13
Forum: The Lounge
Starter: _Gabi_
Views: 6753
Replies: 24
+ Reply to Thread
Page 3 of 4 FirstFirst 1234 LastLast
Results 21 to 30 of 34

Thread: Multiple functions by a single switch32 days old

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

    0 Not allowed!

    Default Re: Multiple functions by a single switch

    Pin is set to 0
    TRISB= % 00000000

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

    0 Not allowed!

    Default Re: Multiple functions by a single switch

    See pages 61 To 63 of the compiler manual For an explanation of logical operators

    DG3=128 | DG And DG3 = DG + 128 will work If the decimal point in On PORTB.7

    DS3=128 & DG does not work.

    The way logical operators work has no connection with the device type so that cannot the problem.
    Last edited by See_Mos; 18th November 2018 at 16:02.
    My RAM is failing

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

    0 Not allowed!

    Default Re: Multiple functions by a single switch

    My decimal pin is on B0. When I write DG3=254+DG whole digit goes blank

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

    0 Not allowed!

    Default Re: Multiple functions by a single switch

    OK, that explains the problem.

    does the segment drive use NPN transistors to drive common anode display?

    Tell us which segment connects to which pin of PortB
    Last edited by See_Mos; 18th November 2018 at 17:43.
    My RAM is failing

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

    0 Not allowed!

    Default Re: Multiple functions by a single switch

    Iam using PNP 557 trassistors.

    segment PORT pin
    Decimal point B.0
    G B.1
    F B.2
    E B.3
    D B.4
    C B.5
    B B.6
    A B.7


    My seven segment display code(working properly)

    'code to light up each segment
    '_________________________________________________ _________________________
    FND:


    FND0:
    If DIGIT>0 Then FND1 'zero
    DG=%00000011
    GoTo FNDEND


    FND1:
    If DIGIT>1 Then FND2 'one
    DG=%10011111
    GoTo FNDEND


    FND2:
    If DIGIT>2 Then FND3 'two
    DG=%00100101
    GoTo FNDEND


    FND3:
    If DIGIT>3 Then FND4 'three
    DG=%00001101
    GoTo FNDEND


    FND4:
    If DIGIT>4 Then FND5 'four
    DG=%10011001
    GoTo FNDEND


    FND5:
    If DIGIT>5 Then FND6 'five
    DG=%01001001
    GoTo FNDEND


    FND6:
    If DIGIT>6 Then FND7 'six
    DG=%01000001
    GoTo FNDEND


    FND7:
    If DIGIT>7 Then FND8 'seven
    DG=%00011111
    GoTo FNDEND


    FND8:
    If DIGIT>8 Then FND9 'eight
    DG=%00000001
    GoTo FNDEND


    FND9: 'nine
    DG=%00011001


    FNDEND:
    Return
    '______________________________

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

    0 Not allowed!

    Default Re: Multiple functions by a single switch

    Try DG3 = DG - 1
    My RAM is failing

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

    0 Not allowed!

    Default Re: Multiple functions by a single switch

    Thanks See_Mos
    It worked.but how?

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

    0 Not allowed!

    Default Re: Multiple functions by a single switch

    With your seven segment LED's a low powers the LED. Your decimal point LED is on PORTB.0 and all of your character patterns end in 1 so subtracting 1 makes the last BIT value 0

    The correct way to do it is

    DG3 = DG & p11111110

    So taking 4 as the number the pattern is p10011001 now if we & that with p11111110 we get

    ...p10011001
    & p11111110
    = p10011000

    using &
    0 & 0 = 0
    1 & 0 = 0
    0 & 1 = 0
    1 & 1 = 1

    I replace % with p so that the forum editor does not mess up the formatting
    Last edited by See_Mos; 19th November 2018 at 12:26.
    My RAM is failing

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

    0 Not allowed!

    Default Re: Multiple functions by a single switch

    You could replace your FND: code with

    DG = Character_Pattern,Digit

    and placing

    Code:
                            ' BIT pattern for common anode seven segment display
    Character_Pattern:        ' reverse connections segment A is on B.7, DP on B.0
        LData $03,$9F,$25,$0D,$99,$49,$41,$1F,$01,$19
    as the last line of your program. The values are the same as your bit pattern in HEX
    My RAM is failing

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

    1 Not allowed!

    Default Re: Multiple functions by a single switch

  11. Ok.i will try this.

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