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
-
Wine 10 Includes Plenty to Excite Users
With its latest release, Wine has the usual crop of bug fixes and improvements, along with some exciting new features.
-
Linux Kernel 6.13 Offers Improvements for AMD/Apple Users
The latest Linux kernel is now available, and it includes plenty of improvements, especially for those who use AMD or Apple-based systems.
-
Gnome 48 Debuts New Audio Player
To date, the audio player found within the Gnome desktop has been meh at best, but with the upcoming release that all changes.
-
Plasma 6.3 Ready for Public Beta Testing
Plasma 6.3 will ship with KDE Gear 24.12.1 and KDE Frameworks 6.10, along with some new and exciting features.
-
Budgie 10.10 Scheduled for Q1 2025 with a Surprising Desktop Update
If Budgie is your desktop environment of choice, 2025 is going to be a great year for you.
-
Firefox 134 Offers Improvements for Linux Version
Fans of Linux and Firefox rejoice, as there's a new version available that includes some handy updates.
-
Serpent OS Arrives with a New Alpha Release
After months of silence, Ikey Doherty has released a new alpha for his Serpent OS.
-
HashiCorp Cofounder Unveils Ghostty, a Linux Terminal App
Ghostty is a new Linux terminal app that's fast, feature-rich, and offers a platform-native GUI while remaining cross-platform.
-
Fedora Asahi Remix 41 Available for Apple Silicon
If you have an Apple Silicon Mac and you're hoping to install Fedora, you're in luck because the latest release supports the M1 and M2 chips.
-
Systemd Fixes Bug While Facing New Challenger in GNU Shepherd
The systemd developers have fixed a really nasty bug amid the release of the new GNU Shepherd init system.