Since my scale's display started to show wrong results I had the opportunity to create a new electronics for it.
The mechanical hardware and the sensor can still be used. So only an ADC and a display is neede, and a microcontroller which connects them. The choice for the components was easy: An ATmega48 was already in the CPU box waiting for a job. Some old hd44780 displays can also be found everywhere. The ADC and amplifier was the only thing to be organized. Since I saw a nice hx711 breakout board in my friends lab I chose to use one of these. The hx711 contains an amplifier, voltage regulator and an ADC with simple digital interface. So the whole project was soldering these components together and write a software.
The firmware of the AVR is 902 bytes. It uses 20 characters from the hd44780 display, 10 digits and a few letters and specials. Each character is 8*5 dots, 5 bytes. This uses a total of 100 bytes character memory. The total code usage is 1002 bytes.
Files
weigh-scale-1k.srec
902 bytes firmware for a ATmega48 in Motorola SREC format.
The current firmware is written in C, compiling it optimized for size leads to a 902 byte binary. It uses 20 different characters from the LCD which adds another 100 byte of data. The total size is thus 1002 bytes.
I could reduce the size of the binary by using a custom startup code, here and there a little optimization. But I don't think I'll get it much smaller that way.
So I started writing a version completely in assembler. It has around 520 bytes now. But it also has a number of bugs and I got distracted a bit too often to finish it on time.
Here is a list of features I want to add but they will probably not fit into 1kB:
Sleep mode: Turn off all hardware and go to sleep after a period of no activity.
Wake-up: A way to wake up from the sleep mode would be very nice, no? Possible options: Button, periodic checks, a low power circuit which triggers on weight changes
Serial port: Sending the measurements to a computer.
Users: The ability to choose a user name for the measurement.
EEPROM: Store one or more previous measurements and maybe show a trend.
Calibration: A way to calibrate the scale, either using display and buttons or over the serial port.
Tara: A button or serial command to set the scale to zero.
I hope I find time to implement a few of these ideas.
Very nice. Thanks :)