**3. Embedded software design**

The embedded software design is a flowchart of the two selected microcontrollers: ADUC7024 and LPC2368 used in this chapter. It is to explain the process of the power quality monitoring system based on the embedded system. For this embedded software design, there are the sampling concept, the power quality monitoring concept, data frame and the Ethernet packet structures.

A Power Quality Monitoring System

repeatedly time after time.

**3.2 Power quality monitoring concept** 

will return to the sampling condition for rechecking.

Fig. 9. Flowchart of the power quality monitoring concept

Via the Ethernet Network Based on the Embedded System 239

counted will be cleared. And if the counted data packet does not reach to the limit value, it

In case, the sampling condition is off-operation, it will change the content of the data frame, will write it to the external memory and will return to the sampling condition to be rechecked. The procedures with the two sampling conditions mentioned above are done

It is generally a conceptual method to monitor power quality used with the embedded

system of LPC2368 microcontroller board as shown in the flowchart of Fig. 9.

#### **3.1 Sampling concept**

The flowchart of the sampling concept shown below is to illustrate how the concept direction works according to the objectives of this chapter.

Fig. 8. Flowchart of the sampling concept

To explain the process of the sampling concept flowchart in Fig. 8., it is supposed to follow as the picture shown. After the used registers and utilized variables have been initialized, the procedures will work according to the conditions. That is, if the sampling condition is on operation, the procedure will do the sampling from the analog signals to the digital ones of the 3 channels. And the next procedure is to write the digital sampling data which are packed in the form of data frames to the external memory board. But if the counted data packet from the frame count value is excessive over the maximum limit, it will seek to the beginning of the first address in the external memory. Meanwhile, the data packet which is counted will be cleared. And if the counted data packet does not reach to the limit value, it will return to the sampling condition for rechecking.

In case, the sampling condition is off-operation, it will change the content of the data frame, will write it to the external memory and will return to the sampling condition to be rechecked. The procedures with the two sampling conditions mentioned above are done repeatedly time after time.
