Arbitrary Waveform Generator control library using SCPI protocol over TCP.
- Model: MP750513 Arbitrary Waveform Generator
- Interface: Ethernet (TCP Socket)
- Default Port: 5025
- Protocol: SCPI (Standard Commands for Programmable Instruments)
- IP Address: 192.168.1.97
The MP750513 driver is part of the awg_device package:
from awg_device import MP750513from awg_device import MP750513
# Connect to AWG
awg = MP750513("192.168.1.97")
# Set sine wave at 1 kHz
awg.set_waveform("SIN")
awg.set_frequency(1000)
awg.set_amplitude(5.0)
# Enable output
awg.output_on()
# Read back parameters
print(awg.get_frequency())
print(awg.get_amplitude())
# Disable output
awg.output_off()awg = MP750513(ip, port=5025, timeout=2)Parameters:
ip(str): Device IP addressport(int): TCP port (default: 5025)timeout(float): Socket timeout in seconds
awg.output_on() # Enable output
awg.output_off() # Disable output
awg.get_output_state() # Get output state
awg.enable() # Alias for output_on()
awg.disable() # Alias for output_off()awg.set_frequency(freq) # Set frequency in Hz
awg.get_frequency() # Get frequency in HzExample:
awg.set_frequency(5000) # 5 kHzawg.set_amplitude(amp) # Set amplitude in Volts
awg.get_amplitude() # Get amplitude in Volts
awg.set_voltage(volt) # Alias
awg.get_voltage() # AliasExample:
awg.set_amplitude(3.3) # 3.3V amplitudeawg.set_dc_offset(offset) # Set offset in Volts
awg.get_dc_offset() # Get offset in Volts
awg.set_offset(offset) # Alias
awg.get_offset() # AliasExample:
awg.set_dc_offset(1.5) # 1.5V offsetawg.set_waveform(waveform) # Set waveform: SIN, SQU, TRI, RAMP
awg.get_waveform() # Get current waveform type
# Convenience methods:
awg.set_sine() # Set to sine wave
awg.set_square() # Set to square wave
awg.set_triangle() # Set to triangle wave
awg.set_ramp() # Set to ramp waveExample:
awg.set_sine() # sine wave
awg.set_frequency(1000)
awg.set_amplitude(5.0)awg.set_phase(phase) # Set phase in degrees
awg.get_phase() # Get phase in degreesExample:
awg.set_phase(45) # 45 degree phase shiftawg.set_duty_cycle(duty) # Set duty cycle (0-100%)
awg.get_duty_cycle() # Get duty cycleExample:
awg.set_square()
awg.set_duty_cycle(75) # 75% duty cycleawg.enable_burst() # Enable burst mode
awg.disable_burst() # Disable burst mode
awg.set_burst_mode(mode) # Set burst mode: TRIGgered or MANUAL
awg.get_burst_mode() # Get burst mode
awg.set_burst_cycles(cycles) # Set number of cycles per burst
awg.get_burst_cycles() # Get burst cycle count
awg.trigger_burst() # Trigger a burst
awg.trigger() # Alias for trigger_burst()Example:
awg.enable_burst()
awg.set_burst_mode("TRIGgered")
awg.set_burst_cycles(10) # 10 cycles per burst
awg.trigger() # Fire one burstawg.get_id() # Get device identification (*IDN?)
awg.is_connected() # Check if device is reachableA Flask app is included to expose the AWG over HTTP on port 3000.
Launch:
python -m flask --app awg_device.flask_app run --port 3000API Endpoints:
GET /- Index pageGET /id- Device identificationPOST /output- Enable/disable outputGET /get/output- Get output statePOST /set/frequency- Set frequencyGET /get/frequency- Get frequencyPOST /set/amplitude- Set amplitudeGET /get/amplitude- Get amplitudePOST /set/offset- Set DC offsetGET /get/offset- Get DC offsetPOST /set/waveform- Set waveform typeGET /get/waveform- Get waveform typePOST /set/phase- Set phaseGET /get/phase- Get phasePOST /set/duty-cycle- Set duty cycleGET /get/duty-cycle- Get duty cyclePOST /burst/enable- Enable burst modePOST /burst/disable- Disable burst modePOST /burst/set-cycles- Set burst cycle countPOST /burst/trigger- Trigger a burstGET /measure- Get all current parameters
Example REST calls:
# Enable output
curl -X POST http://192.168.1.97:3000/output \
-H "Content-Type: application/json" \
-d '{"state": true}'
# Set 1kHz sine wave at 5V
curl -X POST http://192.168.1.97:3000/set/frequency \
-H "Content-Type: application/json" \
-d '{"frequency": 1000}'
curl -X POST http://192.168.1.97:3000/set/waveform \
-H "Content-Type: application/json" \
-d '{"waveform": "SIN"}'
curl -X POST http://192.168.1.97:3000/set/amplitude \
-H "Content-Type: application/json" \
-d '{"amplitude": 5.0}'- The driver is designed to be blocking and safe (no polling loops)
- Connection issues trigger automatic reconnection
- All socket operations include timeout handling
- DC offset is useful for biasing signals (e.g., for AC coupling)
- Burst mode allows generation of a finite number of waveform cycles triggered by command or external signal