CA Seven segments

Submitted by saj on Wed, 06/12/2019 - 02:35

Hi,

Could u please let me know what is the issue for not getting expected o/p from 4 digit 7seg in XC8 16F877A uC. The Ckt diag. and  Code is here.

I am getting o/p in 7seg only 0 and 8 but all contol and data pins in mcu portion is blinking but all the control pins under 7seg portion not blinking.CA 7SEG.jpg

 

 

#include <xc.h>

//***Define the signal pins of all four displays***//
#define s1 RC0
#define s2 RC1
#define s3 RC2
#define s4 RC3
//***End of definition**////

void main()
{
unsigned int a,b,c,d,e,f,g,h; //just variables
int i = 0; //the 4-digit value that is to be displayed
int flag =0; //for creating delay

unsigned int seg[]={0XC0, //Hex value to display the number 0
                    0XF9, //Hex value to display the number 1
                    0XA4, //Hex value to display the number 2
                    0XB0, //Hex value to display the number 3
                    0X99, //Hex value to display the number 4
                    0X92, //Hex value to display the number 5
                    0X82, //Hex value to display the number 6
                    0XF8, //Hex value to display the number 7
                    0X80, //Hex value to display the number 8
                    0X90  //Hex value to display the number 9
                   }; //End of Array for displaying numbers from 0 to 9// FOR CA
 

//*****I/O Configuration****//
TRISC=0X00;
TRISD=0x00;

PORTC=0XFF; // FOR CA

//***End of I/O configuration**///

#define _XTAL_FREQ 20000000

while(1)
{
    
  //***Splitting "i" into four digits***//  
a=i%10;//4th digit is saved here
b=i/10;
c=b%10;//3rd digit is saved here
d=b/10;
e=d%10; //2nd digit is saved here
f=d/10;
g=f%10; //1st digit is saved here
h=f/10;
//***End of splitting***//

PORTD=seg[g];s1=0; //Turn ON display 1 and print 4th digit
__delay_ms(10);s1=1;     //Turn OFF display 1 after 5ms delay
PORTD=seg[e];s2=0; //Turn ON display 2 and print 3rd digit
__delay_ms(10);s2=1;     //Turn OFF display 2 after 5ms delay
PORTD=seg[c];s3=0; //Turn ON display 3 and print 2nd digit
__delay_ms(10);s3=1;     //Turn OFF display 3 after 5ms delay
PORTD=seg[a];s4=0; //Turn ON display 4 and print 1st digit
__delay_ms(10);s4=1;     //Turn OFF display 4 after 5ms delay

if(flag>=10) //wait till flag reaches 100
{
    i++;flag=0; //only if flag is hundred "i" will be incremented 
}
flag++; //increment flag for each flash
}
}

 

Tnx

If the data pins on your MCU is bliking with red and blue colour it means that the code is outputting something. So in that case your see the 7-Seg module display something.

If nothing turns up may be you swapped between Common Cathode and Comman Anode type. Proteus has both type of display, make sure you are using the relevent one 

  Joined August 16, 2016      998
Tuesday at 12:29 AM

yes, code is outputting only 0 and 8.Perhaps the selection of base resitor is the issue. Could u plaese inform how to calculate base resistor depends on my case.

tnx Raj.

  Joined September 28, 2018      26
Friday at 01:20 AM

You need not worry about the tranistsors and resistors during simulation. The simulation should work even if the I/O pins from PIC is directly connected to the 7-Segment display module. 

I would highly recommend you to read this tutorial 

https://circuitdigest.com/microcontroller-projects/7-segment-display-interfacing-with-pic16f877a, here you can find how transistor and resistor is used in 7-segmentdiplay module. It also shows a simulation form proteus.

The base resistor of a transistor can be calculated based in the collector current, switching voltage and gain value of the transistor. As we know transistor is a current controlled device hence the resistor is used only to limit the base current. For your application an intense calculation of base resistor is not required and a value of 1K should work 

  Joined August 16, 2016      998
Tuesday at 12:29 AM

I think you need to check for the simulation issues, when you click on the run simulation button because sometimes your firmware code is successfully complied and hex file is generated but when you import that hex file in your proteus simulation and run that he process failed to execute, you can check this near the simulation buttons here you can find an exclamation mark indicating that something goes wrong. Double click on that icon, you can see there is mentioned simulation is stopped due to excessive CPU load or similar, near these messages and again try to simulate. I suggest you to get connect with the SSLA platform technical support team for getting better assistance regarding your queries and project support.

  Joined April 09, 2020      55
Thursday at 02:40 PM

jaksonlee

Permalink

A seven-segment display is a form of electronic display device for displaying decimal numerals that is an alternative to the more complex dot matrix displays.

Seven-segment displays are widely used in digital clocks, electronic meters, basic calculators, and other electronic devices that display numerical information.
Seven-segment representation of figures can be found in patents as early as 1903 when Carl Kinsley invented a method of telegraphically transmitting letters and numbers and having them printed on tape in a segmented format.
Some early seven-segment displays used incandescent filaments (filament seven segment displays) while making use of an evacuated bulb, like most nixie tubes and early vacuum fluorescent displays.They are also known as numitrons.A variation  made use of an evacuated (vacuum) potted box. They are filament segment displays that are housed in DIP packages like modern LED segment displays. They may have up to 16 segments.There were also segment displays that used small incandescent light bulbs instead of LEDs or incandescent filaments. These worked similarly to modern LED segment displays.Early LED seven-segment displays had all their components built onto a single die. This made the digits very small. Some included mangnifing lenses onto the design in an attempt to make the digits more legible.They are sometimes used in posters or tags, where the user either applies color to pre-printed segments, or applies color through a seven-segment digit template, to compose figures such as product prices or telephone numbers.

  Joined November 07, 2019      124
Thursday at 04:25 PM

I think you need to check for the simulation issues, when you click on the run simulation button because sometimes your firmware code is successfully compiled and hex file is generated but when you import that hex file in your proteus simulation and run that he process failed to execute, you can check this near the simulation buttons here you can find an exclamation mark indicating that something goes wrong. Double click on that icon, you can see there is mentioned simulation is stopped due to excessive CPU load or similar, near these messages and again try to simulate. I suggest you to get connected with the Sierra Software Ltd. platform technical support team for getting better assistance regarding your queries and project support.

  Joined May 23, 2020      47
Saturday at 02:49 PM