Design Research of PIC18F452

Publisher:TranquilOasisLatest update time:2012-01-31 Source: eefocus Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

This paper introduces a design scheme of a frequency meter, and applies this instrument to the measurement of the dome temperature of the 2.4m telescope in Lijiang, Yunnan Astronomical Observatory. The frequency measurement principle of the CCP module of PIC18F452 is elaborated in detail, and the design ideas of the instrument hardware and software are given. Finally, the system is simulated and tested in Proteus. The test results show the feasibility of this scheme. The development of this instrument also provides an effective measurement tool for the site selection of telescopes in the west.

Obtaining temperature data indirectly through frequency measurement is a common method for detecting the temperature of the dome of an astronomical telescope. Frequency signals not only have strong anti-interference capabilities, but are also easy to transmit. Therefore, the electrical signal generated by the temperature sensor near the dome of the telescope is converted into a frequency signal, and then the frequency signal is measured and collected, and finally the frequency value is converted into a temperature value through some determined functional relationships. Compared with the method of directly measuring temperature, this solution is more operational.

1 Frequency measurement principle of PIC18F452

PIC18F452 is a high-performance 8-bit microcontroller produced by Microchip Corporation of the United States. It has rich on-chip resources. The frequency meter designed in this article is realized by using the capture function of the CCP1 (capture/compare/pulse width modulation) module of the microcontroller. The functional block diagram of the CCP1 module working in capture mode is shown in Figure 1.

In capture mode, whenever one of the following events occurs on the CCP pin: every falling edge, every rising edge, every 4 rising edges, every 16 rising edges, CCP R1H:CCPR1L will capture the 16-bit count value of the TMR1 or TMR3 register, that is, record the moment when the event occurs. Using this function of the CCP module, frequency measurement can be achieved.

The principle of frequency measurement using PIC18F452 is shown in Figure 2: Set the CCP module to work in capture mode and let it capture data once on each rising edge. The time difference between two adjacent rising edges can be used to obtain the period of the measured pulse, and thus the frequency of the pulse.

2. Software and hardware design of frequency meter

2.1 Hardware Circuit Design

The hardware circuit of the frequency meter mainly includes two aspects: frequency measurement circuit and data communication circuit. Frequency measurement refers to using the CCP module of PIC18F452 to measure the frequency of the external pulse signal; data communication refers to transmitting the measured data to the PC through the serial port for processing. The hardware circuit of the frequency meter is shown in Figure 3.

2.2 Software Design

The main function of the software is to set up relevant functional modules to cooperate with the hardware to realize frequency acquisition and data upload. In order to achieve the purpose of real-time acquisition, the CCP module uses interrupt mode for capture. The frequency meter and PC adopt master-slave communication. PIC18F452 performs related operations according to different instructions sent by the PC. There are two kinds of instructions: start acquisition and stop acquisition. When receiving the "start acquisition" command, PIC18F452 starts the CCP module to measure the frequency and upload the measurement results to the PC through the serial port; when receiving the "stop acquisition" command, PIC18F452 turns off the CCP module, stops uploading data, and then continues to wait for the command of the host computer. The software flow chart of the frequency meter is shown in Figure 4.

3 Simulation Analysis

Using software simulation methods can not only verify the feasibility of the design in theory, but also reduce the cost and difficulty of development. This technology is very useful in development based on microcontrollers.

Proteus is a circuit analysis and physical simulation software developed by Labcenter in the UK. It can simulate and analyze a variety of analog devices and integrated circuits. It is very powerful and supports a variety of single-chip microcomputers, such as AVR, PIC, MCS-51, etc. What is more valuable is that the software can be seamlessly connected with Microchip's MPLAB integrated development environment, so that the program can be debugged step by step. The whole operation is also very simple. You only need to use MPLAB to compile the source program into a HEX file and import it into the circuit diagram in Proteus to continue the simulation test. The circuit schematic diagram used for the test is shown in Figure 5.

There are several points to note about this simulation schematic:

(1) The purpose of simulation is to verify the working condition of the CCP module of interest, so the crystal oscillator circuit and reset circuit of PIC18F452 are omitted in the figure. In fact, they will not affect the results of program operation.
(2) The simulation component (COMPIM) used in the serial communication part does not need level conversion. As long as the virtual serial port is installed and the relevant properties of the simulation component are set, the PIC18F452 in Proteus can communicate with the PC, so the MAX232 level conversion chip is omitted in the figure.
(3) COMPIM only provides a mapping relationship on the physical connection, so the connection method of the RxD pin and the TxD pin here is connected according to the corresponding relationship. In the actual hardware circuit, it is still necessary to connect according to the hardware circuit diagram (see Figure 3).

After the above work is completed, the designed circuit can be simulated and debugged. The simulation results of the program are shown in Figure 6.


As can be seen from Figure 6, PIC18F452 has measured the values ​​of several set input frequencies, and the simulation results show that the solution is feasible.

4 Hardware circuit testing

After the simulation is passed, you can build the hardware circuit according to Figure 3 to test the hardware operation. Here, VB 6.0 is used to write the host computer software, and the Access database is used to store the frequency data uploaded by PIC18F452. The operation effect of the system is shown in Figure 7 and Figure 8.

5 Conclusion

At present, the frequency meter has been successfully applied to the temperature collection work of the 2.4 m dome in Lijiang, Yunnan Observatory. In the future, the instrument will be expanded and improved (for example, adding a data storage module to the instrument), and then the instrument will be able to adapt to the field working environment, which is of great practical significance for the site selection work of the western telescope that is about to begin.

Reference address:Design Research of PIC18F452

Previous article:PIC microcontroller port expansion technology based on I2C bus
Next article:Design of IC card intelligent water meter based on PIC16F84 single chip microcomputer

Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号