Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[SOLVED] How can I multiplex the alphabets on 3 digit 7 segments

Status
Not open for further replies.

mdamor01

Newbie level 6
Newbie level 6
Joined
Sep 5, 2018
Messages
11
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Location
Bangladesh
Activity points
95
Hi everyone,

Using MikroC Pro for pic16f73, I can multiplex numbers [0-9] on 3 digit 7 segments, but can't multiplex any alphabet or any custom segments. I want to multiplex "H" and "L" in port B.

My program is:


Code C - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
int X; // for Analog value
 
unsigned short hex(unsigned short a){
switch(a){
case 0 : return 0x3F;  //For 0
case 1 : return 0x06;
case 2 : return 0x5B;
case 3 : return 0x4F;
case 4 : return 0x66;
case 5 : return 0x6D;
case 6 : return 0x7D;
case 7 : return 0x07;
case 8 : return 0x7F;
case 9 : return 0x6F;  For 9
}}
 
void main()
{
 TRISB = 0x00; //Port B as O/P, use for 7 segments A to G
 PORTB = 0x00;
 TRISA = 0xFF; //Port A as I/P, use for read Analog signal
 PORTA = 0x00;
TRISC = 0x00; // Port C as O/P, use for 3 digit 7 segments common pin
PORTC = 0xFF;
 
while(1)
{
 x=ADC_read(0);
 x= ((x*500)/255);
 
PORTB = Hex(x%10);
RC0_bit = 0;  //1st digit
Delay_ms(2);
RC0_bit = 1;
PORTB = Hex((x/10)%10);
RC1_bit = 0;  //2nd digit
Delay_ms(2);
RC1_bit = 1;
PORTB = Hex((x/100)%10);
RC2_bit = 0;  //3rd digit
Delay_ms(2);
RC2_bit = 1;
 
  if (x<=250)
{PORTB = ?????;  //Want to show "L"
RC2_bit = 0;
Delay_ms(2);
RC2_bit = 1;}
  else {
PORTB = ????? ;  //want to show "H"
RC2_bit = 0;
Delay_ms(2);
RC2_bit = 1; }
}
}
// End Program



Regard.
Omar.
 
Last edited by a moderator:

Without telling you the exact answer so you can work it out for yourself:

Write the 'return' values in binary and see which bits correspond with each segment on the display. You should see each binary bit causes one of the segments to turn on or off. Then work out which segments and therefore which bits are needed for 'H' and 'L'. Finally, add those patterns to the instruction that writes to the port.

Note that you can do it by adding the segment patterns to the switch/case statement but because you use the table in a math calculation, it would be simpler to just output the new value directly in your "Want to show" lines.

Brian.
 

Hi Brian,

I know that it is simpler to insurt the new value directly in PORTB lines, But I want to use multiplexer so I can show other value in other digit at the same time.
I try it by adding the switch/case statement and failed in instruction steps.


Code C - [expand]
1
2
3
4
5
6
7
unsigned short hex(unsigned short a){
switch(a){
 
case 10 : return 0x76; //For H
case 11 : return 0x38; //For H
 
}}



Regards.
 
Last edited by a moderator:

All this ***t
Code:
switch(a){
case 0 : return 0x3F;  //For 0
case 1 : return 0x06;
case 2 : return 0x5B;
case 3 : return 0x4F;
case 4 : return 0x66;
case 5 : return 0x6D;
case 6 : return 0x7D;
case 7 : return 0x07;
case 8 : return 0x7F;
case 9 : return 0x6F;
can be replaced with 2 strings
const char b[] = { 0x3F, 0x06, 0x5B, 0x4D, 0x66, 0x6D, 0x7D, 0x07, 0x7F, 0x6F };
return b[a];
 

Hi,

so what´s the problem now?
* displaying alphabets (instead of numbers)
* multiplexing several digits.

Please focus on one problem.

Klaus
 

Did you realize that there is a syntax error at the 14th line of the code at post #1?
 

Yes, its typing mistake here.:thumbsup:
case 9 : return 0x6F; //For 9

- - - Updated - - -

Hi Klaus

Multiplexing several digit (to display alphabet)

I can display same alphabets on one digit or all digit, but now i want to display 2 different alphabets on 2 different digit at the same time and i think it should be used by multiplexer.
Or
You can check post #1, there what should be the line 45 and 50 ?
Note that, it can be simply done by Portb = 0x76; // to disply H but i want same result using multiplexing rules.

Regard.
 

Hi,

I don´t know whats the problem.

You have the table for numbers 0..9 (post#1, line 5...14)
you have the values for "L" and "H" (post #3)

--> just add the two lines of post#3 to the table of post#1.

then use the values 10 and 11 to display "H" and "L" respectively.
--> PORTB = Hex(10); or PORTB = Hex(11);

Klaus
 

He wants to display say H on one digit and L on another digit of the multiplexed 2 digits 7 Segment display. He needs to use timer interrupts for multiplexing.
 

Timer interrupts would certainly make it simpler but Klaus's method works as well as for the other digits if the appropriate "RCx" pin is used to activate the digit. At the moment, only RC2 is used so the position of the H or L is fixed by the code.

Brian.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top