Future software updates will be posted in upcoming log entries, but here is a quick summary of how the code base has evolved into what it is now.
Tower State:
The pyserial library made Python an easy choice for reading serial data from a kitchen scale. The core of the gameplay is based on reading the 'state' of the tower at any given moment. There are four different states depending on how many blocks are on the tower: on, off, pause, two off (disqualification), and collapse (see snippet from scale.py).
#set scale status variables
self.on_max = self.tower_wt + (self.avg_block_wt * self.block_variance)
self.on_min = self.tower_wt - (self.avg_block_wt * self.block_variance)
self.off_max = self.tower_wt - self.min_block_wt
self.off_min = self.tower_wt - self.max_block_wt
self.pause = self.tower_wt + self.min_block_wt
self.two_off = self.tower_wt - self.min_block_wt * 2
self.collapse = self.tower_wt - self.min_block_wt * 6
Challenges:
Determining the tower state was challenging since each block varies in weight and the weight of the tower fluctuates as players touch and pull out blocks.
See block weight distribution below in kg:

Changing state:
Matplotlib was helpful for visualizing change in state. To trigger a change in state the tower weight (blue) must fall within a range of state (grey and yellow). Simultaneously, the standard deviation (red) of the most recent data points must fall below the std trigger (black). Adjusting the std trigger changes the responsiveness. Currently it takes about about a half second to confirm a valid change it state.
Below is snapshot of a block being pulled off and placed back on to the tower (analyze.py).

Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.