Raspberry Pi uses sn74hc595 to control the digital tube

Source: Internet
Author: User

(1) using the GPIO port directly control the digital tube using 12 IO ports. In order to reduce the occupied IO port, we used a 74hc595 to drive the digital tube.

(2) The 74hc595 chip has a 8-bit shift register and a memory, three-state output function. The shift register and memory have separate clocks. The data is entered into the shift register at the rising edge of the SH_CP (shift register clock input) and is entered into the storage register at the rising edge of the ST_CP (Memory clock input). If two clocks are connected together, the shift register always has a pulse earlier than the storage register. The shift register has a serial shift input (DS), and a serial output (Q7 '), and an asynchronous low-level reset, the storage register has a parallel 8-bit, with a tri-state bus output, when enabling OE (low level), the data of the storage register is output to the bus.

(3) Pin detailed description:

    

    The
    • Gnd is grounded and VCC is connected to the 5V power supply.
    • Q0-q7 These 8 pins are the output pins of the chip, directly connected to the 8-segment pin of the digital tube. The correspondence depends on the order in which you send the data when you wire and write the code.
    • DS is a serial input pin, so-called serial is to make the data on a signal line in order to transmit one by one, like a string of candied fruit. This pin we received from the Raspberry Pi at any one of the Gpio ports (output mode). The
    • SHCP is the clock pin for the shift register. It sounds a little complicated, but it's very simple. There is a 8-bit shift register inside the 74hc595 to hold data entered from the DS pin. So how does 74hc595 know when it's time to fetch data from the DS pin? This is achieved by SHCP the clock pin. The 74hc595 only obtains current data (high/low) from the DS pin and saves this bit of data to the shift register only when a rising edge occurs at SHCP. Similarly, the pin is also attached to the Raspberry Pi at any one of the Gpio ports. When we send data to the chip, we must first prepare the data to be transmitted on the DS pin, and then make the rising edge of the SHCP pin (pull the low level and then pull the high level), 74hc595 will put the data on the DS pin into the shift register D0 on this rising edge, and D0 the original data will move to D1, D1 data displacement to D2 ... D6 data is shifted to D7. The original D7 data has no place to store, this data will be output to pin q7s. The role of this pin we say next, this article is not used for the time being this pin. (Note that this is not the output pin q0-q7, but refers to the internal 8-bit shift register in each "small room", the chip manual does not give these small room number, here to illustrate the convenience of the number)
    • The STCP is the clock pin of another 8-bit latch register inside the chip. When the shift register's 8-bit data is fully transmitted, the rising edge of the latch clock pin is manufactured (pull the low level up and then pull the high level). The 74hc595 will copy the 8 bits of data from the shift register into the latch on this rising edge (the original data in the latch will be replaced). Note that up to this point, the 8 bits of data are only stored in the latch and are not output to the digital tube. The pin is also attached to any of the Raspberry Pi's gpio ports.
    • OE is the output enable PIN, which is also common in other chips. The function is to control whether the data in the latch is ultimately output to the Q0-Q7 output pin. Low-power output, high-power normally not output (neither high-level, nor low-level but high-impedance state, no power). In order to facilitate direct connection to GND, this example keeps the output data low.
    • Mr is the pin used to reset the internal registers. Reset the internal register (Memoryreset?) at low power. This example maintains high levels for direct connection on VCC.
    • q7s PIN, serial output pin, this article does not use, the next article again explains its function.
    • About latches. As the name implies, save and lock the data. Once the latch is entered, the latch data is no longer changed unless the power loss or reset data (Mr Port is set to low). The advantage is that when you need to update the data, the data is entered into the shift register in the process, the latch in the information will not have any effect, there will be no flicker. Until the shift register 8-bit data is ready, and then the rising edge of the STCP is updated to update the latch data at once, updating the output.

Raspberry Pi uses sn74hc595 to control the digital tube

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.