The Board Embedded in a More Complex Project
This final section illustrates the usefulness of the board layout described in this article in more complex projects. The example used is that of a 3-axis CNC controller. The picture below shows the controller board in situ on the rear panel of the machine. If you look at the right-hand side of this board you should see an ATmega328 with components surrounding it as in the stand alone board described here. The reset button is slightly obscured by a small bolt which passes through a flexible acrylic panel and allows the button to be pressed without removing the panel. The rest of the board contains three high-power, current limited stepper motor drivers and a relay for switching the mains voltage spindle motor on and off. All this is controlled by the 328 chip running custom firmware using the standard Arduino stepper motor library.
Command are sent from a connected computer, via a USB serial connection, using the same USB to TTL serial cable used to program the 328 chip. The commands contain 3D coordinates that describe the end points of paths the software running on the main computer wishes the tip of the cutting tool tool in the machine to take. They also indicate when the spindle motor should be switch on and off. The 328 chip works out all all the intermediate points along the paths and generates the correct stepper motor control sequences to move the tip of the tool as required. Other functions involve setting up the machine and establishing the initial position from which machining will commence.
The display system shown below is on the front of the panel on which the above controller board is mounted. It is made up of three separate boards, each one containing a large, four digit, seven segment display. These provide the operator of the machine with a very clear indication of the 3D position, x, y and z coordinates, of the tip of the cutting tool to the nearest tenth of a millimetre while the machine is in operation.
Each display is just a collection of LEDs, one for each segment plus a decimal point, and is connected to a 328 chip with the same layout as the one described in this article. There are 32 individual LEDs in each four digit display. This would require 32 pins to drive them, but the 328 chip only has 28 pins in the first place, some of which cannot be used as outputs. To overcome this all the cathodes of the LEDs for each digit are connected together in four independent groups, one for each digit. This allows the 328 to select an individual digit to power using only four outputs. In addition all of the anodes of corresponding segments plus the decimal points are connected together across all the digits. This allows the 328 to power any particular segment and a decimal point using only eight outputs. Thus with just 12 outputs, the 328 can choose an individual digit and turn on the segments that are required to form a particular numeric digit. To provide a full four digit display it displays the digits cyclically for 5 milliseconds each and then moves on to the next one. Persistence of vision causes the eye to see this as a stable four digit display. In the picture you can see that the camera is not so easily fooled as the digits do not all appear to be equally bright due to the way the image is built up by the camera's sensor.
Each of the identical display controllers receive packets containing coordinates from the main controller shown above. Every time the main controller moves the tool, it sends out new coordinates on a second serial line provided by the Arduino Software Serial library. The three display controllers each receive the same packets, but have on board links that configure each one to respond only to one particular coordinate, x, y, or z.
This particular application therefore reuses the same DIY Arduino system fours times in one embedded system.