Pulse coding sensor implemented using single-chip microcomputer

Publisher:数字冒险Latest update time:2006-08-16 Source: 单片机及嵌入式系统应用 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 taximeters to calculate the mileage traveled by the taxi using gear ratios, and then converted the fare to the mileage. However, mechanical gears are larger in size, the calculation is not very accurate, and they are easy to wear. Later, the sensor method was adopted, using the sensor to receive the running information of the car to calculate the mileage and fare. However, this method usually allows interference signals to also generate counting pulses, so it is not perfect. The author quotes microcontroller technology and uses encoding and decoding information transmission methods to complete the formation of meter counting pulses. The microcontroller can detect the sensor signal very accurately, so the pricing will be very accurate. The components required to complete this device are simple, the cost is very low, and it is technically easy to implement.

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 revolution of the rotating shaft is fixed, and when the rotating shaft rotates, it drives a small magnet to rotate, and its transmission ratio is also certain. The small magnet faces the magnetic induction sensor once every time it rotates, and the magnetic induction sensor will Generating a low pulse of about 20 ms, the mileage of the taxi and the corresponding fare can be calculated by counting the number of low pulses generated by the magnetic induction sensor.

  The encoder's microcontroller detects the magnetic induction sensor signal through an I/0 port. When it is determined to be a signal generated by the sensor, it sends a set of codes to the decoder's microcontroller through another I/O port, and the decoder's microcontroller first Determine whether the data currently to be received is the encoding sent by the encoder or the decoding sent by the decoding writer. When it is determined that the decoding is sent by the decoding writer, the decoder's microcontroller receives the decoding and saves the decoding to 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 decoding. Encode, then read the decoded code in its own E2PROM, compare it with the received code, if they are the same, the decoder microcontroller will send a pricing pulse to the pricing device through an I/0 port, otherwise no pricing pulse will be sent. Note: The encoding and decoding of each taxi meter here are different, which is beneficial to the management of taxis and to prevent theft of the meter. The decoding in the decoder is written into its E2PRoM using a decoding writer. of. Each taxi meter has an encoder and a decoder, and all taxi meters share a decoding writer. In other words, before the meter is sold, the same decoding writer is used to write different initial decodes to the decoders of all meters. After writing the initial decoding, the meter no longer needs a decoding writer, unless the meter is broken and the decoder needs to be replaced. In this case, the decoding writer needs to be used to write the initial decoding to the new decoder. The hardware circuit design diagram is shown in Figure 2 and Figure 3.


2 Implementation of system functions
2.1 Sensor The

  encoder part of this system uses a sensor to receive the running signal of the taxi. The sensor used here is a magnetic induction sensor. When it faces the small magnet driven by the vehicle's rotating shaft, the output pin of the sensor A low pulse of about 20ms will be generated.

2.2 Encoder

  The microcontroller used in the encoder part is PIC12C508A. The fourth pin GP3 of the PIC12C508A chip is used to detect the output signal of the sensor. When a certain sensor signal is detected, 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 in a certain timing sequence. Each data is pulse-based. sent out. Whatever the decimal number is, just send a few low pulses, and the time it takes to send one decimal data must be within 255μs. The program flow chart is shown in Figure 4.

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

2.4 The microcontroller
  
used in this part of the decoder is PIC12CE5C18, which has E2PROM inside. You can use the I2c protocol to read and decode from the E2PROM at any time or write new codes to the E2PROM. 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 into 5 internal data storage units respectively. Then call the receiving data subroutine to receive 1 data and save it to an internal data storage unit first to determine whether the data is the 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 it to 4 internal data storage units. The received 5 decimal data will be decoded with the previous one. Compare the five decimal data from 00h to 04h in the internal E2PROM read by the device. If they are equal, a 2 ms low pulse will be sent on the GP0 pin as a pricing pulse. If they are not equal, the data will be received again. If the difference character is 10, it means that if the decoding writer wants to modify the decoding of the decoder, it must immediately receive the 5 data following the difference character, and save these 5 decimal data to 00h~04h of E2PROM, overwriting the previous ones. decoding. The program flow chart is shown in Figure 6, and the subroutines called are shown in Figures 7 and 8.

Conclusion
  This system solves the shortcomings of previous taxi meters such as inaccurate pricing and short service life. It now uses coding and decoding technology with a single-chip microcomputer as the main control unit, so that each taxi meter has a different code, thus preventing taxis from entering each other. Mutual theft of taxi meters facilitates taxi companies' management of taxis. At the same time, the peripheral circuits of the microcontroller can be expanded at any time, and the system can be continuously upgraded through software programming.

Reference address:Pulse coding sensor implemented using single-chip microcomputer

Previous article:Pulse coding sensor implemented using single-chip microcomputer
Next article:Micropower Chinese human-machine interface design based on MSP430 microcontroller

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号