Mithun_K_Das
Advanced Member level 3
- Joined
- Apr 24, 2010
- Messages
- 899
- Helped
- 24
- Reputation
- 48
- Reaction score
- 26
- Trophy points
- 1,318
- Location
- Dhaka, Bangladesh, Bangladesh
- Activity points
- 8,254
I had several 7segment based meters which works fine in hardware. Most of these are regular products, no display problem found yet in last 7yrs+.
Today, I was trying to make a simple simulation based on 7segment display in proteus 8.9. But I found that, it can not display 7segment properly.
Either it shows still non-digits or flickering. I tried changing timing for multiplexing. But can't find the problem.
Can anyone tell me whats wrong here? Again I'm mentioning that, it works in hardware with this 5ms refresh interval. Sometimes little adjustment may required.
It is not working properly in proteus only.
Here is the simplified code which I was testing.
And the proteus file:
- - - Updated - - -
This is happening most of the time.
Today, I was trying to make a simple simulation based on 7segment display in proteus 8.9. But I found that, it can not display 7segment properly.
Either it shows still non-digits or flickering. I tried changing timing for multiplexing. But can't find the problem.
Can anyone tell me whats wrong here? Again I'm mentioning that, it works in hardware with this 5ms refresh interval. Sometimes little adjustment may required.
It is not working properly in proteus only.
Here is the simplified code which I was testing.
Code:
unsigned short mask(int num)
{
switch (num)
{
case 0 : return 0xC0;
case 1 : return 0xF9;
case 2 : return 0xA4;
case 3 : return 0xB0;
case 4 : return 0x99;
case 5 : return 0x92;
case 6 : return 0x82;
case 7 : return 0xF8;
case 8 : return 0x80;
case 9 : return 0x90;
}
}
unsigned short portb_index;
unsigned int digit,number;
unsigned short portb_array[5];
void display_digits()
{
PORTB = portb_array[portb_index];
if(portb_index==3)
{
RC0_bit = 1;
RC1_bit = 0;
RC2_bit = 0;
RC3_bit = 0;
}
if(portb_index==2)
{
RC0_bit = 0;
RC1_bit = 1;
RC2_bit = 0;
RC3_bit = 0;
}
if(portb_index==1)
{
RC0_bit = 0;
RC1_bit = 0;
RC2_bit = 1;
RC3_bit = 0;
}
if(portb_index==0)
{
RC0_bit = 0;
RC1_bit = 0;
RC2_bit = 0;
RC3_bit = 1;
}
portb_index ++ ;
Delay_ms(5);
if (portb_index > 3)portb_index = 0;
}
void Digit_seperation()
{
digit = (number / 1u) % 10u;
portb_array[0] = mask(digit);
digit = (number / 10u) % 10u;
portb_array[1] = mask(digit);
digit = (number / 100u) % 10u;
portb_array[2] = mask(digit);
digit = number / 1000u;
portb_array[3] = mask(digit);
}
void main()
{
TRISA = 0xFF; // all input.
TRISB = 0x00; // Set PORTB direction to be output
TRISC = 0x00; // Set PORTB direction to be output
PORTC = 0x00;
PORTB = 0x00;
ADCON1 = 0x00;// all analog in
while(1)
{
number = 5432;
Digit_seperation();
display_digits();
}//Endless loop;
}//End.
// end
And the proteus file:
- - - Updated - - -
This is happening most of the time.