How to develop an embedded product from scratch

Source: Internet
Author: User
Tags what interface

Source: How to develop an embedded product from scratch

Original address:"turn" how to develop an embedded product from scratch Rainpad

(20 of embedded experience sharing learning, from the STM32 Shenzhou Series Development Board designer summary)

first of all, if you are lucky to see this article, do not try to read in 2 hours, even if you read 2 hours, I believe you will not understand the essence of the explanation, I believe that you should be this article, slowly taste, this is absolutely a need to taste 2-3 days, and then combine their past experience, Add your own thinking, I believe that you will not only technical ability, and even the overall way of thinking will have a very big improvement. combined with this article, combined with the STM32 Shenzhou Series Development Board some learning, may deepen the understanding of embedded concepts. I write the purpose of this article is to use my 20 years of embedded experience to present to everyone a complete product, Project development Blueprint, with my many years by the calendar summed up some lessons selfless share to you, I hope you can stand on my shoulder, less detours, more for the company, for the individual to contribute more, That my desire to reach, but also hope to see everyone feedback and reply, leaving a footprint, leaving your insights and wisdom, for the posterity of the foundation, first in this thank you. so start our journey of knowledge, the most important thing is that in the development of a product or project, if there is no clear goal, then the success will not be discussed, the first step to do anything must clear the goal.
as with most things in daily life, the process of designing an embedded product must start with a definite goal and define the product as it is produced. The definition of a product is mainly about what the product is and what functions to describe, followed by our entire development process, should be to write some development documentation, the approximate framework of the following: 1Product Requirements Document: Describe the characteristics of the product 2Functional Requirements Documentation: Describe the features that the product must have 3Engineering Documentation: Describes the system implementation methods and the means to meet the requirements 4Hardware Documentation: Description of the hardware 5software or firmware documentation: Describes how to design micro programs and firmware under a specific processor 6Test Documentation: Describes the items that must be tested and how to verify that the system is functioning correctly

1. Requirements DefinitionA requirement definition is used to describe the basic functionality of a product, and for a company, the requirements are generally drawn up by the company's marketing department or the company's main customer, while for small companies or enthusiasts (like armjishu.com enthusiasts), the technician is responsible for defining requirements and writing documents For STM32 Shenzhou Series Development Board, the main is to provide a variety of interfaces, for everyone to develop products to provide reference!
Typically, requirements are defined around several factors:
1) Purpose of the system (define various functions that require system implementation)
2) The actual input and output is the way to achieve (for the selection of components to do reference)
3) Whether the system needs the operation interface (involving the software layer operating system selection)
In fact, for small embedded products, the definition of requirements is very critical, because the requirements are clear, you can avoid the subsequent development process, such as random memory (RAM) capacity is insufficient or the selected CPU speed does not meet the needs of processing a series of problems.
----------------------------------------------------------------------------------------------------------Here's a simple practical example , for your reference:
System Description: Water pump replacement system for Conghua Onsen (STM32 Shenzhou III Development Board simulation) Power input: Use 9V~12V DC pump power from Transformer: 375W 1) using single-phase AC motor, controlled by mechanical and electrical 2) if the spa pool is at low water level, The input switch closes the signal to prevent the pump from continuing to operate 3) the user is free to set the pump to run or shut down for a length of time 4) in addition to automatic control, there is also a need to provide a manual device to allow maintenance personnel flexible control of the pump for repair 5) The time of the pump on/off/manual intervention can be 30 Adjustment within 30 minutes to 23 hours 6) The display device can indicate the switch status of the pump, the remaining time, and whether the pump is in manual intervention mode 7) with the ability to monitor the low water level and display on the screen
In the case of commercial use, in addition to the functional requirements given above, the design documentation includes the requirements for electromagnetic interference (EMI) and electromagnetic compatibility (EMC) certification, safety certification, and the usage environment (including ambient temperature, humidity, salt fog corrosion, etc.).
In fact, after the above requirements are determined, the next step is to consider the choice of a suitable CPU to meet and implement the functions of the system, then we will be the above 7 users can understand the needs of the transformation into our professional field of demand, the conversion is as follows, we can refer to:
A. How fast does it take to process or update the input and output signals? Explanation: The current frequency of embedded processor is generally in a few 10 trillion to hundreds of trillion, the main frequency of single-chip microcomputer is a few 10 trillion, STM32 Shenzhou series Development Board CPU is 72MHZ, some ARM9,ARM11 processor can go to hundreds of trillion; we mainly see whether this product needs to deal with large amounts of data, Or whether there is a need for frequent operation of buffers, whether there is a similar CPU-intensive work to do, it is decided that we have to choose a suitable processor to get the best performance of the product.
B. Can a monolithic integrated circuit (ASIC) or FPGA be used to complete data processing? Explanation: If you can, you do not have to choose the processor to do, with these professional chips can replace
C. Does the system have a large number of user input and output operations (such as frequent operation of switches and display devices)? Explanation: If so, consider these factors when choosing a processor and choose a CPU that meets the above requirements.
D. What interface do I need to use between the system and other external devices? Explanation: This is also a critical issue to evaluate the processor, and choosing a processor with these interface capabilities will facilitate our circuit design and software programming
E. Is it possible to make changes after the design is complete, or is the system requirements likely to change during the design process? Does our design adapt to changes in system requirements? Explanation: To avoid the selection of the processor just meet the current requirements, so when the transaction requirements gradually increased, processor performance if there is a certain amount of space, then you can reuse the current product; the second is to choose the chip that will not be discontinued, many processors used very widely, can learn a lot of information, But it is likely that the chip has been popular in the market for a long time, chip manufacturers have introduced replacement alternatives, if you choose this chip, it is likely 1, 2 years later will not buy the processor chip, resulting in having to re-select the new processor, redesign the product, such a time-consuming, money, More labor-intensive, delaying the market's fighter jets. 2. Selection of processors
2.1. Number of I/O pins to use
Most processors use memory and external pins to control the input, usually the processor will have built-in ROM and RAM, and if the built-in memory is already satisfied, then the processor can save the pin that generates the reference to the external memory signal. This allows the processor to provide more device pins for the input and output (some processors support the use of external RAM or ROM, but when accessing external memory, the processor typically takes up to 8 to 10 I/O pins).
Also, some processors have a dedicated internal timing clock, which also requires a port pin for certain timing functions, and some processors also have a drain output and high current output capability to facilitate direct drive of the relay or solenoid coil without the need for additional driver hardware support.
When counting the processor I/O pins, we must take into account certain pins that are restricted when using the internal functions of the processor, such as serial interfaces and timers.
2.2. Number of interfaces to be used
The main function of the embedded processor is to interoperate with the hardware in the application environment, which not only requires the external hardware to have real-time processing capability to the interface, but also requires the processor to efficiently handle the interface data at a fast enough speed.
For example, STM32 Shenzhou Series Development Board CPU is an industrial-grade microprocessor produced by St company, it is based on the core of cortex M3, processing frequency up to 72MHZ, while the internal processor configuration of USB, SPI, IIC and other interfaces, The 107 processors like the STM32 Shenzhou IV also support output interfaces such as Ethernet, which are designed to make it easier to develop embedded products using these interfaces.
It is important to note that because many processors have limitations that are not adequately explained in the processor's technical data, be sure to read the processor's indicator descriptions carefully. For example, in the course of reading the material, it may be found that the serial interface can operate at the highest baud rate, but when careful study of the processor's metric data, it may be found that not all operating modes of the serial interface can operate at the maximum baud rate.
Learn more about the interface requirements: You can write your own programs to actually test the interface to see if a processor can meet the requirements of the application, because it is not a simple task to verify that a processor meets the interface requirements.
2.3. Memory capacity to use
Determining the size of the memory capacity is a basic step in the design process of embedded products, if the required memory capacity is overestimated, then we may choose a higher-cost solution, conversely, if the required memory capacity is underestimated, it is possible that the system needs to be redesigned to prevent the project from being completed on time.
The difference between A.ram and ROM: Memory is divided into random memory (RAM) and read-only memory (ROM) two kinds. Where ROM is usually used to solidify the program or data that some manufacturers write to start the computer and control how the computer works. RAM is used to access a variety of dynamic input and output data, intermediate calculation results, and external memory exchange data and staging data. When the device is powered down, the data stored in RAM is lost.
B. The memory (RAM) selection: The prediction of RAM capacity is more intuitive, we simply add all the number of variables to the capacity of all internal buffers and the first in, first Out (FIFO) queue length and stack length directly, you can get the total amount of RAM capacity. If the required memory capacity exceeds the addressing range of such a processor, then only by increasing external RAM to meet demand, however, increasing external RAM will take up a certain number of I/O pins to address the extended memory, which often affects the processor to realize the purpose of the application. One problem to note is that some microprocessors limit the use of RAM, which is designed to borrow part of the memory memory as an internal register group. In addition to these factors, the development language used also has a certain impact on the required RAM capacity, and some inefficient compilers may consume a lot of valuable ram space.
C. The choice of read-only memory (ROM): The size of the ROM required for the system should be the sum of the System program code and the capacity of all ROM-based data tables. The more difficult part of predicting the required ROM space capacity is the length of the forecast program code, and the method to solve this kind of problem can only improve the prediction precision with the gradual accumulation of experience. However, the most important thing is not to accurately calculate the code length of the program, but to clearly estimate the maximum code length. Based on experience, if 80% of Rom space is occupied by code, then it is too crowded to keep enough spare ROM space for possible changes unless there is no change to the system requirements. In most cases, we can try to write some program code in ROM, in order to observe the space of the Code, for the microprocessor system with internal ROM, the system program can only occupy limited program memory space.
D. Experience: ROM is similar to RAM usage, and the length of the program code is related to the language of development chosen. For example, a program compiled using assembly language consumes much less space than a program programmed in C. High-level programming languages are generally not advocated for small systems that pursue low-cost, because while high-level languages are easier to use, debug, and maintain, these languages require more memory space and a large number of processor clock cycles. If the development language is chosen improperly, the consequence may be to turn a simple, low-cost microcontroller system into a 64-bit embedded processor system that needs to be configured with several megabytes of RAM space.
2.4. Number of interrupts to be used
The primary use of interrupts is to notify the CPU of a particular type of event that is currently occurring, such as timer timeout events, hardware-triggered events, and so on.
It is important to emphasize that most system designers often use the interrupt function excessively, in fact, the main function of the interruption is to interrupt the execution of the current program, the interruption is most suitable for the event that the CPU must be required to provide service immediately.
If you need to design and use interrupts, be sure to first confirm the actual required number of interrupts, and then must take into account the internal system of the interruption of resources, if the need to use more than the interruption of the number of interrupts the processor can receive, we should rely on some special means to reduce the number of interrupt signals required.
2.5. Real-time processing considerations
Real-time processing is a very wide range of topics, the main content of the system is closely related to the speed of processing, real-time events are embedded microprocessors need to pay attention to the main task.
For example, when the processor communicates with the serial port, usually through the upper layer software (in order to ensure real-time, the task switching time is short enough), and then occupy the processor to perform the task of data from the serial port, and to ensure that the processor rate is faster than the serial port speed, Then the processor can respond to the fastest speed and processing the related tasks of the serial port, so that the maximum real-time performance can be achieved;
On the other hand, if the processor itself is built-in serial controller, or DMA, or LCD controller, then it can be used to directly use these processors built-in interface to control the serial port, LCD screen and other objects, in order to achieve maximum real-time performance.
2.6. Does the manufacturer provide good development tools and environment?
Choosing a new processor is likely to use a new development tool and development environment, including the software's build environment, etc., and for projects with a more stressful development schedule, developers often don't have the time to study, become familiar with new development tools, and not have a complete grasp of the use of development tools.
And, some of the development tools are more expensive, and most likely only from the manufacturer, as well as simulation tools also need to pay, these are in the choice of a processor, we should take into account the cost factors.
2.7. Processor Speed Considerations
The main considerations are several details: 1) processor speed vs. processor clock: Microcontroller 8031 As an example, the processor can adapt to the input clock of the 12MHz frequency, so you can think of it as a processor with a speed of 12MHz? No, in fact, because the processor internal logic circuit executes each instruction requires a number of different frequency clock pulses, so the internal clock circuit of the processor to the input 12MHz clock 12-way processing, and ultimately the processor is only a 1MHz frequency.
Sometimes the 80MHz processor (80MHz input clock, 80MHz execution speed) is much faster than the 200MHz processor (200MHz input clock, 50MHz execution speed).
2) Processor Instruction system
If you do not need to perform a complex number of applications, the RISC instruction set processor is fast, and if you perform more complex operations, the CISC instruction set has a faster processor speed.
3) Chip structure system
Now some of the chips are a number of different functions of the core package into a chip IC, to customize a specific function, such as DSP, including for digital decoding, multiplication of the hardware multiplier and phase shifter, etc., however, such a processor is also limited by itself, It is often necessary to use additional instructions to put the data in RAM into an internal register before performing some normal operation, in contrast to the general processor allowing direct access to data in RAM.
2.8. Selection of Read-only memory (ROM)
Most projects typically use erasable programmable read-only memory (EPROM) or fast memory (Flash memory) during their development phase, and the main advantage of this type of rewritable repeatable write memory is that it can be used multiple times. Once the product has been developed, you can use a write device (OTP) to replace the EPROM memory, the appearance and encapsulation of a one-time write device almost identical to the EPROM, the only difference is that its surface does not erase the window, and the price is much lower than the EPROM.
However, in another case, if the product needs to be upgraded in the future, or if it is programmed online, then we should choose erasable Programmable memory.
There is also a non-volatile memory, such as the manufacture of a television set, it is possible that the device has the ability to remember the last time to watch a channel, even after the power cut off, the channel information will not be lost.
Summary: Therefore, according to different products to choose different memory is also a very fastidious knowledge.
2.9. Requirements for power supply
In some design scenarios, the power supply is not a problem at all, the only requirement for power supply is that the circuit can be normal power supply; in fact, the choice of power mainly to consider three aspects of the problem:
1) Pay attention to whether the power supply is limited in the design, for example, whether it is necessary to use a power outlet in the wall of the house, as in most household appliances, or to use a USB port to power
2) to see if the system needs to be battery-powered, if so, we have to consider choosing a processor that does not require high drive current, and then select the appropriate battery for it.
3) Sleep current: Many microprocessors support low-power operation mode, in this mode, the system's CPU processor will be in hibernation, while all external equipment power supply is temporarily cut off, in order to reduce the system's power consumption, some microprocessor in this way requires minimal maintenance current, But there are also some microprocessors that do not save much power in this way; In any case, we have to estimate the operating time of the system in node mode in order to select the battery to use for the specific situation.
In short, in either case, we need to be aware of the total power supply required by the system.
2.10. Requirements of equipment working environment
The main content of environmental requirements is to consider temperature, humidity and so on, if the system must be operating in a large temperature range, such as for military equipment or automotive control system, the processor can choose a much smaller range;
And because of the large range of temperature changes in the equipment is usually more expensive, so in the design process can no longer be based on the price of general industrial devices to make budget.
2.11. Use cycle cost
If our product is Stm32 Shenzhou Development Board, in general, you can not consider the user site on the Stm32 Shenzhou Development Board program to modify the problem, also do not have to be able to get equipment spare parts and worry, this is because Stm32 Shenzhou Development Board is a learning type of consumer products, Just a development board.
In other words, if our products are tens of thousands of pieces of industrial equipment and need to be constantly running all year long, then we must take a long-range in the process of product design:
A. First, we need to select a device that can be upgraded with a processor or storage architecture. Considering the possibility of program upgrade, we also need to select a larger capacity of memory C. The last thing to note is whether the selected processor is available for a long time, which is far more important than the price of the processor.
In addition to the above considerations, the use of cycle costs is also at the beginning of the design considerations. In general, the more parts produced, the more acceptable upfront development costs will be. If the product is MP3, we may choose a low-priced microprocessor and invest a lot of money to develop software that controls MP3.
But if our products are expensive industrial equipment, then in the product use period, the equipment sales will only hundreds of units, there is no doubt that the most important to develop this product is to reduce development costs (reduce development costs and not hardware costs!!!) In addition, the cost of industrial products is not as sensitive as household appliances or consumer electronics products. To sum up, the development of industrial products should of course choose a processor that facilitates development and helps to shorten the development process.
2.12. Processor-related information is rich
If the processor is already widely used in the market, then we can obtain more relevant information, see how people's products use the processor, but also can find a lot of relevant design materials and related technical topics on the network, so as to further reduce the technical threshold, to ensure the use of the processor to do product feasibility, reduced risk; For example, STM32 Shenzhou IV Development Board has a 700-page manual document for the Board, if we choose the STM32 chip to develop products, the use of detailed information developed easily, to achieve a multiplier effect.
On the other hand, if it is a new processor, because the market has not been able to learn from the product, we can only from the full English chip manual to read, understand the chip, so that the development cycle is not only longer, and unpredictable risk is also very large. 3. Forecast and estimation of development costs
Most projects or products have a person who is responsible for predicting the development cost of the entire process, and for any project, the cost of development mainly includes human and material costs.
Predicting development costs is largely based on experience, which is why large companies typically designate experienced senior engineers to accomplish this task, in addition to the cost of manpower and materials, summed up the following costs:
1) Cost of labor costs (developers, managers, sales staff, other administrative staff)
2) material (hardware material and loss, sometimes need to cast a few times PCB version to stabilize the product) overhead
3) overhead of developing system and development tools software
4) Cost of hardware tools (e.g. oscilloscopes, emulators, etc.)
For the entire project, the above costs will directly lead to increased product costs, including the most critical human cost, especially in China, hehe 4. Product Development Design documentation (need to include two aspects of hardware and software)
4.1 Hardware Document Writing Ideas
1) First is the requirement definition or product specification:
If these are the final goals of the product, then the hardware and software requirements of the product are the ultimate goal of the technical solution, and the hardware and software requirements begin with the definition of the user interface and the system functions.
2) Secondly, according to the requirements, the whole system definition document gives the specific definition of the hardware interface:
The most effective way to define hardware is to start with the requirements, since the hardware must support all the functions defined by the system, so the hardware definition is inseparable from the system description; For example, we design a timer (pre-requirement stating that the timer cannot be connected to the PC, so the CRT display time cannot be used). We have only two options: one is to use a light-emitting diode (LED), the other is to use a liquid crystal display (LCD), although the LCD display is better, but considering that the timer should be located outdoors, and early LCD display can not work at low temperatures, Finally, the choice of LED equipment (this whole process describes our hardware selection of a way of thinking, this is closely related to demand)
3) Once the system's overall documentation has been completed, the system design begins:
The first step is to refine the contents of the hardware description, including adding the design intent to be understood by the engineer, and the hardware information that the software engineer needs to design around the hardware. After completing the hardware board documentation, we also add a preface to the document describing the original requirements of the system, including the design ideas and methods of the description scheme, as well as the various information required by the software engineer to control the hardware. This type of information mainly includes the following (software engineering required information):-----Memory and I/O port address (if required, can also provide a memory map)-----Available memory capacity-----Status register each bit of the definition-----The purpose of each port pin----- Driver methods for external devices (for example, description of clock frequency for input timer circuits, etc.)-----information needed to be learned by other tube software personnel in the design process
For more complex systems, the hardware documentation often uses two separate sections to describe the hardware metrics and how it works, and the second part provides software personnel with the information they need to program their programs.
4.2 Software Document Writing ideas
1) The software document and the hardware document organization method is similar, the software request document main content is defines the software to realize the function, one is in the simple project design process, the software definition may also give the description only to one kind of circuit board use software, for the more complex project, Since the software personnel involved in this project are responsible for designing the code that drives the different hardware parts (the same board), each software person may specify a different definition for their own design code, a software description that requires the following content:
-----Discusses the requirements of the implementation of the project including demand definition, engineering indicators, hardware parameters-----The communication protocol between the software, the processor, or between the processor and its internal devices: the content should include the buffer interface mechanism, command/response protocol, signal control and other protocols of the specific description. -----Use flowcharts, pseudo-code, or other possible methods to describe the implementation methods and procedures of the software
2) Differences in software and hardware considerations (this experience facilitates the technical director or other relevant managers for reference, because no matter how advanced technical managers, either hardware origin, or software origin, or non-technical origin, armjishu.com inside a few hardware and software are proficient in the master)
A. Software flexibility is much more flexible than hardware, and it's a difficult task to get software personnel to figure out the internal format of a software, to define the specifics of what other programmers need to know about programming interfaces, and the technical details that other engineers need to use to implement their development projects.
B. Software engineers are not likely to know how to operate the system hardware until they have received the hardware documentation, and hardware personnel generally do not need to know the technical details of the software program.
C. Because the software is easy to change, the content of the program is often changed according to the requirements of the salesperson, and in some cases the content of the software documentation does not reflect the latest changes in the program in a timely manner.
D. Software is often the last part of a project, so its documentation is often lacking in completeness due to lack of time. In fact, whether the software documentation is detailed or complete is in part related to the company's or customer's requirements. For example, military or national engineering generally requires developers to provide comprehensive and detailed documentation of all of their software-implemented functions
E. There is a unspoken rule, the more complex the requirements of the software, the less the right probability of demand, this is the experience of experience, we need to put the quasi-demand of the standard to make a fuss, rather than into the individualism and the software requirements to play their own unrealistic imagination.
F. We can design the hardware first and then compile the software around the hardware. Although the actual system implementation process may be hardware and software parallel development, but the software staff is basically around the implementation of the hardware to design, for more complex systems, the development process may be duplicated.
For example, a hardware engineer and a software engineer for a project might sit down to a meeting to decide which hardware to use to implement a function, a software person might suggest that it needs to flush memory capacity for the data buffer port, or may require an external device interface to take advantage of the various driver codes provided by the out-of-the-box interface program.
Overall, there must be a tradeoff between increasing the efficiency of software development and the complexity and cost of hardware systems. 5. Embedded expert understanding of the technology (hardships so many years of the essence of experience)
Many people think that: the core of embedded system performance is the software function, in fact, if according to this logic, the system design problems should be responsible for the software personnel; In fact, this point of view actually reflects how to design embedded products to consider dividing the hardware and software should be implemented, that is, the function is software implementation , or consider hardware (Hardware implementation: the need to buy hardware chips to deal with this function, thereby increasing the cost; Software implementation: There is no need to increase the cost of hardware, but will take up the processor and memory resources, which is what armjishu.com experts have experienced).
For example, we design the STM32-based Shenzhou II Development Board product here, we can use professional decoding chip to be responsible for MP3 music file decoding and playback function, can also use another method to decode MP3 voice file, let ARM processor use software control register to drive headphones or stereo, After decoding the MP3 voice file, the processor sends the decoded data stream to the hardware interface of the audio output in a certain protocol format.
Pros: This solution saves a device in terms of hardware, reduces costs, and facilitates debugging (because it is software-enabled).
Cons: From another point of view, while saving a piece of speech decoding chip, but at the same time to increase costs in three areas. First of all, in the program to add the Voice Protocol decoding code, second, you may want to add ROM to hold the speech decoding protocol, which can increase the speed, and finally, run the program will occupy the processor time and resources.
In fact, then again, for this case, the cost savings will not cause any problems, including the increase in the driver is only a small amount, we discuss the MP3 product case is to explain how to properly partition the function of software hardware.
In general, the more features to be delivered to the software, the lower the cost of the product, of course, the processor must have sufficient processing speed and memory space to achieve the design of the specified function; Saying goes said well, there is no free lunch; assigning functionality to software can increase software complexity, development time, And the debugging time of the program; However, with the increasing processing power of processors, it is anticipated that more and more functions will be implemented by software.
While implementing a variety of features in software can increase development costs, porting functionality to hardware can increase the cost of the product, which is unavoidable when constructing each system component. In a low-cost design, adding any additional hardware will have a significant impact on the cost of the product, so dividing the hardware and software functionality is a big problem in determining the cost of the product. In a cost-sensitive design such as mass consumer products, it is common to exclude features that cannot be implemented by software.
"End of the full text"

How to develop an embedded product from scratch (GO)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.