Development of Python acquisition software using VSPD, Modbustool analog serial port and MODBUS TCP device

Source: Internet
Author: User

Copyright NOTICE: This article is for Bo Master original article, welcome reprint, and please indicate the source. Contact information: [Email protected]

Many instruments/devices provide data acquisition interface, many of which are serial or network MODBUS/TCP protocol.

The serial port is relatively simple, but the older interface way, now the notebook basically does not have this form of interface, if the software development in the notebook, can not be debugged, or to bypass the USB to the serial port of the small device, very inconvenient.

Fortunately there are predecessors to develop a virtual serial port software, can be very convenient for the development of serial communication software, I use VSPD (network disk). The development of virtual serial port software has several advantages:

1, the computer/notebook does not have the serial port to develop normally.
2, the communication/acquisition software development process does not affect the normal use of equipment.
3, the software development process can eliminate the impact of hardware failure.
4, if the software, hardware development together, can be carried out in parallel, without waiting for hardware to complete before the software debugging.

VSPD installation and basic use method:
1, the implementation of Vspd.exe for software installation
2. Running Vspdconfig.exe
3. Select the port name pair and click Add Port. Add 2 ports at a time, one send two receive, two send one receive.

Use one port to simulate the serial port of the computer, and the other port to simulate the other device ports, according to the communication protocol of the two programs.

The following is a Python program written to simulate the Fiberpro polarization extinction ratio tester ER2200:

#-*-coding:utf-8-*-u"""Fiberpro Polarization extinction ratio tester ER2200 simulation program"""__author__='zhengbiqing [email protected]'ImportBinasciiImportSignalImportSYSImportSerialser= Serial. Serial ('COM4', 115200, Timeout=1)Print 'Welcome to',__doc__,',','Device is%s'% (' Ready' ifSer.isopen ()Else 'Error')Print 'Author is',__author__#CTRL + C processing functiondefSignal_handler (signal, frame): Ser.close ()Print 'You pressed ctrl+c!','Device is%s'% ('Closed' if  notSer.isopen ()Else 'Error')    Print 'goodbye!'sys.exit (0)#The program is a dead loop, exit by CTRL + C, in order to close the serial port when exiting, capture the signalsignal.signal (signal. SIGINT, Signal_handler) whileTrue:data= Ser.read (7)    iflen (data):#Debug Print, B2a_hex (data) is the conversion of the string data to hexadecimal number        PrintBinascii.b2a_hex (data), dataifdata = ='read?\r\n':        #three numbers representing the light extinction ratio, polarization angle, and optical power respectivelySer.write ('19.35,53.47,-5.17\r')

The use of the network Port Modbus TCP protocol equipment, the development of data acquisition software can also be used to replace the actual equipment simulation software, the completion of the software used to the actual equipment.

I use Modbustool (network disk), including master and slave, respectively, to simulate the master and slave devices.

Modbustool installation and Basic methods of use:
1. Perform setup.exe installation separately.
2, to master, fill in a good wish to connect the device IP, port, click Connnet Connection Device, fill in start address, size read and write length, click functions function code on the line.
3, to Slave, fill in the port number of the listening port, click Listen wait for master connection (listening interface is 127.0.0.1), you can enter a number in the address after the point apply to address data settings.

Development of Python acquisition software using VSPD, Modbustool analog serial port and MODBUS TCP device

Related Article

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.