Multi-layer pipe string electromagnetic flaw detection logging system based on electromagnetic induction

Publisher:码字先生Latest update time:2015-07-30 Source: eefocus Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere
Overview

Design background and significance

The problem of casing damage in oil and gas fields (hereinafter referred to as casing damage) is a common technical problem encountered in oil development at a certain period of time, and oil fields at home and abroad are all troubled by this problem. With the application of various production-increasing measures such as high-pressure injection and production, ultra-high-pressure fracturing, and the increase in oil field development time, mudstone water absorption creep, rock layer sliding, oil layer sand production, fault resurrection during oil field development, perforation, natural earthquakes, oil layer compaction and other reasons, the problem of casing damage in oil and water wells in various oil fields will become more and more serious.

 

The oil wells in major oil fields in my country have been severely damaged. In 1997, 576 wells in Daqing Oilfield had damaged casing, and in 2001, more than 700 wells had damaged casing. The entire oil field has accumulated more than 8,000 wells damaged. As of April 2003, Shengli Oilfield had more than 5,400 damaged wells.

 

The existence of a large number of casing damaged wells is not only a waste of fixed assets, but also leads to a gradual increase in formation pressure drop, a deterioration in reserve control, and a loss of varying degrees of water drive reserves and recoverable reserves in the oil field. Therefore, casing damaged wells are a bottleneck problem that restricts the stable production of oil fields. Carrying out research and application of casing damage prevention and control technology, clarifying the casing damage mechanism of complex formations, seeking corresponding preventive measures, and extending the service life of casing are one of the issues that need to be urgently solved in the world's casing damaged well oil and gas fields, which is of great significance to improving the overall development efficiency of old oil fields. In such an environment, well logging shows an important role and is listed as one of the top ten disciplines in the petroleum industry.

 

At present, there are many methods of engineering logging instruments used for casing detection, including caliper, ultrasonic imager and electromagnetic detector. Among them, the caliper has very high requirements for the centering of the instrument. Eccentricity will cause measurement errors, and the instrument is not suitable for wells with serious casing misalignment; the ultrasonic method is greatly affected by the drilling fluid. If the drilling fluid density is high, the sound wave attenuation is serious, affecting the detection accuracy. The well must be washed and the drilling fluid must be replaced before detection, which increases the labor intensity. The electromagnetic detector evaluates the integrity of the casing based on the electromagnetic principle. It is not affected by the well fluid, casing scale, wax deposition and well wall attachments, and has a relatively high measurement accuracy.

 

The Russian multi-layer tubing electromagnetic flaw detection imaging logging instrument MID-K uses electromagnetic theory for flaw detection. In China, research on electromagnetic flaw detection is also a hot topic, but most of it is focused on theoretical research. The performance and detection accuracy of the designed electromagnetic flaw detection logging system are not very good. Therefore, we want to design a high-performance and high-precision electromagnetic flaw detection logging system based on the PIC32 32-bit microcontroller.

 

Basic Principles of Casing Inspection Using Transient Electromagnetic Method

The transient electromagnetic method, also known as the time domain electromagnetic method, is based on the theory of electromagnetic induction. A bipolar DC pulse is passed through the transmitting coil. When the current in the transmitting coil changes, a magnetic field will be generated around it. This magnetic field is called the primary magnetic field.

According to the electromagnetic penetration theory in conductors, the magnetic lines of force pass through the tubing into the casing, generating induced currents and in the tubing and casing respectively (as shown in Figure 1). After the DC pulse ends, the secondary magnetic field generates an induced electromotive force in the receiving coil . If there are cracks in the casing or tubing, especially longitudinal cracks, the path of the induced current and will be partially or completely cut off , which will reduce the decay time of the induced electromotive force.

 

Figure 1 Schematic diagram of probe detection principle

Figure 1 Schematic diagram of probe detection principle

 

mathematical model

The single-turn loop including equivalent inductance Lc and equivalent resistance Rc shown in Figure 2 is used to equalize the inductive current loop. The two have similar rules.

 

Figure 2 Schematic diagram of the equivalent circuit of a finite conductor

Figure 2 Schematic diagram of the equivalent circuit of a finite conductor

Among them, emf is the induced electromotive force, is the induced current,  is the equivalent resistance of the pipe column, and is the equivalent inductance of the pipe column. Assuming that the magnetic flux of the equivalent circuit cutting off the primary field is , the transient equation of the equivalent circuit is:

 

        (1)

Right now         

              (2)

in

is the equivalent time constant.

 

Solving differential equation (1) or (2), we get the transient current equation:

(3)

 

Since the excitation source waveform changes in the coil in actual work, the emission waveform is mostly an oblique step wave. Assuming that the field is an oblique step change, and is the off time of the bipolar DC pulse, then the magnetic flux will decrease rapidly from to zero within the time , which can be expressed as:

 

      (4)

According to Faraday's law of electromagnetic induction, the induced electromotive force generated in the equivalent circuit is given by , so the expression of the induced current in the equivalent circuit can be obtained as:

 

        (5)

 

From equation (5) , the induced voltage observed during a field pulse interval ( ) is obtained as

 

  (6)

in the case where

         (7)

 

Where and are the mutual inductance coefficients between the transmitting coil and the equivalent circuit, and between the equivalent circuit and the receiving coil, respectively. They are related to the relative positions between the transmitting coil, the receiving coil and the pipe column, and the geometric shape of the pipe column. When the coil and the pipe column are determined, the parameter is regarded as a constant; the induced electromotive force of the receiving coil is related to the impedance and of the pipe column , and the impedance and are determined by parameters such as the geometric shape, inner diameter, outer diameter, conductivity and magnetic permeability of the pipe column. Therefore, a functional relationship can be established between the induced electromotive force in the receiving coil and the above parameters. The geometric shape, size and changes in electromagnetic parameters of the pipe column can be judged by the induced electromotive force of the receiving coil. This is also the principle of using transient electromagnetic method to detect the pipe column.

Signal attenuation characteristics

It can be seen from formula (7) that the received induced electromotive force is close to an exponential decay curve. According to electromagnetic theory, the thicker the steel pipe is, the slower the induced electromotive force decays, and vice versa. In the decay process of the induced electromotive force, the smaller time period mainly represents the change of the inner pipe, and the larger time period mainly represents the change of the outer pipe. This method can distinguish the influence of the inner and outer pipes, which has been proved and verified from both theoretical and experimental aspects.

 

During transient electromagnetic detection, the decay rate of the abnormal amplitude of the induced voltage observed by the receiving coil on the pipe string is largely determined by the time constant value . In the case of a large value, although the amplitude of the initial response is not very large, the signal decays very slowly. The typical decay time ranges from 100us to 20ms, spanning nearly two levels. In such a wide time range, the law of signal decay is shown in Figure 3. In the early stage, the signal amplitude is high and the decay rate is very fast; in the late stage, the signal is very weak, but the decay rate is much slower. For the same observed signal, the signal amplitude changes from a few volts to tens of microvolts from the early stage to the late stage. Signals within this large dynamic range generally require accurate measurement.

 

Figure 3 Schematic diagram of transient electromagnetic signal sampling

Figure 3 Schematic diagram of transient electromagnetic signal sampling

 

It seems that the attenuation speed of transient signals in the early, middle and late stages is quite different. In order to accurately determine the transient attenuation characteristics without distortion in a wide time range, in addition to having enough sampling points in a sufficiently wide time range, the intervals between the sampling points and the sampling gate width should vary with the observation points. As shown in Figure 1.3, in the early stage, the signal amplitude is high and the attenuation speed is fast, so the sampling time interval and gate width must be quite narrow to ensure that the attenuation characteristics of the signal can be accurately distinguished; in the late stage, the sampling interval and gate width should be increased to adapt to the slow decay characteristics of weak signals.

 

In addition, in order to ensure the accuracy of sampling, the early, middle and late stages must be amplified by different multiples to adapt to the large differences in the dynamic range of the attenuation curve.

 

System solutions

System architecture diagram

 

Figure 4 System block diagram

Figure 4 System block diagram

 

The system mainly includes Microchip's microcontroller PIC32MX7F512L, MOSFET driver module IR2110, multi-channel analog switch HI-201, CAN transceiver chip CTM8251A, and bipolar analog-to-digital converter AD7894.

 

System functions

The PIC32 microcontroller located underground generates a bipolar square wave in the transmitting coil through a MOSFET driver module, causing the receiving coil to generate an attenuated induced electromotive force due to electromagnetic induction. The microcontroller controls the multi-way switch and the variable gain amplifier circuit, selects different amplification factors and sampling frequencies for the attenuation curves of different periods, encapsulates the sampled data and auxiliary information such as temperature into frames, communicates with the PC terminal through the CAN bus, and finally draws the logging curve and well wall thickness spectrum on the PC user interface.

 

Based on the above theory, in actual application, by measuring the induced curve, the faster the curve decays and is divided into three sections, namely the early, middle and late stages, the early and late logging curves are drawn using an iterative algorithm, and the damage of different layers of tubing can be separated. This is the principle of using electromagnetic method to detect multi-layer tubing.

 

Hardware circuit design

Power Design

The power supply system consists of two parts: the surface part and the underground part. The power supply required by the underground instrument includes the +3.3V power supply required by the PIC32 microcontroller, the ±15V power supply required by the operational amplifier OP07 and the driver chip IRS2110, the +12V driver power supply for driving the IGBT, and the operating voltage 5V and high-precision reference voltage 2.5V required by the bipolar analog-to-digital converter AD7894.

 

Power system structure

The structure of the power supply system of the electromagnetic flaw detection logging instrument is shown in Figure 9. The power supply system consists of a ground transformer, a DC voltage regulator circuit, and multiple DC/DC voltage conversion circuits. The function of the ground transformer is to convert 220V AC into 15V AC, and then convert it into DC through the DC voltage regulator circuit. The DC power is sent to the well through the cable, and the DC/DC voltage conversion circuit outputs the 12V, 3.3V, ±15V, 5V, 2.5V and other voltages required by the downhole instrument.

 

Figure 5 Power system structure diagram

Figure 5 Power system structure diagram

DC voltage regulator circuit

The DC voltage stabilization circuit of this power supply system is shown in Figure 6. T1 is a 15V bidirectional transformer, which outputs AC power with an effective value of positive and negative 15V. After being rectified by the 2W10 rectifier bridge, it is filtered by the π-type network and outputs DC power of about 20V. A 0.1u capacitor is connected in parallel at both ends of each diode in the rectifier bridge, which can well absorb the switching noise of the diode and reduce the interference of the subsequent circuit to the previous circuit. Note that the withstand voltage of the capacitor must be more than twice the peak voltage output by the transformer, and it must be a ceramic chip capacitor. In the π-type filter circuit, the withstand voltage of the capacitor is also twice the input voltage, and the capacitance value is large, the AC component can be well filtered out, and the output voltage is relatively smooth.

 

Figure 6 Transformer and DC voltage regulator circuit

Figure 6 Transformer and DC voltage regulator circuit

 

Positive and negative 15V voltage conversion circuit

The operating voltage of chips such as op amp OP07 and IRS2110 is ±15V, which can be achieved by using 7815 and 7915 three-terminal voltage regulator chips, as shown in Figure 7. The diode 1N4001 plays the role of protecting the circuit.

 

Figure 7 Positive and negative 15V voltage conversion circuit

Figure 7 Positive and negative 15V voltage conversion circuit

 

12V, 3.3V voltage conversion circuit

12V is the start-up working voltage of MOSFET tube IRF630N, as shown in Figure 8.

 

Figure 8 12V, 3.3V voltage conversion circuit

Figure 8 12V, 3.3V voltage conversion circuit

 

5V, 2.5V precision reference voltage conversion circuit

AD7894 is a 14-bit bipolar analog-to-digital converter from ADI. It requires a high-precision 2.5V reference voltage when sampling, but general voltage regulator chips cannot provide such high-precision output. We chose Motorola's low-voltage reference MC1403 chip. The output voltage fluctuation of MC1403 is within 25mV, which can achieve 1% accuracy, and the application circuit is simple and cost-effective. As shown in Figure 14, it is a precision reference voltage conversion circuit.

 

Figure 9 2.5V precision reference voltage conversion circuit

Figure 9 2.5V precision reference voltage conversion circuit

 

Transmitter module

Bipolar pulse generation principle

According to the above principle, for electromagnetic flaw detection based on transient electromagnetic method (TEM), a bipolar current pulse must be used as excitation in the transmitting coil, which can be achieved by a full-bridge circuit, as shown in Figure 10:

 

Figure 10 Bipolar pulse generation circuit

Figure 10 Bipolar pulse generation circuit

 

When S1 and S4 are turned on and S2 and S3 are turned off, the voltage across the load transmitting coil is +U, generating a positive 1/4 cycle waveform of a bipolar square wave; when S2 and S3 are turned on and S1 and S4 are turned off, the voltage across the load transmitting coil is -U, generating a negative 1/4 cycle waveform of a bipolar square wave.

 

Therefore, bipolar pulses can be obtained by controlling the switch to open and close periodically. Its ideal waveform is shown in Figure 11.

 

Figure 11 Ideal waveform generated by full-bridge circuit

Figure 11 Ideal waveform generated by full-bridge circuit

 

Assuming the sampling interval is 1cm and the logging speed is 144m/h, a measurement cycle T = 1cm/(4cm/s) = 250ms. Therefore, we set the width of each pulse to 125ms.

Implementation of the transmitter module

The quad SPST should have the characteristics of reliable on/off, small delay, simple drive circuit, and certain power consumption characteristics. Considering all the above points, we choose IR's low-power MOSFET IRF630N.

 

The corresponding driver chip we choose is IRS2110 from IR. It is a high-speed dual-channel voltage-type switch driver with simple configuration. Only two chips are needed to drive the entire full-bridge circuit, saving costs. [page]

 

The load of the bridge is the transmitting coil. Our team consulted the data and took the literature indicators as reference. We used 0.6mm enameled wire to wind the transmitting coil and the receiving coil tightly on the same hollow plastic tube. The actual object is shown in Figure 12:

 

Figure 12: Homemade transmitting coil

Figure 12: Homemade transmitting coil

 

After measurement, the indicators of the transmitting coil and the receiving coil are: D = 2.6cm, L = 0.31mH, R = 2.7Ω. The transmitter circuit connection is shown in Figure 13, where the load is the transmitting coil.

Figure 13 Transmitter circuit schematic

Figure 13 Transmitter circuit schematic

 

The input of IRS2110 is connected to the RD9 and RD11 pins of the PIC32 microcontroller. By alternating the levels of RD9 and RD11, the timing is shown in Figure 7, which can generate alternating gate voltages, thereby controlling the opening of the MOSFET switch and generating bipolar pulses at both ends of the transmitting coil.

 

Figure 14 Transmitter module timing diagram

Figure 14 Transmitter module timing diagram

 

However, in practical applications, there is always a certain rise delay and fall delay in the current pulse, which prolongs the time for the current to reach a steady state. Especially when the falling edge is not steep enough, the receiving coil's induction of the secondary field is interfered by the primary field. In addition, the current pulse decreases linearly and can generate a stable induced current in the oil pipe.

 

Therefore, the requirements for the transmitting coil current pulse are: the rising edge is as steep as possible, the falling edge is steep and the linearity is good.

 

Simulation of decay curves and model interpretation

In view of the tight time schedule and the lack of hardware conditions such as oil well pipelines with different types of damage, our group discussed and decided to use a variable resistor and a ceramic capacitor in parallel to charge and discharge to simulate the exponential decay curve in the receiving coil. The circuit is shown in the figure below:

 

Figure 15 Attenuation curve simulation circuit

Figure 15 Attenuation curve simulation circuit

 

The decay rate of the simulated decay curve is related to the resistance of the variable resistor.

Capacitor charging and discharging formula: and , when the resistance of the sliding rheostat becomes smaller, it simulates the situation where the tube wall is thinner (damaged); when the resistance of the sliding rheostat increases, it simulates the situation where the tube wall is thicker (undamaged).

 

Receiver Module

The receiver module is composed of a receiving coil, a preamplifier circuit, a programmable amplifier circuit and an analog-to-digital converter. As mentioned above, the receiving coil is tightly wound on the same hollow plastic tube as the transmitting coil.

Preamplifier circuit

In the transient electromagnetic casing detection, the signal source is an ungrounded receiving coil. The decay of the induced voltage signal is similar to the shape of an exponential curve. The amplitude varies in a wide range, and the decay speeds in the early, middle and late stages are quite different in time. The bandwidth of the signal is small, and the spectrum energy is mainly concentrated in the low-frequency part. Considering the dynamic range of the signal, the amplification factor of the preamplifier circuit should be very small. The signal in the middle and late stages is a weak signal, and the performance of the amplifier must be considered: the bandwidth of the signal requires the amplifier to be a low-frequency amplification. In order to improve the accuracy of transient electromagnetic signal data acquisition and reduce the noise of the system, two aspects can be taken into consideration. On the one hand, the noise coefficient of the preamplifier circuit should be minimized as much as possible, because the preamplification has the greatest impact on the noise; on the other hand, the matching of the signal source impedance and the source impedance of the preamplifier circuit must be considered to increase the gain of the rated power. In addition, the input impedance of the amplifier circuit should match the receiving coil in a critical damping state. According to the above requirements and the characteristics of transient electromagnetic signals, it is more appropriate to select a measurement amplifier with a multi-op amp combination as the preamplifier circuit. The measuring amplifier has a high common-mode rejection ratio, which can suppress errors introduced by various common-mode interferences.

 

The preamplifier circuit of the transient electromagnetic casing detection system is shown in FIG16 . A common amplifier integrated chip OP07 is selected to design a general measurement amplifier. The measurement amplifier composed of three operational amplifiers is shown in the figure.

 

The three-op-amp combined measuring amplifier designed above consists of two stages, the first stage is a symmetrical in-phase amplifier, and the second stage is a differential amplifier.

 

Figure 16 Preamplifier circuit

 

In order to improve the circuit's ability to resist common-mode interference and suppress drift, the measuring amplifier is set to be symmetrical up and down. According to the virtual short and virtual open, the closed-loop gain of the measuring amplifier can be deduced as:

From the above formula, we can know that by adjusting the resistor R1, the closed-loop gain of the measurement amplifier can be easily changed.

 

Variable gain amplifier circuit

In the transient electromagnetic casing detection system, the basic characteristics of the secondary field signal to be measured are weak signal and large dynamic range, and the three-way magnetic probe signal needs to be processed in time-sharing. In order to meet the requirements of large dynamic range and weak signal of transient electromagnetic signal, and to measure three-way magnetic signal, the circuit design adopts the method of connecting the preamplifier circuit through four-way single-pole single-throw switch to the variable gain amplifier circuit, and the three-way magnetic signal is measured in time-sharing at different times. The PIC microcontroller controls different amplification factors, which can reduce the dynamic range of the signal, so that the signals of the three magnetic probes can be effectively detected. The schematic diagram of the variable gain amplifier circuit is shown in Figure 3.8. It is composed of the amplifier integrated chip OP27 and the four-way single-pole single-throw analog switch H1201. OP27 has the characteristics of low noise, good linearity and high stability, and can achieve accurate amplification of magnetic probe signals.

 

Figure 17 Variable gain amplifier circuit

Figure 17 Variable gain amplifier circuit

 

Since the longitudinal probe A is the main probe, its role is the most important; the transverse probes B and C are auxiliary probes that assist the longitudinal probe A. When the three probes are processed in time-sharing mode at the same time, the sampling order is set as A, A, A, B, C, A, A, A, B, C... This is controlled by the three pins RD1, RD2, and RD3 of PIC32.

 

The amplification of the signal at different times is controlled by the three pins RD12, RD13, and RD4 of PIC32:

RD12 effective, early gain

RD13 effective, mid-term gain

RD4 effective, late gain

By adjusting the resistance value, the amplification factor can be changed.

 

Selection of analog-to-digital conversion chip

The signal output by the variable gain amplifier circuit is sent to the analog-to-digital converter, which completes the acquisition of the receiving coil signal. According to the characteristics of electromagnetic pipe string flaw detection, the analog-to-digital converter should have the following characteristics:

 

  1. Higher sampling rate. According to Shannon's sampling law, the sampling signal can be restored without distortion only when the sampling frequency is not less than twice the highest frequency of the collected signal spectrum. The transient electromagnetic method is actually a broadband electromagnetic system. In theory, its spectrum can be extended infinitely, including the entire frequency band of the frequency domain electromagnetic method (several Hz-several kHz). Therefore, the maximum sampling frequency of the analog-to-digital converter is at least 10kHz.
  2. Supports bipolar sampling. Since the excitation signal is a bipolar pulse, the signal generated by the receiving coil should also be bipolar.
  3. Higher sampling accuracy. Since the sampling signal has a large dynamic range (several V to tens of uV), the amplified signal amplitude is still very small in the later stage of sampling, which requires higher sampling accuracy. The conversion bit number of the analog-to-digital converter should be no less than 12 bits.

 

Considering all the above aspects, we chose the 14-bit analog-to-digital converter AD7894 from ADI. Its sampling rate can reach more than 160ksps, the input range is -10V — +10V, 1LSB is only 1.22mV, and it is powered by a single voltage, which is easy to use.

Calculation of main parameters

The main parameters of the receiver module include: preamplifier gain; division and gain of the three periods of front, middle and back; sampling time slot and point number determination.

 

The following three points should be observed when designing parameters: 1. After the signal is amplified, it cannot exceed the dynamic range of the analog-to-digital converter -10V--+10V, and control the sampling magnification; 1. In order to ensure the accuracy of sampling, the period should be divided reasonably; 3. The early decay is fast, and the time slot should be small; the late decay is slow, and the time slot should be large. After experiments and calculations, we determined the above parameters as: preamplifier gain: 2, early gain: 2, mid-term gain 5.5, late gain 11.

 

Early stage: 2ms-11ms Probe A samples 6*3 points, probe B samples 6 points, and probe C samples 6 points. Sampling time slot 300us.

 

Mid-term: 11ms-45ms Probe A samples 12*3 points, probe B samples 12 points, and probe C samples 12 points. The sampling time slot is 400us.

 

Late stage: 45ms-110ms A probe samples 30*3 points, B probe samples 30 points, C probe samples 30 points. Sampling time slot 500us.

 

Communication module design

The general depth of oil wells and gas wells is about 3km, and some are even as deep as 5km. General transmission methods cannot meet the requirements of effective transmission over such a long distance. CAN-bus protocol is a universal serial communication standard, which has many applications in practical occasions, such as automobiles, coal mines, oil fields, ships, electricity, production lines, etc. It has the characteristics of high communication rate, good openness, short message, strong error correction ability, simple control, strong expansion ability and low system cost. The data transmission rate of CAN bus in short-distance communication can reach up to 10Mbps, and long-distance communication can reach 10km. This system uses CAN bus to realize communication between wells and underground. After adding several CAN repeaters in the middle, it can communicate stably at a baud rate of 50kbps.

 

PIC32MX CAN Module Introduction

The PIC32MX795F512L microcontroller provides a Controller Area Network (CAN) module that implements the CAN2.0B protocol, which is mainly used in industrial and automotive applications. This asynchronous serial data communication protocol provides reliable communication in an electrically noisy environment. The PIC32MX device family can integrate two CAN modules.

 

Figure 18 PIC32MX CAN module block diagram

Figure 18 PIC32MX CAN module block diagram

 

Figure 18 is a block diagram of the PIC32MX CAN module. The CAN module has 32 message FIFOs, each FIFO can contain up to 32 messages, a total of 1024 messages, 32 receive filters for message filtering, 4 receive filter mask registers for message filtering, and can automatically respond to remote transmission requests. It also provides loopback, monitor all messages and monitor modes for self-test, system diagnosis and bus monitoring; low power working mode; dedicated time stamp timer and other features. The powerful CAN module of the PIC32MX7 series can quickly realize the communication part of the system.

 

CAN bus circuit

Figure 19 is a diagram showing a typical CAN bus topology.

 

Figure 19 Typical CAN bus network

Figure 19 Typical CAN bus network

 

For the CAN transceiver, we chose the universal CAN isolated transceiver CTM8251AT. CTM8251AT is an isolated universal CAN transceiver chip. The chip integrates all necessary CAN isolation and CAN transceiver and receiver components, all of which are integrated on a chip of less than 3 square centimeters. This chip is particularly suitable for the CAN controller of the +3.3V system to realize the transceiver and isolation functions of the CAN node. The CTM8251A interface chip can realize an isolated CAN transceiver circuit with an isolation voltage of up to DC2500V. It can replace other components such as optocouplers, DC-DC power supply isolation, and CAN transceivers in previous designs to realize an isolated CAN transceiver circuit. Its interface is simple and easy to use.

 

Figure 20 CAN bus module circuit

Figure 20 CAN bus module circuit

Figure 20 is the circuit of the CAN bus module in this system. C1RX and C1TX are connected to the PIC32MX795F512L microcontroller's CAN1 module receiving and transmitting pins (pins 87 and 88). CGND is the transceiver ground, FGND is the shielding ground, and FGND is connected to the cable shielding wire.

 

The interface between CTM8251AT and CAN bus also adopts certain safety and anti-interference measures. The CANH and CANL pins of CTM8251AT are connected to CAN bus through a 5.1Ω resistor. The resistor can play a certain role in current limiting and protect CTM8251AT from overcurrent impact. Due to the long distance, a pair of resistors (RT1) at the terminal is necessary. The resistance value should be appropriately increased with the increase of communication distance. It is generally set to 120Ω within a communication distance of 2km. [page]

 

Communication protocol design

The downhole equipment is completely controlled by the uphole PC client, such as starting logging, pausing logging, etc. The downhole equipment is responsible for responding to the commands of the host computer. This system defines three frame structures: logging data frame, command frame and response frame. The data frame is mainly used for the logging data sent by the downhole equipment to the host computer, the command frame is used for the host computer to send control commands to the downhole equipment, and the response frame is a frame structure for both parties to respond to success or failure after receiving the logging data frame and command frame.

 

  • Well logging data frame

The structure definition of the logging data frame is shown in Table 1. The logging data frame includes a start flag byte, a frame number byte, a type byte, a current time byte, a current depth byte, a temperature byte, a gamma ray byte, a transmitting circuit byte, a longitudinal probe A voltage byte, a transverse probe B voltage byte, a transverse probe C voltage byte, a checksum byte, and an end flag byte.

 

Table 1 Well logging data frame structure

Start sign

Frame number

Type Byte

current time

Current Depth

FSTA

3 bytes

1 byte ('D')

4 bytes

4 bytes

temperature

gamma rays

Emission current

Longitudinal probe A voltage

Transverse probe B voltage

4 bytes

2 bytes

2 bytes

48*3*2 bytes

48*2 bytes

Transverse probe C voltage

Checksum

End Sign

 

 

48*2 bytes

4 bytes

FEND

 

 

 

Since PIC32MX7 is a 32-bit microcontroller, it can process int data (4 bytes) faster, and the CAN2.0B standard frame can send 8 bytes of data per frame, so the protocol adopts a design of 4 bytes as a unit.

 

The start flag byte is four bytes of "FSTA", the end flag byte is four bytes of "FEND", the frame number is the number of the data frame sent after the logging instrument is started, and the type byte is "D". The other bytes are the logging data collected at the current depth.

 

The protocol uses a simple checksum method to check the frame. First, every four bytes form an int data, then add all the data, and then truncate the result to the length of an int data. The sender performs checksum calculation on the data to be sent, and sends the checksum value after the data. The receiver performs checksum calculation on the received data, and then compares it with the received checksum byte to make error judgment. The bytes to be checked and calculated do not include the start and end mark bytes.

 

  • Command frame

The command frame structure is defined as shown in Table 2. The command frame includes a start flag byte, a frame sequence number byte, a type byte, a checksum byte, and an end flag byte.

 

Table 2 Command frame structure

Start sign

Frame number

Type Byte

Checksum

End Sign

FSTA

3 bytes

1 byte (command word)

4 bytes

FEND

 
 

According to the needs of the system, the command word is provided with a start command word, a pause command word, a continue command word and an end command word, and the type bytes are 'S', 'P', 'C' and 'E' respectively.

 

  • Response frame

The structure of the response frame is defined as shown in Table 3. The frame includes a start flag byte, a frame sequence number byte, a type byte, a checksum byte, and an end flag byte. The type byte of the ACK response frame for successful reception is 'A', and the type byte of the NAK response frame for failed reception is 'N'.

 

Table 3 Response frame structure

Start sign

Frame number

Type Byte

Checksum

End Sign

FSTA

3 bytes

1 byte ('A'/'N')

4 bytes

FEND

In addition to the definition of the frame structure, the communication of the entire system also needs to comply with the following rules:

  1. Both parties of the data transmission transmit data at a rate of 100kbps, using master-slave communication, with the master sending data and the slave receiving data;
  2. After receiving the data frame, the slave will determine whether the data reception is successful based on the final check structure. If the check is correct, it will send an ACK response frame to the host to indicate successful reception. If the check is wrong, it will send a NAK response frame to indicate an error and request retransmission.
  3. If the host receives the ACK response frame, the communication ends, otherwise the host will resend the group of data.

 

Table 4 is the logging data transmission model, which is the data transmission model for the entire logging process.

 

Table 4 Well logging data transmission model

Start logging sign

Data Frame

Response frame

Data Frame

Response frame

……

Data Frame

EMISTART

Data Frame 0

ACK

Data Frame 1

ACK

……

Data frame n

Response frame

Data Frame

Response frame

……

End logging sign

 

WANT

Data frame n

ACK

……

EMITOEND

 

 

Auxiliary measurement module

Temperature Probe

The selection of temperature sensors mainly requires consideration of the temperature range of the object being measured, the chemical stability of the resistor material, and the linear relationship between the resistance value and temperature change.

 

Generally speaking, the temperature in the crust is proportional to the depth. The temperature rises by about 3°C ​​for every 100-meter increase in depth. In addition, the depth of the oil well must also be considered. In the early days, the oil wells were only tens to hundreds of meters deep. In recent years, the depth of oil wells has gradually deepened. Most oil production is between 1,000 and 3,000 meters deep. The deepest record of oil production wells is 6,500 meters. Due to the existence of geothermal gradients, the temperature downhole will increase with the increase in depth, which can be used to estimate the required temperature measurement range of the temperature sensor.

 

The maximum bottom hole temperature can be calculated by the following formula:

Where is the maximum bottom temperature (°C), is the geothermal gradient (°C/100m), and h is the well depth (m).

 

When it is taken as ℃/100m, the temperature at 6500 meters is 23+4.5×6500/100=315.5℃. Therefore, the temperature sensor measurement range of the temperature measurement part is selected in 0-320℃ to meet the temperature measurement requirements under most conditions.

 

Thermocouples, thermal resistors and integrated temperature measuring elements are available for selection within this temperature range. Considering factors such as its use environment, it is more appropriate to use thermal resistors as the temperature measuring elements of the system.

 

Platinum resistance has the advantages of large temperature measurement range, high accuracy, good stability, reliable performance, etc. It also has high melting point and high stability, so it was selected as the temperature measurement element of the system.

 

The specific temperature measurement circuit is shown in the figure below:

Figure 21 Temperature measurement principle diagram

Figure 21 Temperature measurement principle diagram

 

TL431 provides a constant voltage source for OP07 . Since the voltage source is not a pure constant voltage, R5 and C1 are added as power supply filters to eliminate voltage fluctuations. R2, R3, R4, and RT are used as measurement bridges to calculate temperature changes by detecting the voltage difference between the C and D terminals. According to the virtual short characteristics of the input terminal of the integrated operational amplifier working in the linear region, the voltage at the OP072 terminal is equal to the voltage at the 3 terminals; since TL431 provides a relatively stable voltage source for OP07 , according to the virtual disconnection characteristics of the input terminal of the integrated operational amplifier working in the linear region, the current flowing through R4 only flows through RT, so it is equivalent to having a constant current source flowing through R4 and RT. When the bridge reaches dynamic balance, there is: . By calculation, it can be known that , so the change in RT can be calculated . The temperature value can be obtained by checking the platinum resistance temperature table.

 

Gamma Probe

The natural gamma logging instrument measures the intensity of natural gamma rays generated by the decay of radioactive elements in the formation. Natural gamma data can be used to classify the lithology of the formation and calculate the mud content of the formation. In cased well logging, the comparison of the natural gamma curve, the casing collar positioning curve and the open hole data can ensure the accuracy of formation positioning and perforation depth. The general natural gamma circuit is divided into a scintillation detector, an input electrode, a selective shaping stage, an amplification output stage and a high-voltage power supply. The structural diagram is shown in Figure 22.

 

Figure 22 Natural gamma ray detection structure diagram

Figure 22 Natural gamma ray detection structure diagram

 

Software system design

Lower computer software design

Main program flow chart

Figure 23 Main program flow chart

 

After entering the main program, each module is initialized first, including global variables, MCU I/O ports, CAN bus and other modules. Then the system working state is judged. According to different working states, the system executes different contents. The working state of the system is switched by the system and the host computer. The host computer sends commands to the slave computer through command frames.

 

Well logging flow chart

 

Figure 24 Well logging flow chart

In the logging state, the MCU controls the IGBT full-bridge circuit to generate a 125ms positive pulse, controls the programmable amplification multiple according to different times, and performs A/D sampling. After the sampling is completed, the MCU controls the IGBT full-bridge circuit to generate a 125ms negative pulse again, and sends the logging data frame to the host computer through the CAN bus. If the transmission is not successful within 100ms, the transmission failure flag is returned and the transmission is terminated. After the negative pulse, the amplification and sampling are repeated, and the logging data frame is sent. Finally, it is determined whether there is a logging data frame that fails to be sent, and the failed data frame is sent.

 

CAN bus data processing flow chart

The system uses the PIC32MX CAN1 module, the baud rate is set to 100kbps, and two 32-message-deep FIFOs are used as the send and receive FIFOs, respectively. The receive interrupt method is used to receive data from the host computer. The received data is processed in the receive interrupt service program. Figure 25 is a flowchart of CAN bus data processing.

 

Figure 25 Flowchart of CAN bus data processing

 

After receiving a complete data frame and the checksum is correct, the system will process the received buffer data and perform corresponding operations according to different types of data frames. If a complete data frame is not received correctly, the lower machine will return the error type and reply with a NAK response frame.

 

Real Time Clock

The Real-Time Clock and Calendar (RTCC) hardware module and its operation are available on PIC32MX devices. The RTCC is designed for applications that require accurate time to be maintained for long periods of time with no or minimal CPU intervention. The module is optimized for low power use to extend battery life while keeping track of time. The requirement for using the RTCC module is an external 32.768 kHz clock crystal.

 

The current time of the logging data frame is provided by the RTCC module, which only needs to be initialized and the starting clock and calendar set to run automatically.

 

Host computer software design

Overview

Requirements Overview

The main function of this software is to receive the data sent by the hardware part of this system, parse it through a certain protocol, extract and analyze the information, calculate the pipe wall thickness, draw a visualization graph of the thickness, and provide direct and effective information for engineering personnel.

 

Since this system focuses on analyzing the damage location while detecting flaws, it must be separated into far and near. In addition, it is best to draw a thickness spectrum from far to near. Therefore, this software needs to draw two types of graphs, one divided into two curves of far field and near field, and the other gives a colored thickness spectrum.

 

Since logging takes a long time, it is difficult for engineers to track the entire process. In order to facilitate the recovery of stored information for future reference, it is also necessary to add file storage and image storage functions to this software.

 

Finally, engineers also need to observe the on-site conditions and obtain information from the well at any time. This method of observation at any time can effectively save logging time, and it is not necessary to complete the logging for wells that are too damaged.

 

Software and hardware support environment

This software is compiled with VS2008 and uses the .net3.5 architecture. Therefore, the support of the Microsoft .net3.5 runtime library is required to run this software.

 

In addition, this system uses USBCAN module for communication. Since the manufacturer has not provided its driver under Windows Vista and Windows 7, this software can only work under Windows XP system and needs to install USBCAN module driver.

 

Procedural Modeling

This program adopts object-oriented programming method, most of the functions are encapsulated in objects, and the program has good portability and security. The program is mainly encapsulated in the following classes

 

kind

use

  •  

Record the whole logging process information,

  •  

File storage and reading

  •  

8 bytes of information sent from the lower computer

  •  

Data packets sent from the lower computer

  •  

It includes two data packets, one positive and one negative, to record the average value and other data processing results.

  •  

Well logging curve

  •  

Attenuation curve

  1.  
  1. Bus communication
 

In addition, this software uses multi-threaded processing technology. The main program is responsible for key response, graphic display, etc. in the main thread, while the information processing algorithm is executed by the sub-process. This effectively improves the efficiency and independence of the data processing algorithm, and greatly reduces the original processing time of each packet from about 1000ms to about 14ms.

 

interface design

The following figure is a screenshot of the software running. You can see that the program consists of the file/device control area in the upper right corner, the graphic control area in the upper right corner, the information display area in the lower left corner, and the graphic display area in the lower right corner. The most important part, which also occupies the largest area, is the graphic display area. The larger area ensures the convenience of viewing. In addition, in order to observe intuitive first-hand data, we have also specially set up the display of the unprocessed attenuation signal directly transmitted from the sampling equipment, so that engineers can directly judge whether the logging system is working properly and whether the pipe wall is seriously damaged. This attenuation curve can be hidden, because it is not the main content that needs to be displayed after all, and it occupies a large screen space. If you feel that the image display space is not large enough, you can even hide the legend. The legend here is designed to float above the drawing and can move with the scroll bar. [page]

 

Figure 26: Electromagnetic logging tool software interface

 

USBCAN Receiver Module

Since the USBCAN-2A module is used, the driver and dll program provided by the manufacturer are used here, but the program provided is based on C++, and our C# program also needs to be encapsulated for the .Net architecture, which includes data type conversion, structure rewriting and function reference.

 

Function reference uses DllImport statement, taking opening device function as an example:

 

[DllImport("ControlCAN.dll")]

public static extern UInt32 VCI_OpenDevice(UInt32 DeviceType, UInt32 DeviceInd, UInt32 Reserved);

 

The functions in ControlCAN.dll are referenced here, using static and external reference methods.

 

The second thing to be repackaged is the data type. Since the data types of the .Net architecture and C++ are different, a lot of rewriting is required. For example, the Dword type should be converted to the Uint32 type. This conversion is often more patterned, and the specific conversion will not be repeated here.

 

The third and most important thing is the rewriting of the structure. For example

public struct VCI_CAN_OBJ

        {

            public UInt32 ID;

            public UInt32 TimeStamp;

            public Byte TimeFlag;

            public Byte SendType;

            public Byte RemoteFlag; //Is it a remote frame?

            public Byte ExternFlag; //Is it an extended frame?

            public Byte DataLen;

            [MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)]

            public Byte[] Data;

            [MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)]

            public Byte[] Reserved;

        };

 

This structure needs to be re-described in the class. The data types should be converted according to standard data types. In addition, the array should be modified with the MarshalAs modifier, indicating that data is transferred between managed code and unmanaged code. The code in the driver is managed, and the MarshalAs method must be used to collect its data.

 

Finally, since the data format used by our program is relatively fixed, some commonly used methods are encapsulated in this class to make the CAN module transparent to the upper-level program, and the upper-level program seems to have no underlying methods when receiving data. For example, the CAN module defines three methods: open device, initialize device, and start CAN. However, since our parameters are specified, these three methods are encapsulated in the program, and the device is automatically opened in the constructor whenever a USBCAN instance is created.

 

Data Analysis Module

The data received by the CAN module needs to be analyzed. Here we use the regular expression analysis method. Regular expressions are easy to use in C#, highly efficient and powerful.

 

Each time the data is received, it is a small string of 8 bytes, which is actually 8 numbers from 0 to 255. Since the maximum ASCII code is 127, all values ​​exceeding 127 are converted into the "?" character with a value of 63. Therefore, the extended ASCII code specified in ISO8859-1 is used for transcoding.

 

There are five types of small strings, which are matched by the following five regular expressions: @"^EMISTART$", @"^FSTA((.| ){4})$", @"^((.| ){8})$", @"^EMITOEND$", @"^((.| ){4})FEND$", which respectively represent "logging start", "data packet start", "content data", "logging end", and "data packet end". After analyzing the differences between the five frames, corresponding operations can be performed. If the logging start frame is received, a new logging instance is created, the image is reset, and the storage file is reset. If the logging end is received, the logging instance is destroyed. When the data packet start flag is received, a new message instance should be created, and when the content frame is received, information should be added to the last created message packet instance. If the data packet end flag is received, data processing begins.

 

After receiving the end of data packet, the data processing should start immediately. The algorithm flow is as follows:

 

 

The first step is to determine the size. A standard data packet size is 512 bytes. If it is not, it should be discarded. This step greatly saves the time of judgment. After all, the checksum is still a relatively troublesome judgment method, and many erroneous data will be discarded due to inconsistent size.

 

The second step is to check and judge. Here, every four bytes are combined into a 32-bit integer data, and then the sum is added. The final data is compared with the transmitted data. If they are consistent, it is considered that there is no error in the transmission. According to actual measurements, the transmission error rate is less than one thousandth.

 

The third step is to send ACK and NAK information.

 

The fourth step is to split the data to get meaningful integer or floating-point data from character data. The splitting process also uses regular expression technology, and its expression is: @"^FSTA((.| ){3})D((.| ){4})((.| ){4})((.| ){4})((.| ){2})((.| ){2})((.| ){288})((.| ){96})((.| ){96})((.| ){4})FEND$"

 

The received data is shifted and added to obtain its corresponding integer value. For example, the temperature value is 4 bytes of 32-bit data. When receiving, first add the leftmost byte, shift right 8 bits, add the second byte from the left, and so on to get its integer value. Since we stipulate that the data transmitted is 1000 times the value, we can divide it by 1000. The calculation method of other data is similar.

 

Software filtering

Due to the uncertainty of AD sampling, it is very likely to cause deviations in certain data or overall deviations, so we use some methods to eliminate accidental factors in the measurement.

 

First, if the current has only one direction when sending the excitation signal, it may cause a large difference due to geometric factors. Therefore, we use a bipolar square wave for excitation, sampling positively once and negatively once, and averaging the absolute values ​​of the two times to obtain good data results.

 

In addition to eliminating the deviation caused by the geometric structure, it still cannot meet our requirements. For the value of the near field, if we only trust the value of one sampling point, it will cause deviation. Therefore, we take the average value of the approach data and the average value of the far field. The algorithm using the average is faster, occupies less system resources, and the effect is acceptable.

 

File storage and recovery

The file part functionality is encapsulated in the FileSave class, which implements functions such as saving and appending.

 

File Storage

When creating a file object, first create the file according to the obtained path. If the file is being read, it is opened in read-only mode. When writing a file, the system time is automatically obtained and the time determined by the system time is saved. This file name is convenient for viewing.

 

The way to save files is to store what comes, that is, directly store the information sent by the lower computer. Of course, this information is verified and meets the checksum information. The checksum is also stored in the file, so that judgment can still be made when reading the file to prevent the file from being tampered with during the storage process.

 

File Recovery

When the engineer is not logging, the logging curve can still be restored from the stored logging data. The reading process and the logging process use the same code and the same algorithm, which greatly improves the code reuse rate and is also relatively efficient. During the reading process, the data can still be checked and the data packets with incorrect checksums will be discarded.

 

Image storage

In addition, the recovery of logging curves is very slow and the information redundancy is relatively large, so we also set up an interface for image saving. In this way, engineers can use ordinary image viewing software to open the stored images and analyze the image data.

 

Drawing Module

The whole program needs to draw two kinds of images, namely the decay curve and the well logging curve. The decay curve is encapsulated in the DecayGraph class, while the well logging curve is encapsulated in the PDGraph. The working principles of the two are similar, and both use the GDI+ provided by .Net. In the constructor, the frame and legend are first drawn, and then the lines are drawn according to the passed information.

 

System test

Test Equipment

     MOTECH LPS-305S Digital Control DC Regulated Power Supply

Features: 220V power frequency input, two bipolar voltage outputs

Application: System power supply

Special requirements: adjustable supply voltage, stable voltage

 

     Agilent 7104 Oscilloscope

Features: 4 channels, sampling rate up to 4GSa/s

Application: Detection of waveform

Special requirements: fast sampling rate, multi-channel

 

     ZHIYUAN USB CAN-2A CAN receiver

Purpose: To realize the function of CAN to USB, PIC32 microcontroller communicates with PC via CAN bus

     Visual stidio 2008

Application: User interface design, well logging curve drawing

 

     MAPLAB Development Environment

Purpose: Write PIC32 main program, compile, download

 

Downhole circuit part test

Simulated decay curve waveform

The attenuation curve generated by the simulation is shown in the figure below:

 

Figure 27 Simulated attenuation curve (100ms/div)

Figure 27 Simulated attenuation curve (100ms/div)

 

Figure 28 Simulated attenuation curve (5ms/div)

Figure 28 Simulated attenuation curve (5ms/div)

 

The peak value of the curve is 3.3V. The oscilloscope display shows that the simulated attenuation curve is similar to exponential attenuation, but there is ripple interference in the later stage.

 

Programmable module control signals

The signals of the three pins RD12, RD13, and RD4 are shown in Figure 29. They are alternately valid (low level) in one cycle, and the valid periods are 9ms, 24ms, and 75ms respectively, which are consistent with the three time periods of morning, middle, and evening divided previously.

 

The three pin signals of RD1, RD2, and RD3 are shown in Figure 30, which realize the function of time-sharing sampling of the longitudinal probe A and the transverse probes B and C.

 

Figure 29 Period division control signal

Figure 29 Period division control signal

 

Figure 30 Probe selection control signal

 

Signal curve after programming amplification

The signal output by the programmable amplifier module is shown in the figure below. The amplification factors in the early, middle and late periods are 2, 5.5 and 11 respectively.

Figure 31 Attenuation curve after programming amplification (50ms/div)

 

Figure 32 Signal after (green) and before (yellow) programmed amplification (20ms/div)

 

Summarize

Our team mainly realizes the following functions of electromagnetic flaw detection system:

  • Design of underground hardware circuit

A suitable signal processing chip was selected to process the probe signal in a time-sharing and programmed amplification manner.

 

  • Communication and transmission technology research

Based on the CAN bus, a communication protocol suitable for collaboration between underground systems and surface systems was developed.

 

  • Data processing, interpretation system research

The ground interpretation system processes the collected data, draws the logging curves of the inner oil pipe and the outer casing, and can simultaneously display the thickness spectrum of the pipeline, providing oil well workers with more intuitive information.

Reference address:Multi-layer pipe string electromagnetic flaw detection logging system based on electromagnetic induction

Previous article:Design of Ethernet and CAN bus bridge based on PIC32
Next article:Design of card reader based on RC522

Recommended ReadingLatest update time:2024-11-23 03:00

PIC32 Getting Started - Environment Construction
     To learn PIC32, you must first build a compilation environment, otherwise it will be difficult to proceed to the next step of learning.      The first step is to download two software packages: the integrated environment MPLABX-v2.26-windows-installer.exe and the compiler xc32-v1.31-windows-installer.exe, downl
[Microcontroller]
Latest Microcontroller Articles
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号