Targeted corrections for a small mistake often made by junior engineers

Here, using a practical example, a small mistake often made by junior engineers, or a detour that often has to be taken, is targeted correction. I hope that I can help you, and the writing is not good. There are many places in the article that are unclear.
I don't want to say the normative thing of programming in this article. If you want your program file to be at least intuitive and beautiful, it is recommended to look for Huawei's "C language programming specification." I just want to say that when our microcontroller encounters multiple modules of data that need to be processed, what should we do when it is similar to "multitasking"? The background is like this. In September, an engineer began to arrange electric vehicle AC charging piles. The mechanical design part was handled by the company's mechanical structure department. The electronic part of the charging pile is generally divided into X parts (resources used), resistive touch screen (RS232), M1 card reading and writing (RS232), energy meter (RS485), voice prompt (SPI), power switch (relay) IO), communication interface (RS485, CAN). The process of the engineers was very diligent, and the period was difficult. Many versions were changed. In June of the following year, the charging pile was finally set up. Let's check it out. We found that we can't handle the touch screen when reading the card. We can't process the card when playing the voice. The voice play can't be interrupted or jumped. Anyway, all the events must be step by step. Once the operation is wrong, it needs more. Execution, waiting, and even coming back.
How can an engineer who has worked for more than 3 years make the product like this? Look at the program! It doesn't matter if you look at it! The whole program is not logical, one line is written down...While(1){//Power on into the main program or trigger touch screen //play prompt voice Delay();//Wait for playback finish//Read M1 Card information Delay (); / / waiting for card reading data return / / play prompt voice Delay (); / / waiting for playback completed / / M1 card data interaction, determine the next operation and prompt Delay (); / / wait for data processing is completed ............} It is said that this engineer basically does not have any overall concept for the product he designed, or it is unclear what kind of practical effect it will have on the design of the program he developed. He made a few of the most taboo problems we have in the process of developing programs:

1, delay (death, etc.) Such functions are only used in the process of verifying a function in the laboratory. In actual product development, whether it is in the main loop while, in the function it calls, or in the interrupt service routine. Can never be used.

2. The logical relationship between each sub-module of the product design is too strong. For example, you must wait for the broadcast to complete before you can read the card and proceed to the next step.

We say that only the logical relationship between each event processing module is weakened in product design, so that it can be processed more flexibly. For example: two events A and B, if the program is developed to make A necessary condition of B event, the trigger of B event must wait for the occurrence of A event. Conversely, if the A event is treated as a special case of the B event, then the program becomes much more flexible to develop.

3. It does not take into account that the microcontroller itself is a single-core single-task architecture. Each event will monopolize the CPU core. When multiple task modules exist at the same time, we should distinguish each event. We should divide the situation and the event real-time requirements. Treat it differently.

Targeted corrections for a small mistake often made by junior engineers

So what should we do with this kind of problem, or when we encounter similar projects?

A few suggestions:

1. Divide the hardware system into independent units and make the underlying driver function and application function separately, and the function should have parameters and return values ​​normally, and the return value is necessary. How to measure such functions? This type of function is highly portable, as long as a .h file and a .c file are free to be placed in any project. For example: voice playback, M1 card reading, 485 processing, and so on.

2. Time evaluation of all functions in 1 with two evaluation points. One is the execution time t of the function, and the second is the time T at which the function periodically occurs. One of the most basic conditions is t < T, and the ideal case should be t << T.

3. Create a centralized logic processing function in which each function in 1 is scheduled. This function works like system scheduling in an embedded system. This scheduling is the scheduling of all event processing in the entire hardware logic. Its purpose is to complete a process, but never rely on the necessary processing of any event. This weakens the logical relationship between the events mentioned in question 2, and becomes very flexible in handling, so that the relationships are not necessary for each other.

4. In order to ensure the normal implementation of the previous content, it is necessary to establish a necessary time management function for the cycle of various events. The basis of the time function is generally completed by an internal timer interrupt. The cycle of the interrupt is generally considered by us. -10ms. According to actual needs, N timer interrupts are defined as an event processing period TT, which should ensure that all ts that may occur in the worst case are processed, and TT < T is guaranteed.

5. There are exceptions to this. Some events with high real-time requirements should be completed with interrupts. The processing event of the interrupt handler should be as short as possible. See time 2 for time requirements.

Glass Fiber Film Covered Flat Aluminium Wire

About Glass Fiber Film Covered Flat Aluminium Wire

Flat Fiber glass wrapped aluminium wire for winding machine

Copper or Aluminum rectangular Wire

Narrow side size a : 0.80mm-5.60mm

Broad side size b : 2.00mm-16.00mm

Copper or Aluminum Round Wire

Diameter:φ1.7-φ5.0

If specification is out of range, please

Glass Fiber Film Covered  Flat Aluminium Wire


Fiber Glass lapped conductors (bare or enameled) are very suitable for windings of electric
motor stators, generators, special transformers and high voltage motors. In general this
insulation can be applied where high mechanical strength and high insulation properties
are required. It exhibits a very high degree of mechanical and thermal stability.
Temp. Class:F 155°C,H 180°C
Type of Insulation: Single /Double Layer of Glass Fiber
& Impregnated with Class F 155°C,H 180°C Varnish



Flat Copper Wire,Glass Fiber Film Covered Flat Aluminium Wire,Flat Aluminium Wire,Glass Film Covered Flat Wire

HENAN HUAYANG ELECTRICAL TECHNOLOGY GROUP CO.,LTD , https://www.huaonwire.com