"Application Note" "AN004" 4-20ma current acquisition based on RS-485 in VB environment

Source: Internet
Author: User

Version: First edition week new stable Yang Shuai Date: 20160226

===========================

This material HD PDF download:

Http://pan.baidu.com/s/1c1uuhLQ

Source Code Package Download:

Http://pan.baidu.com/s/1LSuXw

===========================

Introduction

This Application note mainly explains how to realize 4-20ma current acquisition based on RS485 in VB development environment. System composition and working principle

System composition 1, mainly including PT100 Platinum resistance temperature sensor, SBWZ temperature transmitter, 4-20ma current acquisition module (GM1008), USB to RS485 module (EVC8001) and the host computer VB.

Figure 1 System composition block diagram

PT100 Platinum Resistance Temperature sensor: a temperature sensor used to measure the change in temperature by using a platinum metal resistance characteristic that changes with temperature.

SBWZ Temperature transmitter: A field-mounted temperature transmitter unit that transforms the platinum resistor signal into a linear 4-20ma output signal.

4-20ma Current Acquisition Module (GM1008): RS485 interface of the GM1008 current acquisition module, the main realization of data acquisition and transmission, and through the RS485 interface with the host computer to communicate.

USB to RS485 module (EVC8001): Implement GM1008 RS485 interface with the host computer USB interface successfully connected.

Host computer VB: Make the upper computer interface, to achieve the measured data collection, analysis and display.

While the system is operating, when the temperature is changed,

The resistance value of PT100 Platinum resistance temperature sensor changes, its resistance is converted to current signal by SBWZ temperature transmitter, and communicates with host computer via 4-20ma current acquisition module (GM1008) and USB to RS485 module (EVC8001) to realize di current acquisition, Analysis and display. Current Acquisition Module

The system uses the RS485 interface of the 8-channel 4-20ma current acquisition module (GM1008), not only can more quickly and accurately transmit the measurement data to the host computer, to ensure the efficiency of the system, but also can make the system information transmission more stable.

GM1008 Introduction

The GM1008 8-channel 4-20ma Current acquisition module (hereinafter referred to as the module) uses a full-appliance isolation scheme, with a high-performance microprocessor and a 8-channel 12-bit ADC to perform the current measurement function in a smaller volume.

The modules are built-in high-performance power conversion circuitry with a wide supply voltage range of 7.5v-36v and efficiency up to 90%. This feature provides protection for long-time use of power supply stability. Module built-in 1500V dual isolated power supply module, so that the power supply input, analog measurement circuit and communication interface are isolated from each other, this feature for measurement accuracy, module stability and versatility to provide assurance.

The module built-in high-quality RS485 circuit based on magnetic coupling isolation technology, long-term use of stable and reliable, anti-interference strong, not off-line.

The module has a 32-bit high performance arm microprocessor which not only completes 8-channel, 12-bit current acquisition, but also supports firmware upgrade function, which provides technical guarantee for post-function upgrade and bug fix. Program design of VB host computer

VB Introduction to the development environment

VB, known as Visual Basic, is a time-driven programming language developed by Microsoft to assist the development environment, with a graphical user interface and a rapid application development system that can easily connect to a database using DAO, RDO, ADO, or easily create active controls. In view of these performance of VB to meet the needs of the application of this system, so choose VB as the host computer development environment of this experiment.

How to use the software

As shown in software interface 2.

Figure 2 Software interface

The specific operation method of the software is as follows:

1. set the port in the ports (the port number is obtained by querying the Device Manager);

2. set the baud rate inside the baudrate, the general fixed is 9600;

3. set parity in parity, generally fixed to none (no calibration);

4. set the stop bit inside stop bits, generally fixed to one (a stop bit);

5. set the slave address to 1;

6. Click the Open button to automatically connect the RS485, this button becomes close;

7. Tap the Start button to start collecting current;

8. Click the Stop button to stop the acquisition;

9. Click the Close button to disconnect the RS485 and clear the data.

Software core code

The core code has two main parts: the CRC check Code (see Appendix 1) and the Data processing code (see Appendix 2).

1. CRC Check code: CRC check is to ensure the accurate transmission of data, among which there are many methods of CRC calibration, this procedure is to look up the table method, greatly improve the calibration speed.

2. Data processing code: wherein MODBUS_FUN3 means that the choice of Modbus function code is 3, is the read-hold register function. This section of code from 214 lines to 221 behaves in the Register Settings section of the Modbus Communication format, followed by the sending and receiving commands of the data, and the subsequent docking of the received data for processing to facilitate the display in the form of physical quantities. Measurement Collection Demo and description

Equipped with tools or software

1. 12V power supply

2. PT100 Platinum Resistance temperature sensor

3. SBWZ Series Temperature transmitter

4. RS485 Interface 8-channel 4-20ma current acquisition module (GM1008)

5. USB to RS485 module (EVC8001)

6. aligent 34401A benchtop Six-bit digital multimeter

7. Application Platform: Visual Studio 2015 Community Edition (download by yourself)

8. Computer operating system: Windows 8.1 x32

System Connection Mode

This experiment mainly collects two channels of current data, in order to keep the picture line clear and neat, only access 1 SBWZ, the other connection method is the same. System main hardware connection 3 is shown.

Figure 3 System main hardware connection diagram

(1) power supply (12V) Conductor 1: Positive connection temperature transmitter positive wiring column, negative connection GM1008 grounding port (GND);

(2) Conductor 2: A port connecting the grounding port of the GM1008 to the power of the GM1008 (power);

(3) Conductor 3: Connect the temperature transmitter to another port on the GM1008 power supply (power);

(4) conductor 4: Connection channel and temperature transmitter negative terminal;

(5) Wire 5: B-Port connecting the RS485 module of the EVC8001 and GM1008;

(6) Wire 6: A + port connecting the RS485 module of the EVC8001 and GM1008;

(7) Square Port USB cable: Connect EVC8001 with computer.

Test steps

1. Connect the components according to the system main hardware connection diagram (Figure 3);

2. Access to two temperature transmitters, GM1008 configuration two channels, the CH0 set as boiling water data acquisition channel, CH1 set as a lighter flame data acquisition channel;

3. Then set the port in the program interface and the relevant parameters (from the address of the machine is generally fixed to 1);

4. Put two PT100 platinum resistors into boiling water and lighter flame respectively (the operation is the Open button of the Click Interface, connect the next Point Start button, the system will automatically collect data, easy to operate).

Test Results

In order to verify the accuracy of the test results and obtain the accurate temperature, the experimental data Interface 4 shows the experimental test.

Fig. 4 Data graph of experiment collection

(1) Accuracy verification

In order to verify the accuracy of the measured current value, the Aligent 34401A benchtop six-bit digital multimeter is concatenated into the circuit of the SBWZ temperature transmitter back end, and the current reading of the multimeter is compared with the current value displayed on the host computer. The experimental results are as shown in table 1, after many experiments, the results of the two groups of data are basically the same.

Table 1 Experimental Data sheets

Object under test

GM1008 measured value

Multimeter Measurement Value

SBWZ corresponding temperature

Water (CH0)

7.68mA

7.64mA

92 ℃

Lighters (CH1)

19.67mA

19.65mA

393 ℃

(2) Experimental verification

By the relationship between the SBWZ temperature transmitter and the range of the PT100 Platinum resistor, the relationship between the actual measured current and the temperature is obtained:

y=25*x-100

The measured current value of the measured water temperature is about 92 ℃, the flame is about 393 ℃ (because the flame temperature is higher than the maximum measured value of PT100, so to stop the experiment after 19mA, so as not to damage the equipment), the test results and the actual match.

Therefore, the test shows: the system in the VB development environment based on RS485 measured data is true and reliable, can be applied to the actual. Summarize

The successful test of this application system proves that the 4-20ma current acquisition based on RS485 in VB development environment is feasible, the interface of PC software makes the operation of measurement simple, the data is clear, it is easy for users to monitor the data of industrial automation system in real time, and meet the demand of the industry for data.


Resources

1. "VB language Programming"

2. download the relevant resources of C programming language

1 , Visual Studio :

Https://www.visualstudio.com/downloads/download-visual-studio-vs

2 , GM1008 Simple manual:

Http://files.cnblogs.com/files/xiaomagee/GM1008%E7%AE%80%E6%98%93%E6%89%8B%E5%86%8CV1.0.pdf

3 , GM1008 User manual:

Http://files.cnblogs.com/files/xiaomagee/GM1008%E7%94%A8%E6%88%B7%E6%89%8B%E5%86%8CV1.0.pdf

4 , GM1008 Purchase Address:

https://item.taobao.com/item.htm?spm=a1z10.3c.w4002251610686.9.zoJaPi&id=522203245449

Appendix 1 : CRC Checksum Code

121 ' CRC check

122 Function CRC(Data() as Byte, length as Integer, ByRef returndatalo as Byte, ByRef Returndatahi as Byte) as String

123 Dim crc16hi as Byte

124 Dim crc16lo as Byte

Crc16hi = &HFF

126 Crc16lo = &HFF

127 Dim i as Integer

- Dim iIndex as Long

129

0 to length - 1

131 IIndex = crc16hi Xor data(i)

Crc16hi = crc16lo Xor getcrchi(iIndex) ' low processing

133 Crc16lo = getcrclo(iIndex) ' High processing

134 Next I

135 Returndatahi = Crc16hi ' CRC high

136 Returndatalo = Crc16lo ' CRC low

137

138 Return 1

139 End Function

205 ' Data processing

206 Private Function modbus_fun3(start_address as Integer , Read_number as integer) as integer

207 Dim sendbyte = New Byte() {0, 0 , 0, 0, 0, 0, 0, 0}

208 Dim recvbyte(.) as Byte

209 Dim length as Int32

About Dim Data(as Int16)

211 Dim crc_value as Int16

212 Dim i as Int16

213 Dim text as String

214 sendbyte(0) = 1 ' unit identifier

215 sendbyte(1) = 3 ' function code

216 sendbyte(2) = start_address >> 8 ' Read Register start address

217 Sendbyte(3) = start_address

218 sendbyte(4) = read_number >> 8 ' Read register number

219 sendbyte(5) = Read_number

-

221 Crc_value = CRC(Sendbyte, 6,sendbyte(7) ,sendbyte(6))

222 Try

223 Text = ""

224 ' Send command

225 SerialPort1. Write (sendbyte, 0, 8)

226 ' receive data

227 Length = SerialPort1. Bytestoread()

228 while (length <

229 Length = SerialPort1. Bytestoread()

the End while

231 I = SerialPort1. Read(recvbyte, 0, length)

232 for k = 0 to 23

233 Data(k) = (recvbyte(k * 2 + 3) * + recvbyte(k * 2 + 4 ) )

234 Next k

235 ' numeric conversions

236 for i = 0 to 7

237 display_value(i) = (data(i * 3 + 2) / 100.0)

238 Next I

Appendix 2 : Show channel data program

239 Catch ex as Exception

-

241 End Try

242 Return 1

243 End Function

"Application Note" "AN004" 4-20ma current acquisition based on RS-485 in VB environment

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.