Skip to content

Connecting to MHS 5200 A by Minghe in Python

Instrument Card

MHS-5200A series instruments using large scale integrated circuits andhigh-speed FPGA MCU microprocessor, the internal circuit to take surface mounttechnology has greatly enhanced the instrument’s noise immunity and service life.Display interface using LC1602 LCD display is divided into two lines, the top lineshows the current frequency, the following line displays additional parameters orfunction variable and flexible use of flip key setting, greatly enhances the operability.

MHS 5200 A

Device Specification: here

Manufacturer card: MINGHE

Could not find

  • Headquarters:
  • Yearly Revenue (millions, USD):
  • Vendor Website: here

Connect to the MHS 5200 A in Python

PROTOCOLS > SCPI

Here is an example Python script that uses Instrumentkit to connect to a MHS 5200 A Function Generator:

import instrumentkit as ik
# Connect to the MHS 5200 A Function Generator
mhs = ik.minghe.MHS5200.open_serial(vid=1027, pid=24577, baud=19200, timeout=1)
# Set the frequency of channel 1 to 1 kHz
mhs.channel[0].frequency = 1e3
# Set the amplitude of channel 1 to 2 V peak-to-peak
mhs.channel[0].amplitude = 2, ik.VoltageMode.peak_to_peak
# Enable channel 1
mhs.channel[0].enable = True
# Set the frequency of channel 2 to 2 kHz
mhs.channel[1].frequency = 2e3
# Set the amplitude of channel 2 to 1 V rms
mhs.channel[1].amplitude = 1, ik.VoltageMode.rms
# Enable channel 2
mhs.channel[1].enable = True
# Disconnect from the MHS 5200 A Function Generator
mhs.close()

Explanation:

  1. The import instrumentkit as ik statement imports the Instrumentkit library and assigns it the alias ik.
  2. The ik.minghe.MHS5200.open_serial() function is used to connect to the MHS 5200 A Function Generator via serial communication. The vid, pid, baud, and timeout parameters specify the vendor ID, product ID, baud rate, and timeout for the serial connection.
  3. The mhs.channel[0] and mhs.channel[1] statements access the first and second channels of the MHS 5200 A Function Generator, respectively.
  4. The frequency property is used to set the frequency of a channel. In this example, the frequency of channel 1 is set to 1 kHz and the frequency of channel 2 is set to 2 kHz.
  5. The amplitude property is used to set the amplitude of a channel. In this example, the amplitude of channel 1 is set to 2 V peak-to-peak and the amplitude of channel 2 is set to 1 V rms.
  6. The enable property is used to enable or disable a channel. In this example, both channel 1 and channel 2 are enabled.
  7. The mhs.close() statement is used to disconnect from the MHS 5200 A Function Generator.