硬件产品设计

You might also like

Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1of 26

硬件产品设计

整体流程

毕业设计主要关注 1、2、3、4 阶段

自研产品的公司,还需要进行 MD、ID

https://www.freertos.org/zh-cn-cmn-s/tutorial/index.html
该应用程序将在嵌入式单板计算机上执行,计算机必须在控制设备的同时,维护
本地和 远程用户接口。

如上所述,系统由以下部分组成:

控制终端内的嵌入式计算机。
两个现场总线联网传感器。
受控设备(可以是电机、加热器等任何东西), 需连接到同一现场总线网络。
使用通用 IO 扫描的矩阵键盘。
两个 LED 指示灯。
LCD 显示屏。
远程监控计算机可以与之连接的嵌入式 Web 服务器。
在 PDA 上运行的配置实用程序的 RS232 接口。
软件需求
在本教程中,我们更关注排序和时序要求,而不是确切的功能要求。

设备控制
每个控制周期均应按以下顺序执行:
在现场总线上传输帧,以从联网传感器请求数据。
等待从两个传感器接收数据。
执行控制算法。
向设备传送命令。
嵌入式计算机的控制函数每 10 毫秒发送一次请求, 生成的命令应在此请求后 5
毫秒内发送。 控制算法依赖于准确的时序,因此满足这些时序要求至关重要。

本地操作员接口
操作员可以使用键盘和 LCD 来选择、查看和修改系统数据。 设备受控时,操作员
接口可起作用。
为确保没有遗漏按键,应至少每 15 毫秒扫描一次键盘。 LCD 会在按键后 50 毫秒
内 更新。

LED
LED 灯用于指示系统状态。闪烁的绿色 LED 灯表明 系统正按预期运行。闪烁的红
色 LED 灯表明发生故障。
正确的 LED 灯应每秒闪烁一次。 此闪烁频率应维持在 50 毫秒以内。

RS232 PDA 接口
PDA RS232 接口可查看和访问的数据与本地操作员接口相同, 两者需遵守同样的
时序约束条件,即减少数据传输次数。

TCP/IP 接口
嵌入式 Web 服务器应在一秒钟内处理 HTTP 请求。

应用程序组件
该虚构系统的时序要求可分为三类:
严格时序 -设备控制
控制函数具有非常严格的时序要求,必须每 10 毫秒执行一次。

灵活时序 - LED
虽然 LED 输出具有最大和最小时间约束,但可以发挥作用的 时间范围较大。

仅限截止日期时序 - 人机接口
这包括键盘、LCD、RS232 和 TCP/IP 以太网通信。

人机接口函数具有不同类型的时序要求,仅指定了最大限制 。 例如,必须至少每
10 毫秒扫描一次键盘, 任何高达 10 毫秒的频率均可接受。

芯片引脚
概念图
连接设计图(主要体现时钟和信号的连接)

实际原理图(还有外围电路,R/C/L,有参考设计,可以直接对 AutoCAD 的原理


图截屏)
机械设计 MD

mechanical Design
Creating a well-tested reliable embedded software is important, especially in safety-
critical applications. A great design starts with a well thought system design. Following the
system design, embedded hardware design and software design will take place with high
clarity. In this article we mainly focus on embedded system design.

Embedded system design is based on software development processes and life cycle,
using any of the popular models such as the waterfall model, the V-Model and nowadays
most of the software houses use the agile methodologies.

Embedded System Design Overview

Why do we create software? This question is a basic question, the answer is to solve a
specific problem based on some requirements. Another important question, how do we create
software? The answer is in the following figure, which is an example of a software
development life cycle. There are 5 stages in the following model, the waterfall model.

Requirements Analysis
Design
Development
Testing
Maintenance
In the first stage, the requirements should be collected and the software requirement
document is written. In the design phase, we answer the question “how to build the
solution?”. In the SW development phase, we start to implement the software and write the
code. In the testing phase, we verify the proposed solution to produce high-quality software.
After deployment of the solution, we maintain it if needed in case of changing the
requirements.

Our scope here is on the design phase, our input is system/requirement specification and,
the output is the design document.

The Design document can be a physical Document or a code skeleton. There are two
types of software design a static design or a dynamic design.

In the static design, you define the structure, the structure includes modules and how
they connected. On the other hand, the dynamic design defines how the modules interact
together.
As an example, in a football match, consider the plan of the team (e.g. 4-4-2) as the
static design and consider how they move as the dynamic design.

Another example from the definition of the real-time system, a real-time system is a
system that has to perform a correct function at a correct time.

Static design is responsible for executing the correct function, on the other hand, the
dynamic design enables the function to be executed at the correct time.

Embedded Software Design Characteristics

Good software design has three main characteristics. Your software design should be
correct, meaning, that everything is correct and nothing is wrong from gathering,
requirements (inputs), so your design solution should meet these requirements. The second
one, the software design should be understandable, and it means that any stockholder should
understand the design regardless of his/her background, however, we do a lot of reviews
between the team members to clarify the design. The third characteristic of a good embedded
software design is to be maintainable; we mean here that the system should allow editability,
in case of changing the requirements, we can change the design without damaging any other
part or any other component in the system.
Software Design Levels

When creating a design, it can be done through steps, as example, when facing a big
problem, we try to solve it by cutting it into smaller parts “Divide and conquer approach”.
As you can see in the figure, we have divided the system into subsystems, and also have
divided each subsystem into modules and submodules.

For example, consider you are working on a microcontroller project, we can map the
design outputs to c code as

— System is the IDE Project

— Sub-system is the group of files

— Module contains on functions’ definition in 1 C file or more header files

— Sub-module contains data types, variables, and the implementation of the functions.

Pragmatic Software Design

To make your design pragmatic we should have


The Concept is what you have studied and your previous experience as a designer. The
more concept, the better. The context is how you can use and apply your knowledge to
achieve pragmatism.

The goal of pragmatic software design is to determine and organize how we reach the
optimal solution. Keep in mind always the following slogan “if you fail to plan, you plan to
fail”, so you need to organize and plan before implementing your solution.

Elements of Embedded software Design

There are some questions you should ask yourself before starting your design process

How to identify modules:


– using context diagram

OR

– using Super loop and block diagram

How to identify modules’ interfaces

– apply 4 rules in the software design process

How to identify dynamic design or behavior

– using interfaces classification

– using timing analysis

– do schedulable check

How to identify modules’ details

– using Pseudo code

– using state machines

Case Study – A Digital Clock


This is a design example of a digital clock with 3 modes/buttons

Normal
Set hours
Set mins

Let’s look at the first question “How to identify modules: ”

Context diagram 外部视图、概念视图


From the context diagram, we can understand what are the inputs and what are the
outputs

Super Loop as a design tool

Identify modules of the digital clock:

Void main (void)

while (1)

pushButton.update(); // Input taks

TIME.update(); // Processing Task

sevenSegmentDisplay(); //Output Task

}
}

Block Diagram 内部、外部联合视图

In the block diagram, we divide the modules in the context diagram. There is always an
operation system (e.g. real-time system, while(1), simple scheduler)

In the figure, we have modules such as:

Switches (SW) is used to set the hours, mins and change the modes
OS is used (to set the rules of the software)
Seven Segments Display (SSD) is used to display the time
Time module is used to send the time and the mode to display (SSD)
Display module (DISP) is used as a generic module to allow us to change display block
e.g. from seven segments to LCD

from the static design Perspective, any module should have

Initialization function is used to


Initialize hardware
Initializes data structures

Initializes both

1 or more update functions


Update something

Do the module logic

0 or more setter functions


Set something in the module

0 or more getter functions


Get something from the module

The above figure applies the rules to the digital clock use case
A push Button Module

This is another module in our system (push button)

The push button module is used to identify the state of the button to show us if it is
pressed or not

Setter or a getter?

If we have 2 modules connected together


We have 2 options:

M1_Getsomething

Implemented in M1 and called in M2

M2_SetSomething

Implemented in M2 and called in M1

Modules’ Interfaces of the digital clock

Switch

SW_Init
SW_Update
SW_GetState

OS

OS_Init
OS_Update
OS_Sleep

TIME

Time_Init
Time_Update
Time_GetTime
Time_GetMode
DISP

DISP_Init
DISP_Update

SSD

SSD_Init
SSD_Update
SSD_SetSymbol
SSD_GetSymobl
SSD_SetState
SSD_GetState

From the dynamic design perspective, we can classify the functions into 4 types

Initialization
Called just one time before using the module

Task
Period or aperiodic and it is called by the operating system

ISR
Period or aperiodic and it is called by the hardware
Function
It is not like any of the above types and it can be called by any other function.

Similarities between static and dynamic design:

Initialization is the same in static and dynamic design. Update in the static design is task
and ISR in the dynamic design. Setter and getter in the static design can be functions in the
dynamic design.

To apply them in our use case

pushButton_Init is an initialization function


pushButton_UpdateState can be task or ISR
pushButton_UpdatePressTimeMS is a task
pushButton_GetState is a function
PushButton_GetPressMS is a function

Timing Analysis of a function

We have many parameters to be used in timing analysis

E is the Execution time

BCET is the best-case execution time (the max time to be done)


WCET is the worst-case execution time (the min time to be done)
B is the blockage (interruption + preemption) that can be discovered after system
integration

D is the deadline (based on the requirements)

P is the period (design choice)


BCET <= WCET and B +E <= D <= P

Schedulability Check

If the functions are not periodic, change the period with the minimum interarrival time.

Worst-case design (E = D = P)
No multitasking

Relaxed worst-case design (E < D = P)


The first design check

Blockage is considered after integration (B+E < P)


Schedulability check

Timing Analysis and Schedulability check the digital clock use case
The following table has the timing analysis and the Schedulability check of our use case

Conclusion

In this article we have introduced, how to create a pragmatic embedded software design
step by step. Embedded software design is important to meet the requirements of any system
software. What to do next? Try to implement apply the principles of embedded software
design on any embedded system you know and then implement the system using any
microcontroller.

References

Embedded System Design, Embedded Systems Foundations of Cyber-Physical Systems,


and the Internet of Things, Authors: Marwedel, Peter

Embedded Systems Architecture 2nd Edition, Author: Tammy Noergaard

You might also like