This Dezyne example is Mark Weber’s submission for the Dezyne Challenge 2016. The example illustrates Mark’s experiments in building a scale with the possibility to process the measured weight.
According to Mark, measured weight processing scales are commercial available, but way too expensive for a fun application and not suitable to build in your own enclosure. So, Mark raised a valid question: why not try to model this project in Dezyne?
The site of SparkFun explains exactly how to build a scale and which components are needed:
a load cell, i.e. a piece of metal with a strain gauge glued to it.
an ADC to readout the load cell.
an Arduino to readout the ADC and process the measured value.
The modelled system consists of:
an interface to enable / disable the scale.
a display interface, which can be in fact any other module for processing the data.
a tare interface.
a serial protocol to readout the ADC.
The Modelled Functionality
Auto zero calibration
When enabling the scale, the first measured weight is considered the tare value. This value is stored and all future measurements are compensated with this value.
This can be used to do a new zero calibration at anytime. It was a nice little exercise which showed how to process data: send the measured weight out of the Dezyne model and return a corrected value.
The system periodically measures the weight and sends it to a display. I think it is valuable when Dezyne would offer timers in a kind of library.
The serial protocol to readout the ADC
It makes use of a register, a data bit and a clock bit. The datasheet of the ADC (HX711) describes the protocol. This was the most educational part to me, because I do not have experience with this kind of interfacing. Basically it is generating a clock pulse, reading the data bit and writing it into a register until it is full. Then wait until the ADC indicates a new measurement is available.
The Serial Protocol
Dezyne is A LOT easier to use and more intuitive to programmers than ASD.
By modelling it this way, it becomes clear how much complexity there is in such a simple system.
The project files can be found here.
Note that all of the diagrams included in this document have been produced in and exported from Dezyne. The System View and State Charts are part of the Dezyne editor.