Introduction: Ping-Pong Scoreboard Tutorial
In this project, I designing an interactive scoreboard for a ping pong table using an Arduino. The controller for the scoreboard is an infrared light embedded into a wrist watch, and will be explored in another tutorial. The goal of this project is provide prospective engineerings with an introduction into circuit elements and soldering.
The fundamental concepts explored in this project are:
- Understanding shift registers
- Understanding 5V regulator
- Soldering onto a PCB (Printed Circuit Board)
- Soldering joints
- Inserting Heat-Set Threads
This project can optionally include concepts such as programming a microcontroller and 3D modeling. However, that is currently beyond the scope of this tutorial, and may be added later depending on traction. Those who are familiar with those concepts are encouraged to try programming the scoreboard and model its casing. However, the source code and 3D models will be provided for those who are not.
All of the necessary STP files, PCB layouts, and Arduino code can be found in this Google Drive.
Supplies
Software
- Arduino
Tools
- Soldering Iron
- Soldering Flux
- 3D Printer
Hardware
- 1 Microcontroller (ATMega328p)
- 4 Shift Registers (SN74HC595)
- 1 5V Regulator (L7805CV)
- 1 Crystal Oscillator (16 MHz)
- 2 Capacitors (0.1 uF)
- 2 Ceramic Capacitors (22 pF)
- 15 Blue LED (3 mm)
- 15 Red LED (3 mm)
- 4 Threaded Inserts (3x10x5 mm)
- 4 Screws (M3x16 mm)
- Copper Wire (About 6 inches)
- 1 9V Battery
- 1 9V Battery Connector
Specialized Hardware
- PCBs
- 3D Printed Parts
** This project was intended to be a kit. If you are interested in buying all of the necessary components for this project, contact me through Instructables!
Step 1: Understanding Shift Registers
One of the inevitable problems encountered when interfacing with an Arduino is the limited number of I/O (Input/Output) pins available to control components, especially LED lights. Typically, displaying a single digit requires seven individual LED lights. Therefore, creating a scoreboard that has four digits would require 28 pins, which seems impossible. However, the solution to this problem is using a shift register. An individual shift register can control eight LEDs while using only three I/O pins. Additionally, shift registers can be chained together and thus control thousands of LED lights from just three pins.
How a Shift Register Works
To set the stage, microcontrollers work in bits. A bit is a piece of information in the form of a 0 or a 1. When turning an LED on using a I/O pin, its value is put to high, or 1. This means electricity can now flow through the pin, and light the LED. To turn the LED off, the pin's value would be set to 0, or low.
The driving principle behind a shift register is serial to parallel conversion. Put simply, the microcontroller sends one bit of information at a time (serial data) to the shift register's eight output pins. The shift register then stores each incoming bit, and eventually outputs the data all at once when the bits have been received (parallel data). Three pins are used to make this happen: the latch, clock and latch pins.
Latch Pin (RCLK)
The latch pin can be though of as the display switch of the shift register. When the register is receiving information, the latch pin is set to low, or 0. During the entire time that new information is being sent to the register, the latch pin remains low. This prevents data from being displayed when the register is still processing information. However, when all of the data is set, the latch pin switches to high and BOOM! All of the information is displayed simultaneously.
The Data Pin (SER)
The data pin is where the serial data (1 or 0) is shifted into the register, one bit at a time.
The Clock Pin (SRCLK)
The clock pin is used to control when data should be shifted into the register.
How the Pins Work Together
Lets imagine that a user wants to push data to a shift register. First, the latch pin switches from high to low. During the entire time that the latch pin is low (a few milliseconds), the shift register does not display any data. Next, the data pin receives a single bit (either a 1 or 0). Then, a pulse from the clock pin commands the register to "shift" all of the existing data to the next position. Now, the data pin can send the next bit of information, which is only committed with the clock pin pulses. This method ensures that only the correct data is being shifted into the register. This process then repeats until all of the necessary bits of information have been committed. Finally, the latch pin switches from low to high, and displays all of the information.
Shift Registers in Series
As stated before, shift registers can be chained to theoretically run an infinite number of lights from just 3 I/O pins. Doing this is quite simple. The clock and latch pins can be connected in parallel with all of the other shift registers. This ensures that all of the shift registers can "shift" the information and display the data simultaneously. However, the data pin must be connected to the next shift register in series. Lets all eight pins on the shift register are holding a bit of information. When a new bit of information is shifted into the register, where does the eight pin's data go? The answer is the QH' pin (pin 9). If this pin is connected to the data pin (SER) of the next shift register, the new shift register will act as an extension of the first. This is the driving principle of how 3 pins were used to control all 28 LEDs on the scoreboard.
Programming with Shift Registers
Programming with a shift register may seem complex, but the Arduino platform makes it extremely intuitive. Thanks to the shiftOut() method in the Arduino library, sending information to the register can be done in 3 lines.
Displaying Numbers with A Shift Register
Now that information can be sent to the shift register, the next obstacle is committing meaningful information. Lets dissect the newNumber() function. The first line in this tells the latch pin to switch to low. The shiftOut function is part of the Arduino library, and takes 4 parameters: the data pin, the clock pin, the digit order, and the information to display. The first two inputs are self explanatory. The last parameter accepts an integer. To control all eight pins with a single integer, the number is translated into its 7-digit binary form, meaning the number 27 would be converted to 00110100. Then, the pins corresponding to a 0 would be turned off, and the pins corresponding to a 1 would be turned on. The third parameter signifies the order in which the digits are transferred. The digit order can either be most significant bit first (MSBFIRST), or least significant bit first (LSBFIRST). MSBFIRST means that the highest bit of a binary number is transmitted first (or the left most digit). Using the previous example, the binary number 00110100 would be processed in the way that it is read: 00110100. However, LSBFIRST is the inverse of this. The binary number would be processed as: 00101100. In this project, I choose to use MSBFIRST since it is more intuitive.
Now, to display numbers using a shift register, each pin has to be assigned to a part of the 7-segment display. Then, fill in the desired parts of the display to represent a number. LEDs that should be on are then represented with a 1, with the rest being 0s. This will yield a binary number. Repeating this process for the digits 0-9 will provide all of the necessary numbers for the scoreboard. This process is outlined in the picture at the top of this step. I put all of the integers into an array so that accessing numberArray[0] would output the number associated with displaying a 0. The last integer in the array is to display a dash, for when the when neither player has scored a point.
Step 2: Understanding a Voltage Regulator
A challenge when developing a standalone product is powering the circuit. The ATMega328 requires a 5 volt power supply. However, 5 volt batteries are not common or cheap. Therefore, one solution to this problem is using a voltage regulator. Put simply, a voltage regulator is a circuit elements that can regulate a fluctuating voltage into a more stable, lower voltage. This will allow the scoreboard to be powered by a standard 9 volt battery without overloading the microcontroller, which requires 5 volts.
7805 Voltage Regulator Pins
The leftmost pin on the regulator is for the input voltage. 7085 Regulators typically require a 7-35 volt input to function, but this value varies slightly depending on the producer. The middle pin is to ground the voltage. This pin provides an outlet for all excess voltage and current. Finally, the right most pin is the output, which will maintain a 5 voltage output.
Decoupling Capacitors
A decoupling capacitors' primary function is to ensure that sensitive components (like microcontrollers, ICs, or transistors) receive a clean and stable voltage, free from high-frequency noise or ripples that might come from the power supply or other parts of the circuit. While may not be necessary for a simple circuit such as this scoreboard, it is a good practice to add capacitors to the voltage regulator. One capacitor goes between the input voltage and ground, and the second goes between the output voltage and ground. The data sheet for the 7805 regulator will typically include a circuit diagram with these capacitors added in, including the recommended capacitance values. An example circuit has been included, as well as where the voltage regulator is on the custom PCBs.
Step 3: Soldering to PCBs
Soldering is the process used to create a reliable electrical and mechanical connection between electronic components and a board. It involves melting a filler metal, known as solder, which has a relatively low melting point and forms a strong connection after cooling. The supplies needed to solder are a soldering iron, solder, and flux. The soldering iron is essentially a rod heated to around 325 degrees Celsius, and is used to melt the solder. As stated before, solder is the filler material, typically consisting of tin, lead, silver, and copper. Finally, flux is a special paste that improves the quality and reliability of solders. The main function of flux is to distribute heat and help the solder flow into the desired area.
Soldering To a PCB
- Place the component at the desired location
- On the provided PCBs, white outlines of the component are visible from one side. This is called a silkscreen. Silkscreens provide no electrical conductivity, and solely assist with the placement of parts. It is imperative that the bottom of the shift register is touching the side that has the silk screen, as demonstrated in the first picture. A point of clarification is the orientation of the shift register. Some components, such as resistors and ceramic capacitors, are non-polarized. This means that electricity can flow forward or backward through the component. However, components such as LEDs or shift registers are polarized, meaning that electricity can only flow one way through it. Therefore, their orientation must match the silkscreen. For shift registers and microcontrollers, the orientation of the part is signified with a semi-circle on one side of the part. This signifies the top of the component, and should align with the opening in the silkscreen. With the correct orientation, place the component so the pins fall through the PCB. The pins may need to be bent to fit through the board.
- Flip the board and apply flux
- Once the component is placed correctly, flip the entire board and the component so that the pins are exposed. To apply flux, use a toothpick. Try to ensure that all of the targeted pins have some flux on them. This step does not have to be done with the most precision. Refer to the second picture to see the PCB should look like after this step.
- Heat the pin and the hole
- Using the tip of the soldering iron, heat the targeted pin and the metal ring around the hole for 1-2 seconds.
- Apply solder
- With the soldering iron still in contact, feed a small amount of solder into the heated joint. Maintain contact until the solder flows to create a smooth, shiny joint.
- Repeat for all components
- Congrats on your first solder! Now, rinse and repeat for all of the components, and you will be a pro!
**Note: Read the next section before continuing to solder!!!!
Step 4: Soldering the Scoreboard
In this project, there are only two unique PCBs: one for the lights and one for the microcontroller. When creating a product, it is important to try to minimize unique pieces of hardware. This helps keeps the cost of production down, but requires more effort during the design phase of development. Thus, even though the two light PCBs have slightly different functions, they use the same PCB. Therefore, it is important to understand how the scoreboard is going to work before continuing to solder.
IR PCB
To control the score on the scoreboard, an IR remote control is used. While powerful IR beams can travel through walls, the ones generated by the 3.3V remote controller can not. Hence, an IR sensor must have a clear line of sight to the players. In order to make this happen, the IR sensor must be attached to one of the PCBs that also controls the LEDs. This is the only location where the sensor can be soldered and reach above the body of the scoreboard. Only one IR sensor is needed for this project, so only one of the Light PCBs needs to have a sensor. Solder the sensor as shown in the first picture of this section. This PCB will be referred to as the IR PCB.
The only modification that must be made to the IR PCB is removing one of the pins from the right shift register. As described before, the bottom right pin of the shift register is used to send data to the next register. Therefore, this pin in the final register is unnecessary. Since this pin is connected to the microcontroller, it can be used to send the IR data to control the score. The final shift register is the one on the right side of the IR PCB. Before soldering this register down, remove the bottom right pin. Ensure the correct pin is being removed by checking with the first picture in this section.
This is the only modification that needs to be made to the PCBs. When soldering, double check the orientation of the components. As stated before, components like ceramic capacitors and resistors do not had polarity. However, LEDs do have a polarity, and must match the orientation of the silkscreen. The flat edge of the silkscreen is for the cathode of the LED. Physically, this is the shorter leg of the LED. Please, please, please double check before soldering every LED, since removing a components is drastically harder than soldering a component on!
** Move on to the next step when all of the components have been soldered!
Step 5: Soldering Joints
An important design consideration when designing a multi-PCB product is how to connect the boards. There are various ways to do this. Some examples are using a component to bridge the gap, directly soldering the boards together, and using flexible wires. The way that was chosen for this project was using copper wire to bridge the gap. Not only does this method provide a stable electrical connection, but the rigidity of the copper helps support the weight of the PCBs.
Finding a suitable place to create the gap between the boards was another design consideration. Minimizing the number of wires that had to bridge this gap was important, since it mitigated the probability for error. The minimal amount of wires to bridge the gap was six. The latch, clock, and data pin were all used to power the shift register. Next, each board needed access to the 5V power source, as well as the ground. Finally, each Light PCB needed to send data back to the board, whether it be the information for the next shift register or commands from the IR sensor.
To solder this connection, 12 pieces of copper wire are needed, each about 5 inches in length.
- Solder six copper wires to one side of the microcontroller board.
- Clip the wires in descending order from right to left. This helps when threading the wires through the Light PCBs, since only one wire has to be aligned at a time. Ensure that at least 3 inches remain on the shortest wire, as seen in the first picture of this section.
- Thread the standing wires through the six corresponding holes on the Light PCBs. Before soldering, make sure that the IR PCB is soldered to the side of the microcontroller PCB that says "IR Out."
- Measure the length of needed wire by placing the microcontroller PCB in the bottom housing and then bending the Light PCB, as demonstrated in the third picture.
- Solder the connecting wires to the Light PCB.
- Repeat these steps with the other side!
- Check that the PCBs resemble the last figure in this section!
Step 6: Setting the Threaded Inserts
Finding an efficient way to connect 3D printed parts varies heavily on the intended use. For example, components can be super glued together for an easy connection method. While this method is quick, the adhesion can be unreliable and create a visually unappealing finish. In this project, heat-set inserts were used to connect the parts. While this method requires additional hardware, it is is extremely reliable, and allows for the product to be unassembled if needed. To set the threaded inserts into the printed parts, a combination of pressure and heat are needed. The holes for the inserts was designed to be slightly smaller than needed. This allows for the inserts to be melt the plastic when being installed, creating a very strong connection.
- In the bottom housing, manually press an insert into the hole. This is just to align the insert before using the soldering iron.
- Using the top of the soldering iron, push the insert down into the part. The plastic should quickly begin to melt around the insert.
- Continue pressing the insert until the top is flush with the 3D printed part.
- Congrats! Repeat this process for the 3 remaining inserts!
Step 7: Final Assymbly
Its its time to put all of the pieces together! To start, place the microcontroller PCB into the bottom housing. Then, place the top housing over the microcontroller PCB. Next, place the two seven digit 3D prints over the LED PCBs, using the four screws to finalize the assembly. There you have it! Now, you have a functional scoreboard!