An introduction to electronic weighing
Display
For the display, I wanted a large, bright, clear output that was cost effective. I also wanted something that was easy to drive and required few pins from the microcontroller. The display I chose was a six-digit LCD with a white LED backlight from Hobby Components [7] that requires only three lines to drive. The digits are about 1.5cm (0.6in) in height, with a battery state indicator to the right of the display. It is based on the HT1621 chip by Holtek [8], and the datasheet is available from their website.
Microcontroller
Once all the other parts of the design were chosen, attention could turn to selecting a suitable microcontroller. Because I'm already familiar with ST Microelectronics' range of ARM-based controllers, this was an obvious place to start. However, I also wanted a low-cost solution that was scaled appropriately for this application. I was pleasantly surprised to find that the ST's "Value Line" controllers include a device that runs at 48MHz without an external crystal, has 20 pins (plenty for this application), and 16KB of flash program memory. Programming and debugging use ST's two-wire ST-Link interface, and a Linux-based IDE, the STM32CubeIDE, integrates well with ST-Link. This device is available for less than a dollar. USB-based ST-Link programmers are available online for just a few dollars, as well. The exact device is the STM32F030x4 [9].
Design
Schematic capture and PCB layout were both performed by KiCad, a free and open source CAD tool originally developed at CERN [10]. It really is an excellent suite of tools and handles the entire process of electronic design from schematic capture (Figure 5) right through to generating files for manufacture. It even has a 3D viewer that generates a panable/rotatable image of your design, including the components. Although PCB assemblies are in some ways two dimensional, the use of the 3D viewer has saved me from mechanical clashes that are not apparent from the two-dimensional design perspective. You can export the 3D model as a STEP file and import that into 3D CAD tools such as FreeCAD to build up more complex assemblies (e.g., aiding the design of parts suitable for 3D printing, such as enclosures).
Many excellent PCB companies online will build good-quality PCBs in a few days for less than $5 (EUR6, £5), so building prototypes or experimental PCBs is not prohibitively expensive.
A four-pin terminal block is provided for connecting the load cell: two excitation pins and two signal pins. The excitation is provided by the REF5040, and the signal pins go to the ADS1232 through a simple low-pass filter. The ADS1232 needs a handful of passive components for filtering and stability, and its digital interface is three lines that go directly to the microcontroller. The microcontroller in turn drives the display with its three-line interface, with enough spare I/O pins on the controller to provide additional facilities (i.e., a battery monitoring circuit, a temperature input from the REF5040, a serial port for debugging and/or data logging, and two buttons used for tare and span setting). A pin switches or dims the display backlight.
Power is supplied by a PP3 (9V) battery, and two linear regulators provide 3.3V for the digital electronics and 5V for the analog section, giving some isolation between the two to minimize the effects of digital electrical noise. The 5V analog supply allows the REF5040 to generate a stable 4.1V for the load cell excitation. The 9V supply greatly simplifies the power supply design, allowing the use of linear regulators. If a lower supply were used (e.g., two lithium ion cells), some form of switching regulator would be required to boost the voltage to a level suitable for the load cell excitation, with all the attendant noise problems that could bring.
The PCB layout itself is fairly straightforward. Having decided the display would mount directly above the PCB, I saw that it was fairly apparent that most components could go under the display, with only switches and connectors requiring a margin around the edge. Therefore, I arrived at a size of 100x50mm (4x2 inches), with a two-layer PCB being more than adequate for such a simple circuit. Close attention was paid to layout of the analog section, care being taken to distance it from digital lines where possible, placing decoupling capacitors close to the analog chips and creating generous ground planes on the top and bottom layers. A 3D rendering of the resulting PCB is shown in Figure 6.
Buy this article as PDF
(incl. VAT)
Buy Linux Magazine
Subscribe to our Linux Newsletters
Find Linux and Open Source Jobs
Subscribe to our ADMIN Newsletters
Support Our Work
Linux Magazine content is made possible with support from readers like you. Please consider contributing when you’ve found an article to be beneficial.
News
-
Armbian 24.11 Released with Expanded Hardware Support
If you've been waiting for Armbian to support OrangePi 5 Max and Radxa ROCK 5B+, the wait is over.
-
SUSE Renames Several Products for Better Name Recognition
SUSE has been a very powerful player in the European market, but it knows it must branch out to gain serious traction. Will a name change do the trick?
-
ESET Discovers New Linux Malware
WolfsBane is an all-in-one malware that has hit the Linux operating system and includes a dropper, a launcher, and a backdoor.
-
New Linux Kernel Patch Allows Forcing a CPU Mitigation
Even when CPU mitigations can consume precious CPU cycles, it might not be a bad idea to allow users to enable them, even if your machine isn't vulnerable.
-
Red Hat Enterprise Linux 9.5 Released
Notify your friends, loved ones, and colleagues that the latest version of RHEL is available with plenty of enhancements.
-
Linux Sees Massive Performance Increase from a Single Line of Code
With one line of code, Intel was able to increase the performance of the Linux kernel by 4,000 percent.
-
Fedora KDE Approved as an Official Spin
If you prefer the Plasma desktop environment and the Fedora distribution, you're in luck because there's now an official spin that is listed on the same level as the Fedora Workstation edition.
-
New Steam Client Ups the Ante for Linux
The latest release from Steam has some pretty cool tricks up its sleeve.
-
Gnome OS Transitioning Toward a General-Purpose Distro
If you're looking for the perfectly vanilla take on the Gnome desktop, Gnome OS might be for you.
-
Fedora 41 Released with New Features
If you're a Fedora fan or just looking for a Linux distribution to help you migrate from Windows, Fedora 41 might be just the ticket.