C # Write the 34401a serial port 232 Data reading program

Source: Internet
Author: User
Tags idn
Document directory
  •  

First, set the HP table to the talk only mode, that is, 31.

In addition, the settings for each table are different. For example, the two tables here are different. One is 7-Bit Data bit, and the other is even. The other is 8-Bit Data bit, and the other is none. For more information, see the I/O settings in the table.

Data line practice, 9pin line, 2, 3, 4, 6, 7, 8, other direct connections

I am using the SerialPort component in. Net formworks2. The only thing to note is that sp1.dtrenable = enabled; this must be enabled, otherwise data cannot be obtained.

I wrote a small program source code and learned the first program of C #. It is not very well written, but it can be used.

Http://anerg.ys168.com

 

 

 

The C # code just passed the debugging is used for the serial communication of the Agilent 34401a.

 

  1. First, set the interface of 34401a to RS232, baud rate to 9600, and parity to non: 8 bits.
  2. The following code snippet tests voltage and current.
SerialPort serialPort = new SerialPort("COM3");serialPort.DtrEnable = true;serialPort.Open();serialPort.WriteLine("SYST:REM");serialPort.WriteLine("*CLS");serialPort.WriteLine("TRIG:SOUR IMM");serialPort.WriteLine("MEAS:VOLT:DC? AUTO, MIN");var v = double.Parse(serialPort.ReadLine());serialPort.WriteLine("MEAS:CURR:DC? AUTO, MIN");var i = double.Parse(serialPort.ReadLine());

 

 

MEAs: volt? The MEAs: curr? Read power output current MEAs: pow? Read power output MEAs: DVM? Read input voltage of the voltmeter MEAs: res? Read the resistance value * STB? It is used to read the value stored by the Status bit. After this command is executed, the register is cleared and calibration: current returns the actual output current value to the current power supply calibration point status: questionable: condition? The value status: questionable: Enable is used to read the value status: Operation: Enable in the query Time Register. onput: State? Is it used to control the Enable and disable IDN of power output? Must be the last query command IDN in the command string? : Syst: vers? Configure enter * rstsystem: remotemeas: curr?

 

 

About the SCPI command that can be sent, the signal is not received:

I thought it was an internal communication that needs to be set up. I tried it but it still didn't work. I finally switched it to the USB-to-Serial Line and connected it to the line of the device itself, so that the communication would be normal.

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.