Decimal Counter Using Two 7-segment displays and an 8051

Not rated 31,376

Circuit Image

The objective of this lab is to create a decimal counter that counts from 0 to 99 using the 80X51 microcontroller. A C program must be written for this purpose, which will then be compiled using the C51 compiler and uploaded to an 8051 standalone chip. Wiring will also be necessary, as the 8051 chip requires specific connections to function properly, and the 7-segment displays must be connected to the 8051. The schematics are provided. Understanding the operation of the 7-segment displays is essential before programming. The LSD5061-11 display is utilized in this lab, where each segment corresponds to a specific pin. To illuminate a segment, its pin must be set to 0V, and to turn it off, the pin must be set to 5V. The corresponding pins on the 8051 are adjusted accordingly. Instead of manually setting each of the seven pins for displaying a number, a lookup table is employed: unsigned char LookupTable[11] = { }. The index of the table correlates with the pin settings needed to display a specific number. For instance, LookupTable[0] provides the necessary pin settings to show "0" on the display. To display "0", segments s1, s2, s3, s4, s5, and s6 must be activated, while segment s7 must be deactivated. This results in a bit pattern of 1100 0000, which translates to hexadecimal 0xC0. This value is stored in the lookup table at index 0. The remaining values for 1-9 must also be filled in, with LookupTable[10] indicating an error condition, where segment s7 is lit, and the others are off. Further information can be found in the 7-segment display datasheet. The ports P0, P1, P2, and P3 are predefined and bit addressable. The function SetDisplay(unsigned char value) checks if the input value is valid and returns the appropriate display configuration or an error value. A delay function is implemented to manage timing, and the main function contains a loop that updates and displays the counter value.

The circuit design consists of the 8051 microcontroller interfaced with the LSD5061-11 7-segment displays. Each segment of the display is connected to specific output pins on the 8051, allowing for direct control over which segments are illuminated. The microcontroller operates at a standard voltage of 5V, and the 7-segment displays are designed to function within this voltage range, ensuring compatibility.

The lookup table is essential for efficiently managing the display outputs. Each entry in the table corresponds to a specific digit, and the values are derived from the required pin states to illuminate the segments correctly. For example, the entry for displaying the digit "0" is represented by the bit pattern 1100 0000, indicating that segments s1 to s6 are active (0V) while s7 is inactive (5V). The remaining entries in the lookup table must be populated with similar bit patterns for digits 1 through 9, ensuring that the display can accurately represent all decimal numbers in the range.

The SetDisplay function is designed to handle the input value and verify its validity. If the value is within the acceptable range, it retrieves the corresponding display configuration from the lookup table. If the value is out of bounds, it returns an error value, which is indicated by lighting segment s7.

The delay function is implemented as a simple nested loop that creates a pause in the execution of the program, allowing the displayed numbers to be visible to the user for a short period before the next update occurs. The main loop continuously updates the counter, displaying both the ones and tens places, ensuring that the display reflects the current count accurately.

This circuit design effectively demonstrates the integration of microcontroller programming with hardware components, providing a practical application of digital electronics principles. The use of a lookup table simplifies the process of controlling the 7-segment display, while the structured approach to programming ensures clarity and functionality.The purpose of this lab is to implement a decimal counter which counts from 0 to 99. You will have to write a C program for the 80X51 micro-controller. You will then compile your C program using C51 compiler and burn it unto an 8051 stand alone chip. You will also have to do some wiring in this lab. The 8051 chip requires some connections to funct ion properly, and the 7-segment displays need to be wired to the 8051. Schematics are provided below. Before you can write your C program, you have to understand how the 7-segment displays work. The 7-segment displays used in the lab are the LSD5061-11 display. Each of the segment corresponds to a pin (see below for the pinout). In order to light up a particular segment, it`s pin must be set to 0V. Since these pins are connected to the 8051, we simply set the corresponding pin on the 8051 to `0`. To turn a segment off, the pin must be set to 5V. This is done by setting the corresponding pin on the 8051 to "1". Instead of going through each of the seven pins and setting them to `1` or `0` each time we want to display a number, we will use a lookup table unsigned char LookupTable[11] = { }. The location of the entry in the table corresponds to the correct pin settings to display that number.

Simply, LookupTable[0] returns the correct pin settings to display a "0" on the 7-segment display. Now we have to figure out the correct entries into the table. We know that in order to display a "0" on the 7-segment display we need to turn on segments s1, s2, s3, s4, s5, and s6. To turn a segment on, we set the corresponding pin to "0". Segment s7 will need to be turned off. To turn off this segment we set the corresponding pin to "1". Therefore, the pins will need to be assigned the following values: The bit pattern desired is 1100 0000 (remeber that pin 8 is the highest bit).

We then convert the values into hexadecimal 1100 -> C and 0000 -> 0. We fill in the table with this value 0xC0. The "0x" is needed before the actual value to indicate to the compiler that it is a hexadecimal value. Now when we call LookupTable[0] it will return the proper configuration to display a "0" on the 7-segment display.

You will need to fill in the rest of the values (1-9). LookupTable[10] will indicate an error has occured, at this location segment s7 will be on, the remaining segments will be off. (If you want, you can also look at the 7-segment display datasheet. ) /* P0, P1, P2 and P3 are predefined port names and are bit addressable */ unsigned char SetDisplay(unsigned char value){ unsigned char LookupTable[11] = { 0xC0, .

}; /* check to see if "value" is in bounds, if not return an error */ if( ) { /* return appropriate value */; } else { /* return error value */; } } /* Delay function */ void delay() { int i, j; for(i=0; i<1000; i+) for(j=0; j<100; j+) i = i + 0; } void main(void){ unsigned char count = 0; /* value held in one`s place */ while(1) { /* determine and display the one`s place */ /* determine and dipslay the ten`s place */ /* update the counter (remember to keep it within bounds)*/ delay(); } } 🔗 External reference




Warning: include(partials/cookie-banner.php): Failed to open stream: Permission denied in /var/www/html/nextgr/view-circuit.php on line 713

Warning: include(): Failed opening 'partials/cookie-banner.php' for inclusion (include_path='.:/usr/share/php') in /var/www/html/nextgr/view-circuit.php on line 713