Continuous Assessment Cover Sheet Faculty of Engineering Module Details EC2132 Module Code Microcomputers Course: BSc.Eng Electrical and Electronic Engineering Module Title SLIIT Stream: Electronics Program: Assessment details Title Lecturer/ Instructor Due date Assignment on driving MAX6952 Group assignment LED dot matrix display using Group No. PIC16F877A NO Dr.Lasantha Seneviratna 06/12/2024 06/12/2024 Date of Performance Date submitted 02 Student statement and signature By this declaration, I/we confirm my/our understanding and acceptance that the work reported in this report is my/our own work. I/we also understand the consequences of engaging in plagiarism or copying others work without proper citation. Any material used in this work (whether from published sources, the internet or elsewhere) have been fully acknowledged and referenced and are without fabrication or falsification of data. [Copying or plagiarism will result in a “0” mark for the continuous assessment and “F” for the module after an investigation on academic misconduct; All academic misconduct is considered seriously and defined as dishonest and in direct opposition to the values of a learning community. Misconduct may result in penalties from failure to exclusion from the campus. Further help and guidance on how to avoid academic misconduct can be obtained from your academic advisor/tutor] By this declaration, I/we confirm my understanding and acceptance that• I/we have adhered to relevant ethical guidelines and procedures in the completion of the assignment. • I/we have not allowed another student to have access to or copy from this work. • This work has not been submitted previously. [The Institute may request an electronic copy of this work for submission to the Plagiarism detection facility (TURNITIN). You must make sure that an electronic copy of your work is available in these circumstances] Details of the student/s submitting the assignment ID Number EN23467866 Signature Name (As per the institute records ) Perera W.S.O OFFICE USE ONLY Receiving Officer (seal, signature, date) Specific comments about the work (including overall comments and guidelines for improvement) Tutor: Marks: Signature: Date: [ All marks are subject to external moderation and approval of board of examinations] Sri Lanka Institute of Information Technology Faculty of Engineering Department of Electrical and Electronic Engineering Assignment Driving MAX6952 LED dot matrix display using PIC16F877A Name: Perera W.S.O Index Number: EN23467866 Specialization: EEE Group: 02 Submission Date: 06/12/2024 1. Abstract The main aim of this project is to design and implement a system to display a student registration number in a MAX6952 LED dot matrix display using the PIC16F877A microcontroller. The language used to program the microcontroller is assembler. The MAX6952 is a condensed serial input/output display driver and is capable of providing a connection between microcontrollers and dot matrix LED displays. Three control lines from PIC16F877A were used to drive the display as the chip is compatible with SPI and other serial communication protocols. The display format of the registration number was initially identified, and the code was developed accordingly to incorporate techniques such as bit rotation for efficient execution. In addition, the functionality of the system was verified by simulation software. 2. Introduction PIC microcontrollers are widely used in modern electronics applications. All members of the PIC microcontroller family use Harvard architecture. This architecture allows the program data to be accessed from separate memories using the program memory bus and the data memory bus. The PIC16F877A microcontroller is a part of the PIC family and uses Flash memory technology to write/erase many commands. It is a capable microcontroller that can perform many tasks due to its large program memory. PIC16F877A has 40 pins and 33 paths of I/O. The functions are spread out over the pins due to the presence of the 40 pins, making it easier to use the peripherals. In addition, it is more convenient when deciding on what pins the external devices should be connected to. PIC16F877A runs on 35 single-word instructions. Some applications of the PIC microcontroller are industrial machines, consumer electronics, automobiles, household appliances, and medical devices. [1] The MAX6952 is a condensed cathode-row display driver and can provide a connection between microcontrollers and dot matrix LED displays using an SPI compatible serial interface. It can drive up to 4 digits (140 LEDs). In addition, the chip includes an ASCII 104character font, column and row drivers, multiplex scan circuitry, a static RAM that stores each digit, and font data for 24 user-definable characters. The component also has a test mode that turns on all the LEDs, segment blinking (synchronized across multiple drivers, if desired), and a low-power shutdown mode. The MAX6952 display driver is mainly used to display numerical/textual data and acts as user interfaces in embedded systems. In addition, in projects such as automation and monitoring systems, the use of displays provide real-time feedback to users about system status and errors. Therefore, the use of microcontrollers and LED dot matrix displays allows this assignment to show advanced programming techniques, while creating visually engaging outputs. The purpose of this project is to provide an overview of the methods used by the PIC16F877A microcontroller to display a registration number using the MAX6952 LED dot matrix display. Key features of the system include the use of assembly language using the SPI communication protocol and the implementation of bit rotation for code optimization. 1 3. Literature Review The PIC16F877A microcontroller is used in many applications such as control systems for consumer electronics, industrial automation, communication systems and display systems etc. The use of the PIC microcontroller for driving LED displays is common where information must be displayed in a pattern. It is used in digital clocks, message boards, scoreboards, etc. With reference to the assignment, the PIC16F877A is used to display digits in LED displays using the MAX6952 display driver. Similarly, the microcontroller can display information in a 16 x 64 (p10) LED matrix Display. Data is sent to the microcontroller via UART which is stored in the EEPROM to display the data on an LED matrix display. The same data would continue to be shown whenever new data arrives. [5] Display drivers are integrated circuits used to provide an interface between a microcontroller and a display device such as an LED matrix. LED drivers are used in regulating the magnitude of current and voltage supplied to individual LEDs in the display while also providing brightness, backlight, and color control. There are many types of LED display drivers such as white light LED drivers, Pulse width modulation (PWM) LED drivers, RGB LED drivers and constant current LED drivers that provide features such as white light for backlighting, being able to be programmed through an I2C compatible interface, and control the color of RGB LEDs and LED strips respectively. [4] Display drivers such as the MAX6952 have a wide variety of uses when displaying digits in LED displays. The MAX6952 and MAX6958 are a 4-digit, 9 segment LED display driver which contains a reduced pin count multiplexing scheme to drive 36 segments using only 10 drive pins. Through this LED display driver, 4-1/2 digit meter displays with a range of -19999 to 19999 could be driven, making it appropriate for applications such as voltmeters and ammeters. Furthermore, in addition to the normal operation to display four digits, a fifth digit could be accommodated for extended range applications, such as employing steering diodes to enable multiplexing additional segments without adding complexity to the circuit design. This method maintains accuracy in display outputs while guaranteeing effective operation. The drivers offer high-performance designs with minimal wastage since they are optimized for low power consumption and is compatible with 3V to 5.5V systems. In addition, these drivers can be used by applications to achieve more complex features such incorporating separate LED indicators for status updates or showing measurement scales. [3] At present, the use of Micro-pixelated light-emitting diodes (micro-LEDs) have gained significant attention due to their high-performance display applications because of their low power consumption, rapid response time, and robustness under high pixel currents compared to organic LEDs. Ahn et al proposed an active matrix micro-pixelated LED (AMLED) display driver to improve luminance uniformity by fixing resistance mismatches in micro-pixel circuits by using silicon-based MOSFET backplanes to solve issues like voltage shifts and low mobility in TFT designs. [2] Therefore, the use of microcontrollers used to drive LED displays are very common at present. 2 4. Methodology 4.1 Code 1 Explanation The code was developed to display the Student Registration number by first displaying the first four digits, then the second four digits, and lastly, the final two digits. After displaying the complete Student Registration number once, the screen is cleared, and the Registration number is displayed again. This occurs in a loop. A PIC16F877A microcontroller and a single MAX6952 Display Driver was used to display the registration number in four LED displays. 4.1.1 Initialization First, variable names were assigned to a few general-purpose registers in the PIC microcontroller using the ‘equ’ keyword. Registers were assigned to store the count for the first eight bits and second eight bits of data separately for the MAX6952, as well as to store the count for the display looping of the ten digits. In addition, variable names were given to registers to store the count for the delay and for a temporary register to store the data. Then, values were assigned to the delay variable and count. Next, banks were selected to configure all pins in PORTB as outputs and PORTB was cleared. 4.1.2 MAX6952 Display Driver Configuration Data corresponding to the addresses and data values of different registers were assigned to general purpose registers in the PIC microcontroller to initialize and configure the MAX6952 display driver to control the LED display. As MAX6952 stores data in 16-bit registers, data corresponding to one register is stored in two registers as the address and data separately in the PIC microcontroller. The address value is first written into the microcontroller before sending the data value. The address is represented by bits 15 to 8, while the data value corresponds to bits 7 to 0. The MOVLW keyword as shown in Fig.1 is used to move a particular value to the Working register while MOVWF keyword is used to store the value from the working register in a defined general-purpose register. Registers for configuration, display test, intensity, and data values were used when initializing the display driver. The corresponding addresses and data values can be found in the MAX6952 data sheet. Fig.1 The configuration register is used in the code to enter and exit shutdown and globally clear the digit data. The intensity 10 and 32 registers are used to control the brightness of the display digits. The Display test register is used to test if the LED segments are working properly when connected to the microcontroller from MAX6952. The data to be displayed is also stored in the pic in separate registers for each digit. In the code, the four digits are displayed in Plane P0 using addresses 0x20 to 0x23. 3 In the context of the configuration register, the general value for the configuration register data is 0x81. The value “0XA1’ is used in this code to clear the digit data (display) after displaying the first four digits prior to displaying the next four digits as bit 5 is set to one. 4.1.3 Bit Rotation After initializing the addresses in MAX6952, data from these addresses is sent to the display driver one bit at a time. A special register that acts as a pointer to any memory address indirectly across file registers and program memory is the FSR (File Select Register). Initially, FSR points to the memory location 0x21. Fig.2 Data is sent to the MAX6952 driver by first making Chip Select high, then clock low, and then making chip select low. Then, values are loaded to the variables that store the count for each 8-bit rotation loop. FSR is then incremented to point to the next digit address. The value stored in the register pointed by FSR is then loaded to the working register, and then moved to the temporary data register in the PIC microcontroller. Fig.3 Afterwards, the initial loop count is decreased, and the DECFSZ (Decrement File Skip if Zero) command checks if the count has reached zero. It is checked using the following command: Fig.4 If zero is not reached, the bits are continuously clocked in to MAX 6952 and the data bit is made high/low based on if the bit is one or zero by going to the first_word_rotation function. After the data bit is made high/low, a delay is called, the clock is made high, and the bits are rotated using RLF(Rotate Left through Carry). After all the eight bits are rotated starting from the MSB, the count reaches zero, and the code moves to the loop that sends the second 8 bits to the display driver. 4 Fig.5 The MSB of the data is checked if it is one or zero using the BTFSC or BTFSS command: Fig.6 Once the first eight bits are loaded onto the MAX6952 display driver, the FSR is incremented to point to the next address and the data value in the data register is updated. The count variable is also decreased by one after the first eight bits are clocked in. The next eight bits are loaded in the same way using the second_word_rotation function into the display driver. The count decrements after each register address value is loaded into the display driver. Until count becomes zero (all ten digits are displayed), FSR increments continuously and loads the values to the display driver. When count reaches zero, the code restarts by going to the RESTART_LOOP subroutine. Fig.7 4.1.4 Restarting Loop Before the loop restarts, the count value is initialized again, and the starting address that FSR should point to is provided. This is done to start displaying the digits again from the beginning. FSR points to the initial memory location and the count loads its initial value to display all 10 digits again. The RESTART_LOOP subroutine is used to loop the program infinitely, making sure the 10 digits are continuously displayed. 5 4.2.5 Delay Subroutine This subroutine is used to introduce a short delay in the program. The value stored in the use_delay register is decremented until it reaches zero. Afterwards, the same value is loaded to the register again and the code returns to the place where it was called. The delay function is mainly used to provide a brief pause between commands when sending data to the display to prevent disruption of the commands due to synchronized timing when exchanging commands between the microcontroller and display driver. 4.2 Code 2 Explanation The code was developed to display the Student Registration in ten 5x7 LED displays using three MAX6952 display drivers. Each digit was displayed in a single LED display. A PIC16F877A microcontroller and three MAX6952 Display Drivers was used to display the registration number. 4.2.1 Initialization First, variable names were assigned to a few general-purpose registers in the PIC microcontroller using the ‘equ’ keyword. Registers were assigned to store the count for the first eight bits and second eight bits of data separately for the MAX6952, as well as to store the counts for the three display loops for the ten digits. In addition, variable names were given to registers to store the count for the delay and for a temporary register to store the data. In addition, values were assigned to each count variable. Next, banks were selected to configure all pins in PORTB and PORTC as outputs and PORTB and PORTC were cleared. 4.2.2 MAX6952 Display Driver Configuration Data corresponding to the addresses and data values of different registers were assigned to general purpose registers in the PIC microcontroller to initialize and configure the MAX6952 display driver to control the LED displays. As the MAX6952 stores data in 16-bit registers, data corresponding to one register is stored in two registers as the address and data separately in the PIC microcontroller. The address value is first written into the microcontroller before sending the data value. The address is represented by bits 15 to 8, while the data value corresponds to bits 7 to 0. Registers for configuration, display test, intensity, and data values were used when initializing the display driver. The corresponding addresses and data values can be found in the MAX6952 data sheet. The configuration register is used in the code to enter and exit shutdown and globally clear the digit data. The intensity 10 and 32 registers are used to control the brightness of the display digits. The Display test register is used to test if the LED segments are working properly when connected to the microcontroller from MAX6952. The data to be displayed is also stored in the pic in separate registers for each digit. In the code, the ten digits are displayed in Plane P0 using addresses 0x20 to 0x23. All the registers used to configure the MAX6952 driver stored in three different memory location in the PIC microcontroller to display all ten digits using three display drivers at the same time. Therefore, the number of registers used was more than in code 1. 6 4.2.3 Bit Rotation After initializing the addresses in MAX6952, data from these addresses is sent to the display driver one bit at a time. A special register that acts as a pointer to any memory address indirectly across file registers and program memory is the FSR (File Select Register). Initially, FSR points to the memory location 0x21 as shown in Fig. 8. Fig. 8. Data is sent to the MAX6952 driver by first making Chip Select high, then clock low, and then making chip select low. Then, values are loaded to the variables that store the count for each 8-bit rotation loop. FSR is then incremented to point to the next digit address. The value stored in the register pointed by FSR is then loaded to the working register, and then moved to the temporary data register in the PIC microcontroller as shown in Fig. 9. Fig. 9 Afterwards, the initial loop count is decreased, and the DECFSZ (Decrement File Skip if Zero) command checks if the count has reached zero. It is checked using the following command: Fig.10 If zero is not reached, the bits are continuously clocked in to MAX 6952 and the data bit is made high/low based on if the bit is one or zero by going to the first_word_rotation function. After the data bit is made high/low, a delay is called, the clock is made high, and the bits are rotated using RLF(Rotate Left through Carry). After all the eight bits are rotated starting from the MSB, the count reaches zero, and the code moves to the loop that sends the second 8 bits to the display driver. The MSB of the data is checked if it is one or zero using the BTFSC or BTFSS command before assigning one or zero to the data pin in the microcontroller. Once the first eight bits are loaded onto the MAX6952 display driver, the FSR is incremented to point to the next address and the data value in the data register is updated. The count1 variable is also decreased by one after the first eight bits are clocked in. The next eight bits are loaded in the same way using the second_word_rotation function into the display driver. The count decrements by one after each register address value is loaded into the display driver. Until count becomes zero (the first four digits are displayed), FSR increments continuously 7 and loads the values to the display driver. When count1 reaches zero, the program moves to the second main loop (first8bit_loop_2) to load the second four digits to the MAX6952 driver in the same way as the first four digits. When count2 also reaches zero, the program jumps to the third main loop to load the last two digits of the registration number to the display driver. Afterwards, the program goes to the reset function to start displaying the ten digits again from the beginning. Nine different ports were assigned for the chip select, data in, and clock signal ports for the three display drivers. In addition, the displays were configured, and the intensity and display was tested before each set of 4 digits were displayed in the next MAX 6952 display driver. 4.2.4 Restarting Loop Before the loop restarts, the three count values are initialized again, and the starting address that FSR should point to is provided. This is done to start displaying the digits again from the beginning. FSR points to the initial memory location and the count variables load their initial values to display all 10 digits again. The RESTART_LOOP subroutine is used to loop the program infinitely, making sure the 10 digits are continuously displayed. 4.2.5 Delay Subroutine This subroutine is used to introduce a short delay in the program. A count for the delay value is stored in the use_delay register and is decremented until it reaches zero. Afterwards, the same value is loaded to the register again and the code returns to the place where it was called. The delay function is mainly used to provide a brief pause between commands when sending data to the display to prevent disruption of the commands due to synchronized timing when exchanging commands between the microcontroller and display driver. 8 5. Results 5.1. Simulation of code 1 Fig. 11. First four digits of the student registration number Fig. 12. Second four digits of the student registration number 9 Fig. 13. Last two digits of the student registration number 5.2. Simulation of code 2 Fig. 14. All ten digits of the student registration number 10 6. Discussion Code 1 worked as intended as all 10 digits were displayed, starting with the first four digits, then, the next four digits, and finally the last two digits. The display kept on displaying the registration number in an infinite loop. However, only the first eight digits of the student registration number were displayed when code 2 was run and simulated. There could have been an error in the third loop used to display the last two digits. Furthermore, there could have been a wrong command that was used to start loop 3 after loop 2. On the other hand, there may have been a an inaccurate value assigned to a display register during the configuration of the MAX6952 display driver. These possible errors were analyzed, and checked thoroughly, however, the code did not work as intended. 7. Conclusion Through this project, a system to drive the MAX6952 LED dot matrix display, was successfully implemented through one code, showcasing the EN number. The use of SPI communication and assembly language programming was tested through the functionality of this code. The use of simulation tools such as Proteus made it convenient to check for the working functionality of the code. Through the two codes included, the project’s objectives and learning outcomes were addressed, even though code was not fully functional. In conclusion, we were able to gain practical experience on displaying digits in an LED display that has real world applications. References [1] Maxim Integrated, "MAX6952: Compact, Serial-Input, 4-Digit LED Display Driver," Datasheet, 2001. [Online]. Available: https://www.maximintegrated.com [2] H. Ahn, S.-K. Hong, and O.-K. Kwon, “An Active Matrix Micro-Pixelated LED Display Driver for High Luminance Uniformity Using Resistance Mismatch Compensation Method,” IEEE Transactions on Circuits and Systems Ii-express Briefs, vol. 65, no. 6, pp. 724– 728, Jun. 2018, doi: https://doi.org/10.1109/tcsii.2018.2790412. [3] “Driving 4-1/2 Digit Meter Displays with the MAX6958/59 LED Drivers,” 2003. Accessed: Dec. 06, 2024. [Online]. Available: https://www.analog.com/media/en/technicaldocumentation/design-notes/driving-412-digit-meter-displays-with-the-max695859-leddrivers.pdf [4] Louvil Abasolo, “LED Display Drivers,” Circuit https://www.circuitbasics.com/led-display-drivers/ Basics, Mar. 2021. [5] iTechnoLabzVisit M. S. Follow, “16x64 P10 Scrolling LED Display Using PIC16F877 Microcontroller,” Instructables. https://www.instructables.com/16x64-P10-Scrolling-LEDDisplay-Using-PIC16F877-Mi/ 11 Appendices Appendices A The following Table was referred when loading the data value for the configuration register to clear the display after displaying the first four digits. Fig 14 12