Summary of the invention
Technical problem to be solved by the invention is to provide a kind of anti-interference multichannel analog amount sample circuit and methods, should
Anti-interference multichannel analog amount sample circuit and method are easy to implement, and anti-jamming effectiveness is prominent.
The technical solution of invention is as follows:
A kind of anti-interference multichannel analog amount sample circuit, including controller, A/D converter, M SPI chip and N number of biography
Sensor;M and N is the integer greater than 2;M is even number;N≤2*M;
The chip select terminal (CSai, i=1,2 ..., M) of M SPI chip with the chip selection signal output end CSa phase of controller
Even;
The clock signal input terminal (CLKai, i=1,2 ..., M) of M SPI chip is exported with the clock signal of controller
CLKa is held to be connected;
The cascade of M SPI chip: M SPI chip is arranged in sequence;
The data input pin Dina1 of first SPI chip meets the serial data output terminal Dina of controller;First SPI
The data output end Douta1 of chip meets the data input pin Dina2 of second SPI chip;The data of second SPI chip are defeated
Outlet Douta2 meets the data input pin Dina3 of third SPI chip;And so on, until the data of the M-1 SPI chip
Input terminal Dina (M-1) meets the data output end Douta (M-2) of previous SPI chip;The data output of the M-1 SPI chip
End Douta (M-1) meets the data input pin DinaM of m-th SPI chip;
SPI chip has input shift register and 2 groups of analog switches, i.e. A analoglike switch and B analoglike switch;Often
Group analog switch includes 4 analog switches;First group of analog switch has a common end DA;
First group of analog switch has a common end DB;
M SPI chip is divided into 2 groups of the identical front and back of quantity in order, and preceding M/2 SPI chip is first group, rear M/2
SPI chip is second group;
The common end DA and common end DB of first group of SPI chip meet 2 terminals IOUT1 and IOUT2 of constant-current source respectively;
Preferably, 2 terminals IOUT1 and IOUT2 of constant-current source are derived from IOUT1 the and IOUT2 pin of A/D converter;
The common end DA and common end DB of second group of SPI chip meet 2 input signal end AIN1 of A/D converter respectively
(+) and AIN1 (-);
The signal of A/D converter connects:
Chip select terminal CSb1, clock signal terminal CLKb1 and the data output end Doutb1 of A/D converter connect controller respectively
Chip selection signal output end CSb, clock signal output terminal CLKb and data input pin Doutb;The signal of sensor connects:
There is first group of SPI chip M*2 A analoglike switch and M*2 B analoglike to switch [first group of SPI chip in total
The port numbers of corresponding A analoglike switch are S (i) AI, and the port numbers of B analoglike switch are S (i) BI];M*2 A analoglike is opened
Close the first end that most multipotency respectively connects M*2 sensor;Most multipotency connects the of M*2 sensor to M*2 B analoglike switch respectively
Two ends;[S1AI in such as Fig. 4, S1BI;And S2AI, S2BI etc.];
Second group of SPI chip has M*2 A analoglike switch and M*2 B analoglike switch, [second group of SPI core in total
The port numbers of the corresponding A analoglike switch of piece are S (i) AV, and the port numbers of B analoglike switch are S (i) BV];M*2 A analoglike
Switch the first end that most multipotency respectively connects M*2 sensor;Most multipotency connects M*2 sensor to M*2 B analoglike switch respectively
Second end;[S1AV in such as Fig. 4, S1BV;And S2AV, S2BV etc.].
The data output end DoutaM of m-th SPI chip meets the checking signal input terminal Douta of controller.
Isolating chip is equipped between first SPI chip and controller;Between A/D converter and controller be equipped with every
Off-chip piece.
The isolating chip uses ADuM1411 chip, and the SPI chip uses ADG739 chip, the A/D
Converter uses AD7793.
The M=4, N=8.
The sensor is thermoelectricity occasionally thermal resistance, is also possible to other kinds of sensor, such as pressure sensor, wet
Spend sensor etc..
Controller is single-chip microcontroller or DSP.
Sample detailed process:
(1) for do not need load constant-current source sensor;A certain SPI in second group of instruction control is issued by controller
2 analog switches of chip are connected, so that the both ends of one of sensor are believed by the analog switch extraction voltage of the conducting
Number to A/D converter 2 input signal end AIN1 (+) of signal input part and AIN1 (-), A/D converter output digit signals
Data sampling is completed to controller;
(2) for needing to load the sensor of constant-current source;
It is first connected by 2 analog switches that controller issues a certain SPI chip in first group of instruction control, so that wherein
The both ends of one sensor are separately connected 2 terminals IOUT1 and IOUT2 of constant-current source by the analog switch of the conducting;
It is connected again by 2 analog switches that controller issues a certain SPI chip in second group of instruction control, so that wherein
The both ends of one sensor are defeated by signal input part 2 of analog switch extraction voltage signal to the A/D converter of the conducting
Enter signal end AIN1 (+) and AIN1 (-);A/D converter output digit signals complete data sampling to controller.
Jamproof process is realized by checking procedure:
Controller is m_DATA_OUT_PRE by the data that pin Dina is exported;
The data that controller passes through the Douta readback of checking signal input terminal are m_DATA_OUT_CUR;
Compare m_DATA_OUT_PRE and m_DATA_OUT_CUR, if equal, then it represents that data output is normal, otherwise, table
Registration is interfered according to output, retransmission data.
A kind of anti-interference multichannel analog amount method of sampling, it is real using anti-interference multichannel analog amount sample circuit above-mentioned
Existing data sampling;
M SPI chip cascade is formed into daisy chain sampling structure, to can control the sampling for any one sensor;
By the checking signal input terminal Douta readback that the data output end DoutaM of m-th SPI chip is connect to controller
Data;
Controller is m_DATA_OUT_PRE by the data that pin Dina is exported;
The data that controller passes through pin Douta readback are m_DATA_OUT_CUR;
Compare m_DATA_OUT_PRE and m_DATA_OUT_CUR, if equal, then it represents that data output is normal, otherwise, table
Registration is interfered according to output, retransmission data;It is anti-interference by comparison mechanism above-mentioned and retransmission mechanism.
As shown in Figure 1, whole network is divided into two-stage, level-one is control system topological diagram based on PLC or DCS
Monitoring software and logic control system, it includes that various execution structure field devices and multichannel temperature are adopted that in addition level-one, which is field level,
Collect controller, the span of whole system is very broad, and each mistake of walking out of all may cause the system failure.The input number of whole system
According to flow direction since acquiring thermal resistance or thermocouple temperature sensor, lead can preferably be eliminated using three-wire system acquisition mode
The influence of resistance is most common in industrial control process.Live multiplex temperature collection measuring signal passes through controller multichannel
Pass through fieldbus after the analog-to-digital conversion and logical operation process of temperature acquisition controller and transfers data to PLC/DCS logic
Control system is shown finally by the monitoring that Ethernet is connected to upper computer software offer temperature acquisition data.Data pass through layer
The conversion of layer, each network have the reliability of the peculiar verification scheme guarantee data of oneself.Multichannel temperature acquisition controller
Internal topology figure is as shown in Figure 2;
CPU acquires switching circuit by SPI communication interface (band isolation) control multichannel temperature, logical by switching acquisition
Road, moment scan the real time data in each channel.
Due to SPI chip not or only simple verification scheme, so may cause control system in SPI communication
The non-intellectual of behavior, the timing diagram of SPI communication such as Fig. 3.
From figure 3, it can be seen that the data output of SPI chip is there are two process, the displacement that output data is sent to SPI chip is posted
After storage, output control register is output to by enabled output pin, the data of readback shift register is first passed through, guarantees just
It is exported again after really, then does and handle in next step again.So software processing should all be carried out in shift register.
Multichannel temperature acquisition hardware circuit as shown in Figure 4, in hardware design, the acquisition control of controller multichannel temperature
Device CPU processed mainly uses the ARM7 chip ST32F103ZET6 of CORTEX-M3 kernel, controls the acquisition between multi-route measuring temperature channel
Switching between SPI interface and multichannel collecting switching circuit mainly by being communicated, the collected simulation of multi-route measuring temperature circuit
Signal by the AD7793 analog-digital converter of ADI company is converted into digital signal and passes through again to carry out between SPI communication interface and CPU
Data exchange.Constant-current source IOUT1, IOUT2 needed for three-wire system RTD thermometric channel by AD7793 can software configuration output be 10 μ
A, 210 μ A or 1mA.ADC reference voltage reference source selects AD7793 internal reference 1.17V.In order to enhance entire temperature measurement circuit
Electrical anti-interference ability, select ADI company iCoupler technology 4 channel number word isolators [ADuM1411 four-way number every
From device] electromagnetic isolation is carried out to the SPI communication interface between CPU and peripheral circuit.Multichannel collecting switching circuit mainly uses
The integrated chip ADG739 of ADI company, it is a CMOS, 4 channel analogy matrix switch of two-way, equipped with Serial Control
Three-wire type interface.Conducting resistance matching between switch is stringent, and in entire range of signal, conducting resistance curve is very flat
It is smooth.ADG739 can be by several this devices with chrysanthemum using the output of shift register DOUT using three-wire type serial line interface
Chain form is connected.
The SPI daisy chain communication link that 4 ADG739 analog switch chips are constituted is realized between 8 channel Temperature Measuring acquisition channels
Be switched fast, when temperature transducer type be RTD when, CPU by software programming control ADG739 1. with ADG739 2., by constant current
Source IOUT1, IOUT2 are successively switched in turn on 8 road RTD sensors, variable resistance signal are changed into voltage signal, then pass through
3. ADG739 with the ADG739 4. successively voltage signal on 8 road RTD thermometric channel of switched scan, finally believes collected voltage
Number by ADC analog-to-digital conversion process be sent to CPU carry out data analytic operation.When temperature transducer type is TC, then it is not required to
Constant-current source IOUT1, IOUT2 are successively switched in turn on 8 road TC sensors, directly by ADG739 3. with ADG739 4. according to
Collected voltage signal is finally passed through ADC analog-to-digital conversion process by the voltage signal on secondary 8 road TC thermometric channel of switched scan
CPU is sent to through row data analytic operation.
Thermocouple English Thermocouple, abbreviation TC, working principle is: with temperature change output linear millivolt letter
Number.Signal amplification is scaled temperature signal by instrument.Thermal resistance English Resistance abbreviation RTD, working principle is: resistance
With temperature change linear change occurs for value.
In software design, the number of the Douta4 pin readback of the daisy chain of the last one SPI chip output can be passed through
According to, it is available from the daisy chain principle of SPI chip, identical data are input into the daisy chain network of the same SPI chip,
The available previous data being input into of output Dout pin of the last one SPI chip.Obtained data are carried out every time
Compare, equal expression current data can correctly export.
CPU first is stored in m_DATA_OUT_CUR when powering on the shift register data for being output to SPI for the first time afterwards, leads to
Cross SPI_DOUT pin readback shift register data m_DATA_OUT_BACK confirmation it is equal with m_DATA_OUT_CUR after,
It is stored in m_DATA_OUT_PRE in variable, the content for then enabling shift register is output to output control register, completes
Primary correct output.
Secondly whether second and its later output, it is equal with m_DATA_OUT_PRE to compare m_DATA_OUT_CUR,
There are two types of situations herein:
A is equal: then the output behavior of SPI chip is consistent with preceding primary output behavior, so unnecessary output data,
A possibility that greatly reducing interference while reducing the burden of CPU.B is unequal: passing through SPI_BIN mouthfuls of output data m_
DATA_OUT_CUR is stored in m_DATA_OUT_BACK in the data of SPI_DOUT readback simultaneously, then m_DATA_OUT_BACK is protected
What is deposited should be the equal data of m_DATA_OUT_PRE, compare m_DATA_OUT_CUR whether with m_DATA_OUT_PRE phase
Deng;Unequal, expression is interfered, and at this moment output data can enter SPI chip until m_DATA_OUT_CUR and m_ again
DATA_OUT_BACK is equal.
Register is controlled to output finally by the content of the enabled output pin Output Shift Register of SPI chip, it is complete
At primary correctly output
Such as first sensor, S1AI and S1BI load constant-current source is first had to, it is necessary to so that ADG739-1#
The corresponding analog switch conducting of S1AI and S1BI, meanwhile, to read the voltage value of first sensor, it is necessary to ensure simultaneously
The corresponding analog switch conducting of the S1AV and S1BV of ADG739-3#;
RTD/TC sampling
RTD/TC controller has 8 common sampling channels, is realized by 4 cascade ADG739 chips to sampling channel
Sequence switching, to realize to the real-time sampling in 8 channels.
RTD/TC sample circuit is divided into two parts
1. channel switching circuit
We choose multiplexer ADG739 to realize that multiplexer channel switches herein, and every 8 paths are one group, with 2
Piece ADG739 cascade, which is realized, (actually uses 4, when sampling to thermal resistance, needs with wherein two panels switchable current source to thermoelectricity
Resistance, to generate potential difference), channel switching software section is designed as every 200ms and carries out a subchannel switching.
2. sampling A/D chip partial circuit
Sampling A/D chip selects AD7793, has 4 configurable pseudo-differential sampling channels, herein matches its first passage
It is set to sampling input terminal, there are two configurable current output sources for itself tool, so as to realize sampling thermal resistance both ends electricity
Potential difference.
Important data structures
The data structure of 1.SPI chip communication
Software block diagram is as shown in Figure 5.
The utility model has the advantages that
The present invention devises a kind of anti-interference multichannel analog amount sample circuit and method, anti-interference multichannel analog amount are adopted
Sample circuit mainly uses the analog switch chip ADG739 of ADI company, in view of the problems of the existing technology, will be in the communication technology
Time-division multiplex technology is introduced into multichannel temperature signal acquisition switching circuit, and multiplex temperature collection data are transmitted through same channel
To ADC digital analog converter, using the powerful software and hardware function of controller multichannel temperature acquisition controller by the data of acquisition into
After row analysis and processing, data are uploaded by fieldbus, the final real time temperature monitoring for realizing field device reaches field level
The temperature of equipment controls.The disadvantages of hardware resource is big, waste is serious is occupied when this method overcomes multichannel while acquiring.Have
Effect has saved system resource, so that complicated control system is become simple, it is easy to accomplish flexible production.The present invention devise it is a kind of by
The daisy chain data transmission structure [daisy chain ring] that multi-disc SPI integrated chip is composed is electric to realize multichannel temperature acquisition switching
Hardware spending is not only reduced when designing hardware in road, can also be returned by the daisy chain output interface of the last one SPI chip
To the input interface of CPU, can guarantee in this way output data can again readback to CPU.
To sum up, anti-interference multichannel analog amount sampling plan of the invention is easy to real using existing integrated chip
It applies, in addition, realizing that the switching of analog switch and sampled data are transmitted using universal serial bus, the port resource of consuming is few, is easy to
Programming is realized, using unique daisy chain architecture, is avoided corrupt data based on data back verification and retransmission mechanism, therefore, is resisted dry
It disturbs and has excellent performance, thus the present invention is especially suitable for the occasions of bad environments.
Embodiment 1: a kind of anti-interference multichannel analog amount sample circuit, including controller, A/D converter, 4 SPI cores
Piece and 8 sensors;
The chip select terminal (CSai, i=1,2 ..., M, M=4) of 4 SPI chips with the chip selection signal output end of controller
CSa is connected;The clock signal input terminal (CLKai, i=1,2 ..., M, M=4) of 4 SPI chips is believed with the clock of controller
Number output end CLKa is connected;
The cascade of 4 SPI chips: 4 SPI chips are arranged in sequence;
The data input pin Dina1 of first SPI chip meets the serial data output terminal Dina of controller;First SPI
The data output end Douta1 of chip meets the data input pin Dina2 of second SPI chip;The data of second SPI chip are defeated
Outlet Douta2 meets the data input pin Dina3 of third SPI chip;And so on, until the data of the 3rd SPI chip are defeated
Enter to hold Dina3 to meet the data output end Douta2 of previous SPI chip;The data output end Douta3 of 3rd SPI chip connects
The data input pin Dina4 of 4 SPI chips;
SPI chip has input shift register and 2 groups of analog switches, i.e. A analoglike switch and B analoglike switch;Often
Group analog switch includes 4 analog switches;First group of analog switch has a common end DA;First group of analog switch has one
A common end DB;
4 SPI chips are divided into 2 groups of the identical front and back of quantity in order, and preceding 2 SPI chips are first group, rear 2 SPI cores
Piece is second group;
The common end DA and common end DB of first group of SPI chip meet 2 terminals IOUT1 and IOUT2 of constant-current source respectively;
Preferably, 2 terminals IOUT1 and IOUT2 of constant-current source are derived from IOUT1 the and IOUT2 pin of A/D converter;
The common end DA and common end DB of second group of SPI chip meet 2 input signal end AIN1 of A/D converter respectively
(+) and AIN1 (-);
The signal of A/D converter connects:
Chip select terminal CSb1, clock signal terminal CLKb1 and the data output end Doutb1 of A/D converter connect controller respectively
Chip selection signal output end CSb, clock signal output terminal CLKb and data input pin Doutb;The signal of sensor connects:
First group of SPI chip has 8 A analoglike switches with 8 B analoglike switches in total, and [first group of SPI chip is corresponding
A analoglike switch port numbers be S (i) AI, B analoglike switch port numbers be S (i) BI];8 A analoglike switch difference
Connect the first end of 8 sensors;8 B analoglike switches connect the second end of 8 sensors respectively;[S1AI in such as Fig. 4,
S1BI;And S2AI, S2BI etc.];
Second group of SPI chip has 8 A analoglike switches and 8 B analoglike switches, [second group of SPI chip pair in total
The port numbers for the A analoglike switch answered are S (i) AV, and the port numbers of B analoglike switch are S (i) BV];M*2 A analoglike switch
The first end of 8 sensors is connect respectively;8 B analoglike switches connect the second end of 8 sensors respectively;[S1AV in such as Fig. 4,
S1BV;And S2AV, S2BV etc.].
The data output end DoutaM of 4th SPI chip meets the checking signal input terminal Douta of controller.
Isolating chip is equipped between first SPI chip and controller;Between A/D converter and controller be equipped with every
Off-chip piece.
The isolating chip uses ADuM1411 chip, and the SPI chip uses ADG739 chip, the A/D
Converter uses AD7793.
The sensor is thermoelectricity occasionally thermal resistance, is also possible to other kinds of sensor, such as pressure sensor, wet
Spend sensor etc..
Controller is single-chip microcontroller or DSP.
Sample detailed process:
(1) for do not need load constant-current source sensor [such as RTD];It is issued in second group of instruction control by controller
2 analog switches of a certain SPI chip are connected, so that the both ends of one of sensor are drawn by the analog switch of the conducting
For voltage signal to 2 input signal end AIN1 (+) of signal input part of A/D converter and AIN1 (-), A/D converter exports number
Word signal completes data sampling to controller;
(2) for needing to load the sensor [such as TC] of constant-current source;
It is first connected by 2 analog switches that controller issues a certain SPI chip in first group of instruction control, so that wherein
The both ends of one sensor are separately connected 2 terminals IOUT1 and IOUT2 of constant-current source by the analog switch of the conducting;
It is connected again by 2 analog switches that controller issues a certain SPI chip in second group of instruction control, so that wherein
The both ends of one sensor are defeated by signal input part 2 of analog switch extraction voltage signal to the A/D converter of the conducting
Enter signal end AIN1 (+) and AIN1 (-);A/D converter output digit signals complete data sampling to controller.
Jamproof process is realized by checking procedure:
Controller is m_DATA_OUT_PRE by the data that pin Dina is exported;
The data that controller passes through the Douta readback of checking signal input terminal are m_DATA_OUT_CUR;
Compare m_DATA_OUT_PRE and m_DATA_OUT_CUR, if equal, then it represents that data output is normal, otherwise, table
Registration is interfered according to output, retransmission data.
A kind of anti-interference multichannel analog amount method of sampling, it is real using anti-interference multichannel analog amount sample circuit above-mentioned
Existing data sampling;
4 SPI chip cascades are formed into daisy chain sampling structure, to can control the sampling for any one sensor;
By the checking signal input terminal Douta readback that the data output end Douta4 of the 4th SPI chip is connect to controller
Data;
Controller is m_DATA_OUT_PRE by the data that pin Dina is exported;
The data that controller passes through pin Douta readback are m_DATA_OUT_CUR;
Compare m_DATA_OUT_PRE and m_DATA_OUT_CUR, if equal, then it represents that data output is normal, otherwise, table
Registration is interfered according to output, retransmission data;It is anti-interference by comparison mechanism above-mentioned and retransmission mechanism.
ADG739[2.5 Ω, low pressure, three-wire type Serial Control, 4 access matrix of two-way switch] it is that a CMOS, two-way 4 are logical
Road analog matrix switch, the three-wire type interface equipped with a Serial Control.Conducting resistance matching between switch is stringent, and
In entire range of signal, conducting resistance curve is very flat.
ADG739 uses three-wire type serial line interface, and and SPITM、QSPITM、MICROWIRETMAnd some dsp interface marks
Standard is compatible.Using the output of shift register DOUT, several this devices can be connected in the form of daisy chain.It is interior when powering on
Portion's shift register is complete zero, and all switches are in off-state.
When connection, each switch is identical in the electric conductivity of both direction, therefore this device is both suitble to multiplexing, also fits
Close demultiplexing application.Each switch is switched on or switched off by individual position, therefore this device is also configurable to cubicle switchboard
Formation formula, eight switch in it is any or all switch can closing or opening at any time.Input reference signal can be extended to electricity
Source voltage range.
All channels are all made of break-before-make formula switch, prevent that instantaneous short-circuit occurs when switching channels.ADG739 uses 16
Pin TSSOP encapsulation.