当前位置:网站首页>[Shenzhen IO] precise Food Scale (some understanding of assembly language)
[Shenzhen IO] precise Food Scale (some understanding of assembly language)
2022-07-01 07:09:00 【Messenger big tooth】
Steam game : Shenzhen IO
In the near future , Contact Shenzhen IO This game , In the main task of learning the deep learning network, the branch task of assembly language is started , I found it interesting to learn assembly language , But also quite exercise programming thinking .
As a little white who has never learned embedded system or assembly language , At present already “ play ” 了 38h, Here we go Accurate food scale this , Record some understanding .
Ironically , This “Shenzhen IO” The game cannot be played in the national service , You need to register an overseas account .
Precise food is called functional requirement

It is no different from the electronic scales we use everyday , This scale has “ Turn it on ”,“ To turn it off ”,“ Net weight ”( peel ) These three functions .
Code implementation

The idea of this design and implementation is very simple , The chip on the left is used to judge the current state of the electronic scale , Press down “ Button ” after , It should be turned on (dat Set up 1), Or turn it off (dat Set up 0), Or record the tare weight , And clear the current weight (dat Set up 3).
This design can really meet the requirements , But look at the results , The segment that belongs to the tail of the crane among global players .
The best way to see the product cost is ¥5, There's no doubt about it :
This electronic scale can use a MC6000 Realized !
Code optimization ideas
When learning advanced languages , Will often apply Combine several simple logic , Do complex functions The logic of , in other words , Sometimes code , Fine “ Without brains ”, As long as the conditions , Simply and crudely knock it all out .
But that's how it works , In compiling this “ low-level ” Language , It often doesn't work , Mainly because : The chip limits the number of lines of code , And the ability of assembly language in nested logic , Higher level languages are really hard to use .
At least in Shenzhen IO This game is like this , Involving nested logic , It's really a headache , And high-level languages directly write more layers if That's it
So when using assembly , It has to be “ With brain ”, Before you write a program, think about how the code can be streamlined and smart . And the most important method that I summarize personally is : Conduct Conditional merger , Find the key conditions .
Code optimization methods
Signal Planning
If only one piece is used MC6000 chip , That can be operated acc Must be used for net weight ,dat Used to record tare ( Input as gross weight )
Condition sorting
The core focus of this design task & The difficulty lies in how to distinguish “ Turn it on ”,“ To turn it off ”,“ Zeroing ( peel )” These three functions .
① Startup conditions
- Button =100
- weight ( Gross weight )=0
- tare =999( The state before power on must be turned off , The shutdown status is defined as net weight =-999)
② Shutdown conditions
- Button =100
- weight ( Gross weight )=0
- tare =0
③ Set zero condition
- Button =100
- weight ( Gross weight )>0
- tare =0( The tare weight is still 0, In the next state , The tare weight will be equal to the gross weight at this time )
Now let's start sorting and merging , First , The three functions can be combined into two , Starting and zeroing are essentially a state ( Boot tare is 0)
Next , As long as from the above conditions , find The simplest sufficient condition to distinguish between shutdown and zero setting states That's it .
That's it :
① Set zero condition
- weight ≠ tare
② Shutdown conditions
- weight = tare
Find this condition , You can build a new design .
Design optimization

Running results ,world best design!
边栏推荐
- Unity2021-Scene视图中物体无法直接选中的解决办法
- [image processing] image histogram equalization system with GUI interface
- Product learning (II) - competitive product analysis
- The programmer of Beipiao posted a post for help late at night: I am lonely when my girlfriend is gone
- 运维管理系统,人性化操作体验
- How to use Alibaba vector font files through CDN
- [network planning] (I) hub, bridge, switch, router and other concepts
- 运维面临挑战?智能运维管理系统来帮您
- 自动化测试平台(十三):接口自动化框架与平台对比及应用场景分析及设计思路分享
- Esp32 monitors the battery voltage with ULP when the battery is powered
猜你喜欢
![[lingo] find the minimum connection diagram of seven cities to minimize the price of natural gas pipelines](/img/34/d2efae5b283cdc130d55f52cdff76d.png)
[lingo] find the minimum connection diagram of seven cities to minimize the price of natural gas pipelines

JSP - paging

微软宣布开源 (GODEL) 语言模型聊天机器人

Esp32 - ULP coprocessor reading Hall sensor in low power mode

Pourquoi tant de gens sont - ils devenus des gestionnaires de produits? Quelles sont les perspectives de développement des gestionnaires de produits?

(I) apple has open source, but so what?

Product learning (III) - demand list

Code practice - build your own diffusion models / score based generic models from scratch

如何进入互联网行业,成为产品经理?没有项目经验如何转行当上产品经理?

ctfshow-web354(SSRF)
随机推荐
DC-4 target
AI视频智能平台EasyCVR设备录像出现无法播放现象的问题修复
关于“2022年度网络安全教育线上培训”相关问题的复盘和说明
Chinese explanation of common rclone subcommands
【分类模型】Q 型聚类分析
Docker installation and deployment redis
Cadence OrCAD Capture “网络名”相同,但是未连接或连接错误的解放方案之nodename的用法
EasyNVS云管理平台功能重构:支持新增用户、修改信息等
Subclasses call methods and properties of the parent class with the same name
Product learning (II) - competitive product analysis
JAX的深度学习和科学计算
【推荐系统】美团外卖推荐场景的深度位置交互网络DPIN的突破与畅想
JSP - 分页
[Tikhonov] image super-resolution reconstruction based on Tikhonov regularization
[Electrical dielectric number] electrical dielectric number and calculation considering HVDC and facts components
Esp32 esp-idf ADC monitors battery voltage (with correction)
Félicitations pour l'inscription réussie de wuxinghe
Problem: officeexception: failed to start and connect (II)
电脑有网络,但所有浏览器网页都打不开,是怎么回事?
Record an online interface slow query problem troubleshooting