Multiple functions by a single switch - Page 3

•  By: Dave Purola Yesterday 21:27 Forum: Proton Plus Compiler v3 Starter: glenlivet Views: 0 Replies: 9 I need to drive 2 separate 4-line displays (Hantronix HDM16416L). I'm using a common system wide data bus (RD0-RD7) to talk to all of the parallel bus chips in the system. It seems that in the LCD Declares I can only assign one RS pin and one Enable pin without the compiler bitching about it. Sure- I can use some logic gates and another cpu pin or... If you are interested please email me: n8nta@yahoo.com.

# Thread: Multiple functions by a single switch – 37 days old

1. 0

## Re: Multiple functions by a single switch

Pin is set to 0
TRISB= % 00000000

2. 0

## 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.

3. 0

## Re: Multiple functions by a single switch

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

4. 0

## 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

5. 0

## 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. 0

## Re: Multiple functions by a single switch

Try DG3 = DG - 1

7. 0

## Re: Multiple functions by a single switch

Thanks See_Mos
It worked.but how?

8. 0

## 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

9. 0

## 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

10. 1

## Re: Multiple functions by a single switch

11. Ok.i will try this.

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

#### Posting Permissions

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