6/30/2023 0 Comments 7 segment common anodethe third digit of the 16-bit number end 2'b11 : begin activate LED3 and Deactivate LED2, LED1, LED4 LED_BCD = ((displayed_number % 1000) % 100) / 10 the second digit of the 16-bit number end 2'b10 : begin activate LED2 and Deactivate LED1, LED3, LED4 LED_BCD = (displayed_number % 1000) / 100 the first digit of the 16-bit number end 2'b01 : begin activate LED1 and Deactivate LED2, LED3, LED4 LED_BCD = displayed_number / 1000 anode activating signals for 4 LEDs, digit period of 2.6ms // decoder to generate anode signals always *) One_second_counter <= one_second_counter + 1 Įnd end assign one_second_enable = (one_second_counter = 99999999) ? 1 : 0 Īlways posedge clock_100Mhz or posedge reset)ĭisplayed_number <= displayed_number + 1 Įnd always posedge clock_100Mhz or posedge reset)Įnd assign LED_activating_counter = refresh_counter Reg refresh_counter // 20-bit for creating 10.5ms refresh period or 380Hz refresh rate // the first 2 MSB bits for creating 4 LED-activating signals with 2.6ms digit period wire LED_activating_counter // count 0 -> 1 -> 2 -> 3 // activates LED1 LED2 LED3 LED4 // and repeat always posedge clock_100Mhz or posedge reset) Reg one_second_counter // counter for generating 1 second clock enable wire one_second_enable // one second enable for counting numbers reg displayed_number // counting number to be displayed reg LED_BCD Input clock_100Mhz, // 100 Mhz clock source on Basys 3 FPGA input reset, // reset output reg Anode_Activate, // anode signals of the 7-segment LED display output reg LED_out // cathode patterns of the 7-segment LED display : FPGA projects, Verilog projects, VHDL projects // FPGA tutorial: seven-segment LED display controller on Basys 3 FPGA module Seven_segment_LED_Display_Controller( the first hex-digit of the 16-bit number end endcase end the fourth hex-digit of the 16-bit number end default : begin activate LED4 and Deactivate LED2, LED3, LED1 LED_BCD = displayed_number the third hex-digit of the 16-bit number end 2'b11 : begin activate LED3 and Deactivate LED2, LED1, LED4 LED_BCD = displayed_number the second hex-digit of the 16-bit number end 2'b10 : begin activate LED2 and Deactivate LED1, LED3, LED4 LED_BCD = displayed_number the first hex-digit of the 16-bit number end 2'b01 : begin activate LED1 and Deactivate LED2, LED3, LED4 LED_BCD = displayed_number anode activating signals for 4 LEDs // decoder to generate anode signals always *) To avoid the displaying discontinuity perceived by the human eye, the four seven-segment LEDs should be continuously refreshed at about 1KHz to 60Hz or it should be refreshed at every 1ms to 16ms. When a LED is deactivated after illuminating, it will darken. When a transistor is on or the Base terminal (W4, U4, V4, or U2) is low, the corresponding anode is driven high to activate or enable the corresponding seven-segment LED. As shown in the figure above, we can control activating four seven-segment LEDs by using 4 PNP transistors AN0-AN3. Similarly, LED 2 - LED 4 can be displayed by using the same way at different times. For example, when we activate LED 1 by driving A1 high and the other three LEDs (LED 2, LED 3, LED 4) are deactivated (A2, A3, and A4 not driven), the cathode pattern (CA-CG) will be used for displaying numbers on LED 1. Thus, to display 4 different numbers on the 4-digit seven-segment LED display, we have to control the cathodes (CA-CG) of the four seven-segment LEDs separately by activating the four seven-segment LEDs at different times.
0 Comments
Leave a Reply. |