Design of Electronic Test System Based on FPGA Chip of EP1C6Q240C8
Veröffentlichte Zeit: 2020-08-04 10:54:12
In large industrial sites, some large cranes are often used to transfer goods. These cranes are often as high as ten meters or even tens of meters. Under normal circumstances, the crane operator often judges the height of the hook based on experience, or judges the position of the lift based on the command of the personnel on the ground. The disadvantage of this is that the accuracy is not enough. Due to the observation by human eyes, there will be a large visual deviation. At the same time, additional personnel are required to command, which increases unnecessary waste of human resources. Based on the above considerations, this paper designs an electronic test system for testing the lifting height of the hook.
According to the on-site measurement, the hook rises faster and the on-site environment is harsh. On the one hand, the speed cannot keep up with the ordinary single-chip microcomputer. On the other hand, considering the stability of the system, the choice is now more and more widely used. FPGA to design.
1. The principle of the system
This system uses sensors to detect the number of pulses, and then converts the counted pulses into length units to measure the actual height of the hook. The specific process is as follows:
First, the photoelectric encoder fixed on the main motor collects the number of pulses rotated by the lifting height of the hook. The pulse signal is sent to the FPGA through the signal line to be processed and then counted, and then the pulse-to-height conversion is completed through the FPGA, and The height of the hook is displayed. The system block diagram is shown in Figure 1.
The main tasks completed by FPGA are:
(1) Set the height, the diameter of the main motor wheel and the number of pulley sets.
(2) Height measurement.
(3) Display the actual height.
The setting of height, diameter and pulley set is done through the band switch. The input of pulse number is sent directly through the pulse collected by the photoelectric code disc. The display is displayed with four LEDs.
2. FPGA implementation
What this text adopts is ALTERA company's EP1C6Q240C8 type FPGA, the whole system adopts the idea of modular design, each module is described in VHDL language and then connected.
2.1 Parameter setting module
This module converts the input height and diameter into decimal height value and unit pulse width. Used for subsequent calculations. Among them, B1[11..0] and B2[11..0] are the binary numbers actually entered. The entered quantities are the height and the wheel diameter of the main motor respectively. These parameters are set according to the actual situation and manually input through the band switch. Since this system uses a 12-bit band switch, the maximum integer input is 4095, the accuracy of the diameter can reach the millimeter level, and the height accuracy can reach the centimeter level. Since the system presets a height of 20 meters, it is determined The band switch is 12 digits, and in practice, the number of digits of the band switch can be specifically set according to the actual site.
The input binary quantity is converted by the module into the width of the unit pulse (unit is one tenth of a millimeter) and the set height value (unit is cm).
2.2 Pulse input module
In practice, in order to reduce the load of the motor, some movable pulleys are often used, so the actual height of the lifted weight and the number of turns of the main motor have a multiple relationship. This coefficient is related to the number of pulleys, so the actual There is also a multiple relationship between the counted pulse number corresponding to the height of the heavy object. The function of this module is to convert the pulse width and set height input previously, and the number of pulley groups into the set main motor through calculation. The number of pulses.
In this module, in the process of converting pulse width and set height to pulse number, since FPGA cannot perform floating-point operations, all operations in it must be converted into integers for operations. Here we use the most basic The calculation method of rounding, that is, when the one-tenth of the number of pulses is greater than five, the set number of pulses is added by one, and if the calculated number of pulses is less than five, it is rounded off.
2.3 Counting module
The module is composed of four basic two-way up and down counters 74193, the output value is 16 bits, the maximum can count up to 65535, through the input of different ports to control the pulse addition and subtraction operation, the input is the set number of pulses, It is output by the pulse input module. It is the number of count pulses obtained through parameter setting. The actual height is based on this set pulse and performs corresponding addition and subtraction operations.
2.3.1 Digital filter module
The field environment requires a large transmission distance of the signal line (50 meters), and the received pulse signal is severely distorted.
Since the pulse count is recognized by the rising edge of the square wave, the burr in the signal causes the FPGA to be unable to accurately identify the number of pulses, so certain filtering methods must be used. The traditional filtering methods are mostly completed by analog circuits. Digital circuit filtering is used in FPGA to truly realize the system on chip.
The principle of filtering is to adopt the sampling method of "moving window". By setting the width of the "window", the high and low levels of the square wave can be well collected, and the burrs can be filtered out. The waveform after filtering is shown as the waveform below in Figure 2. After waveform simulation, it is found that the waveform signal is obviously better after filtering. At the same time, the filtering method can set the width of the "window" according to the width of the acquired waveform, so that the versatility is well realized.
2.3.2 Frequency division module
In the filtering process, the sampling frequency of the signal is very critical. The usual sampling frequency is determined according to Shannon's sampling law. This article is based on site requirements. In order to improve accuracy, the sampling frequency is set to 100 times the signal frequency. The crystal vibration frequency provided by the system is 50M, and the required sampling frequency is 10KHZ, so two frequency division modules are used to complete the conversion from 50MHZ frequency to 10KHZ frequency. This article uses two frequency division modules to achieve frequency division. First, divide the frequency of 50MHZ into 200KHZ, and then divide the 200KHZ into 10KHZ, which is the frequency required for sampling.
2.3.3 Orientation detection
Since the hook may go up or down during its travel, this system uses a phase detection system to detect the direction of movement of the hook, and then performs addition and subtraction operations based on the characteristics of the addition and subtraction counting module. As shown in the figure, the input A and B in the figure are pulse signals after passing through the filter circuit. The output signals AOUT and BOUT are the results of phase detection. The pulse signal AB sent by the sensor is 90 degrees out of phase. If the high level of phase A is detected first, then AOUT outputs a phase A pulse, and BOUT is always high Level. Conversely, if the high level of phase B is detected first, then BOUT outputs a pulse of phase B, and AOUT is always high. Send AOUT and BOUT to the counting module to complete the up and down counting function.
2.4 Pulse-height conversion module
The function of this module is to convert the actual calculated pulse number into the corresponding actual height value output display, the input quantity is the unit pulse width Cn[9..0], the number of pulley groups n[3..0] and the calculated pulse Number load[15..0]. The output is the actual height loadToBCD[13..0], the actual height is the height of the weight, and the count pulse is the number of turns the main motor has turned, and there is a conversion of the multiple relationship of the pulley block between them, that is:
The distance traveled by the weight = (the number of pulses × the width of the unit pulse) / the number of pulley sets
In the process of calculation, in order to improve the accuracy, this article also uses the rounding algorithm, but the improvement of the accuracy is based on the increase in the consumption of logic units in the FPGA, and it also affects the speed of the calculation.
2.5 Integer-BCD code conversion module
The actual height needs to be sent to a four-digit LED digital tube for display. The height number output by the pulse-height conversion module is an integral number, which needs to be converted to BCD code before it can be sent to the seven-segment drive circuit for display.
2.6 Other modules
2.6.1 Alarm height setting module
In order to ensure that the driver will not encounter any unexpected situations during the operation of the hook at the scene, there is often an alarm point. When the hook reaches this point, the buzzer will sound an alarm. The alarm height set in this article is 1 meter, and the system can set the alarm point arbitrarily according to the actual situation.
2.6.2 Alarm height output module
As the pulley block is involved, it is necessary to convert the set height to the distance the main motor rotates, and then convert this distance and the corresponding pulse number alarmout[15..0] to output.
2.6.3 Alarm comparison module
This module compares the number of pulses converted by the module shown in Figure 12 with the actual number of pulses counted. If the height corresponding to the number of pulses reaches the set alarm point, the buzzer will sound to remind the driver.
This article changes the traditional design method and adopts advanced FPGA design, which solves the slow speed and poor stability of software design. The FPGA with good performance, high speed and good flexibility is introduced into the design, and a set of position measuring instrument that can be used in harsh environments is designed.