Pulse Code Sensor Implemented by PIC Microcontroller

Publisher:亚瑟摩根Latest update time:2012-01-03 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

Introduction
With the development of society, taxis have become a very convenient and common means of transportation in people's lives, but taxi meters are relatively backward. In the past, taxis used mechanical meters, which used gear ratios to calculate the mileage of taxis and converted the mileage into fares. However, mechanical gears are large in size, the calculation is not very accurate, and they are easy to wear. Later, sensors were used to receive the running information of the car, so as to calculate the mileage and fare. However, this method usually causes interference signals to generate counting pulses, so it is also imperfect. The author quoted single-chip microcomputer technology and used encoding and decoding information transmission methods to complete the formation of meter counting pulses. The single-chip microcomputer can detect the sensor signal very accurately, so the price will be very accurate. The devices required to complete this device are simple, the cost is very low, and it is also easy to implement technically.

1 System Principle
The system block diagram is shown in Figure 1. This article mainly introduces the design of the modules in the dotted box. The transmission ratio between the number of revolutions of the taxi driving wheel and the number of revolutions of the shaft is certain, and when the shaft rotates, it drives a small magnet to rotate, and its transmission ratio is also certain. Every time the small magnet rotates one circle, it will face the magnetic induction sensor once, and the magnetic induction sensor will generate a low pulse of about 20 ms. The mileage of the taxi and the corresponding fare can be calculated by calculating the number of low pulses generated by the magnetic induction sensor.

The encoder's microcontroller detects the magnetic induction sensor signal through an I/O port. When it is determined that the signal is generated by the sensor, it sends a set of codes to the decoder's microcontroller through another I/O port. The decoder's microcontroller first determines whether the data currently to be received is the code sent by the encoder or the decode sent by the decoder writer. When it is determined that the decode is sent by the decoder writer, the decoder's microcontroller receives the decode and saves the decode to the E2PROM using the 12c bus protocol; when it is determined that the code is sent by the encoder, the decoder's microcontroller first receives the code, then reads out the decode in its own E2PROM, and compares it with the received code. If they are the same, the decoder microcontroller sends a pricing pulse to the meter through an I/0 port, otherwise it does not send a pricing pulse. Note: The encoding and decoding of each taxi meter here are different, which is conducive to the management of taxis and preventing the theft of meters. The decoding in the decoder is written into its E2PRoM using a decoding writer. Each taxi meter has an encoder and a decoder, and all taxi meters share a decoder writer. That is, before the meter is sold, the same decoder writer is used to write different initial decodes for the decoders of all meters. After writing the initial decode, the meter no longer needs the decoder writer, unless the meter breaks down and needs to replace the decoder, in which case the decoder writer needs to write the initial decode to the new decoder. The hardware circuit design diagram is shown in Figures 2 and 3.


2 Implementation of system functions
2.1 Sensors

The encoder part of this system uses sensors to receive the running signal of the taxi. The sensor used here is a magnetic induction sensor. When it is facing the small magnet driven by the vehicle shaft, the output pin of the sensor will generate a low pulse of about 20ms. 2.2 Encoder The microcontroller used in the encoder part is PIC12C508A, and the output signal of the sensor is detected by the 4th pin GP3 of the PIC12C508A chip. After detecting a certain sensor signal, the microcontroller will continuously send 5 decimal data (that is, the encoding form is a 5-digit decimal number) to the decoder at its 7th pin GP0 according to a certain timing sequence. Each data is sent out in a pulse manner. How many low pulses are sent according to the decimal number, and the time used to send a decimal data must be guaranteed to be within 255μs. The program flow chart is shown in Figure 4.


2.3 Decoder writer
The microcontroller used in the decoder writer is AT89C51, and the function of the decoder writer is similar to that of the encoder. Since the decode sent needs to be able to change at any time, 5 small numeric keyboards can be connected here, and the decode to be sent by the decoder writer can be obtained from the 5 small numeric keyboards. In order to distinguish it from the code sent by the encoder, the decoder writer needs to send a distinguishing character first, so that the decoder can identify whether the data currently received is sent by the encoder or the decoder writer. The distinguishing character is followed by the decoding. The sending method of all these data is exactly the same as the sending method of the encoder code, and is output by the P3.4 port of the AT89C51 microcontroller. The program flow chart is shown in Figure 5.

2.4 Decoder
The microcontroller used in this part is PIC12CE5C18, which has an internal E2PROM. The I2C protocol can be used to read out the decoded data from the E2PROM or write new codes to the E2PROM at any time. The working process is described below. First, the decoder reads out the 5 decimal data from 00h to 04h in the internal E2PRoM and saves them in 5 internal data storage units respectively. Then the data receiving subroutine is called to receive 1 data and save it in 1 internal data storage unit first to determine whether this data is a distinguishing character 10. If it is not a distinguishing character, it means that the data received now may be the code sent by the encoder, then continue to receive the next 4 data and save them in 4 internal data storage units, and compare the received 5 decimal data with the 5 decimal data from 00h to 04h in the internal E2PROM read by the previous decoder. If they are equal, a 2 ms low pulse is sent on the GP0 pin as a pricing pulse, and if they are not equal, the data is received again. If the distinguishing character is 10, it means that the decoder writer needs to modify the decoder's decoding. It must immediately receive the 5 data following the distinguishing character and save these 5 decimal data to 00h~04h of E2PROM, overwriting the previous decoding. The program flow chart is shown in Figure 6, and the subroutine it calls is shown in Figures 7 and 8.

Conclusion
This system solves the shortcomings of the previous taximeter, such as inaccurate pricing and short service life. Now, the coding and decoding technology with a single-chip microcomputer as the main control unit is adopted, so that each taxi meter has a different code, thereby preventing the misappropriation of taxi meters between taxis and facilitating the management of taxis by taxi companies. At the same time, the peripheral circuit of the single-chip microcomputer can be expanded at any time, and the continuous upgrading of this system can be achieved through software programming.

Reference address:Pulse Code Sensor Implemented by PIC Microcontroller

Previous article:Design of a sine wave output inverter power supply based on single chip microcomputer
Next article:Control system of jet loom based on PIC16F874 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号