5094 views|2 replies

19

Posts

0

Resources
The OP

Embedded System Design Based on PIC18F Series Microcontroller [Copy link]

Introduction Embedded systems refer to special computer systems that are application-centric, based on computer technology, and whose software and hardware can be tailored to meet the strict requirements of application systems on functions, volume, cost, reliability, and power consumption. Embedded systems are application-oriented, and the hardware selection and software development mode of the system must be determined according to the specific application. Permanent magnet brushless DC motor is one of the hot spots in the field of motor control research, which is closely related to its inherent technical advantages: electronic commutation replaces the mechanical commutation of brushed DC motors. It fundamentally eliminates a series of problems such as sparks, noise, and high failure rate caused by brush commutation of ordinary brushed DC motors, while making the system performance comparable to that of ordinary brushed DC motors, so it has been widely used. The electronic commutation of permanent magnet brushless DC motors is inseparable from the rotor position signal of the motor. The traditional method is to use Hall devices or other position sensors to detect the position signal, which makes the maintenance and manufacturing of the system inconvenient, and due to the unstable working characteristics of the sensor, it brings some hidden dangers to the safe operation of the system. Therefore, the position sensorless solution has aroused great interest. This paper combines the development of the position sensorless permanent magnet brushless DC motor control system, takes Microchip's PIC18F452 microcontroller as the main control device, and uses the embedded real-time operating system μC/OS-II as the software development platform, and discusses the development model and process of the embedded system in detail. 2. System hardware platform design
The first step in the design of an embedded system is to combine the specific application, comprehensively consider the system's requirements for cost, performance, scalability, development cycle and other aspects, determine the system's main control device, and build the system hardware platform with it as the core.
The key issue of the position sensorless permanent magnet brushless DC motor control system is position detection. At present, there are many position detection schemes, among which the back electromotive force method is widely used because of its simplicity and practicality. The principle of the back-EMF method is: based on the three-phase terminal voltage of the motor, the three-phase back-EMF zero-crossing signal is obtained through the hardware detection circuit or software algorithm, and then the software phase shift is used to obtain the phase change moment, and the phase change is completed according to the phase change logic at the phase change moment, triggering the inverter bridge to work with a suitable conduction sequence, thereby ensuring the normal operation of the motor. The back-EMF method of permanent magnet brushless DC motor position sensorless control puts forward higher requirements on the system hardware: ① Three external interrupt input pins to facilitate the capture of the three-phase back-EMF zero-crossing signal; ② At least one PWM module to realize the chopper speed regulation of the motor; ③ Rich timer resources to complete software phase shifting, speed measurement and other functions; ④ Multi-channel AD conversion module, which can sample the current and voltage signals of the speed setting and the main circuit; ⑤ Hardware multiplier to ensure the speed and current regulator The rapidity of the device; ⑥ Sufficient program and data storage for easy system expansion; ⑦ High-speed system operating frequency to ensure the strong real-time performance of the system; ⑧ Rich communication modules to facilitate the interconnection of the system with other embedded systems. For the design of position sensorless permanent magnet brushless DC motor control system, there are many special chips available for selection, but in order to further improve system performance and enhance design flexibility, DSP or special single-chip microcomputer and other intelligent devices are mostly used. However, this increases the system development cost while improving system performance. In order to design a high-performance, low-cost development platform, the PIC18F452 single-chip microcomputer is selected as the main control device in view of the application's requirements for system hardware and its high cost performance. PIC18F452 is an enhanced 8-bit single-chip microcomputer launched by Microchip. It adopts a reduced instruction set (RISC) design, has a two-stage pipeline, and can reach a maximum operating frequency of 10MIPS, which can meet the system's real-time requirements; the instruction bus is 16 bits wide and the data bus is 8 bits wide; the single-chip microcomputer has 32K bytes of FLASH program memory, 1.5K bytes of data memory and 256 bytes of EEPROM, which is convenient for system expansion; it has a built-in 8×8 hardware multiplier; it has rich interrupt resources, provides 18 interrupt sources, two interrupt priorities, and the interrupt priority is configurable. PIC18F452 microcontroller is equipped with abundant peripheral modules, which greatly simplifies the design of microcontroller peripheral circuits. At the same time, Microchip provides a powerful instruction set for PIC18F series microcontrollers, with a total of 77 instructions. Most of the instructions are stored in single words (2 bytes) and executed in single cycles. The storage compression rate of application code is high and the instruction execution efficiency is high. The hardware block diagram of the system composed of PIC18F452 as the main control device is shown in Figure 1. It is worth noting that: ① The commutation logic in the system is completed by programmable logic devices, mainly to improve the reliability of the system. From a functional point of view, it can be completely realized by the microcontroller; ② The speed detection of the motor can be calculated by software based on the position signal, so the speed sensor is omitted; ③ The analog input is the speed given signal of the motor. 3. Embedded system software development model For simple application systems, the system software development model is usually shown in Figure 2, which is called the front-end and back-end system (also called infinite loop system). In the foreground and background systems, the application is an infinite loop. The functions are called in the loop to complete the corresponding operations, which are called background tasks; the interrupt service program handles asynchronous events, which is called the foreground behavior. Because the information provided by the interrupt service program has to wait until the background program runs to process the information, the task response time in the worst case is equal to the execution time of the entire loop. Because the execution cycle of the background loop is not a constant, the application software development based on the foreground and background mode, although the design process is simple, the real-time performance of the system cannot be guaranteed. In order to improve the real-time performance of the system, a software development model based on an embedded real-time operating system (RTOS) can be adopted. RTOS is divided into two categories: non-preemptive kernel and preemptive kernel. Generally, the commercial ones are preemptive kernels, so this article only discusses this type of RTOS. Its kernel structure is shown in Figure 3. RTOS divides the entire application into multiple tasks. Each task completes a specific function and is given a certain priority. It has its own task control block and stack space. Generally, each task is an infinite loop in the program structure. It has multiple states - sleep state, ready state, running state, suspended state and interrupt state. The system kernel always lets the high-priority task in the ready state run first. The interrupt service program can preempt the CPU. When the interrupt service program is completed, the system kernel lets the task with the highest priority in the ready state run (not necessarily the interrupted task). It can be seen that the software development model based on RTOS optimizes the task response time of the system. More importantly, this development model transforms the previous function-oriented application development into task-oriented application development, simplifying the logical structure of the system design. At the same time, thanks to the RTOS, the application software's visibility to the underlying hardware is shielded, transforming the previous two-layer structure of the software system into a three-layer structure (as shown in Figure 4), greatly facilitating the system's software expansion and hardware upgrades.
This post is from Microchip MCU

Latest reply

Nice, very good post  Details Published on 2008-8-22 02:59

157

Posts

0

Resources
2
:lol
This post is from Microchip MCU

225

Posts

0

Resources
3
Nice, very good post
This post is from Microchip MCU

Guess Your Favourite
Just looking around
Find a datasheet?

EEWorld Datasheet Technical Support

Related articles more>>

    EEWorld
    subscription
    account

    EEWorld
    service
    account

    Automotive
    development
    circle

    Robot
    development
    community

    Copyright © 2005-2025 EEWORLD.com.cn, Inc. All rights reserved 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
    快速回复 返回顶部 Return list