The GW Instek AFG-2012 and AFG-2025 function generator is controlled remotely with SCPI commands. TestFlow's instrument library holds 67 commands for it, 9 of them queries that read values or state, grouped below by subsystem with their arguments. It is the same library TestFlow's AI agent uses to drive the AFG-2012 on a real bench.
Describe the test; TestFlow's agent uses this command set to drive your GW Instek AFG-2012 or AFG-2025 and writes the report from the measured results.
With PyVISA, any VISA backend, and the instrument on USB, LAN or GPIB, this opens a session, identifies the instrument, sends one setting, and reads one value. Every command in it comes from the reference below. For a full walkthrough, see the PyVISA tutorial and the SCPI command cheat sheet.
import pyvisa
rm = pyvisa.ResourceManager()
print(rm.list_resources()) # find the GW Instek AFG-2012's VISA address
# Paste the address of your GW Instek AFG-2012 (USB, LAN or GPIB).
inst = rm.open_resource("PASTE_VISA_ADDRESS_HERE")
inst.timeout = 5000 # ms
print(inst.query("*IDN?")) # identify the instrument
inst.write("OUTPut ON") # Turn On Output CH1
print(inst.query("OUTPut?")) # Read Output State CH1
inst.close()Describe the test; TestFlow's agent uses this command set to drive your GW Instek AFG-2012 or AFG-2025 and writes the report from the measured results.
Describe the test in a sentence, for example “turn on output ch1 on the AFG-2012, then read output state ch1 and log it against a limit”. TestFlow's agent builds the steps from this command library, runs them on your bench through the TestFlow desktop app, and writes the report from the measured values. See AI test automation for lab instruments for how that works and where it stops.
67 commands in 9 groups. A ? marks a query that returns a value. Placeholders in angle brackets take the listed values. The AFG-2012 and AFG-2025 share this command set in TestFlow's library.
| Command | What it does | Arguments |
|---|---|---|
| SOURce1:FUNCtion <Shape> | Set Function CH1. Sets the output waveform shape for channel 1. | Text: SINusoid,SQUare,RAMP,NOISe,USER |
| SOURce1:FUNCtion? | Read Function CH1. Reads the output waveform shape for channel 1. | None |
| SOURce1:FREQuency <Freq> | Set Frequency CH1. Sets the output frequency in Hz for channel 1. | Number |
| SOURce1:FREQuency? | Read Frequency CH1. Reads the output frequency for channel 1. | None |
| SOURce1:PERiod <Sec> | Set Period CH1. Sets the output period in seconds for channel 1. | Number |
| SOURce1:AMPlitude <Amp> | Set Amplitude CH1. Sets the output amplitude (Vpp) for channel 1. | Number |
| SOURce1:AMPlitude? | Read Amplitude CH1. Reads the output amplitude for channel 1. | None |
| SOURce1:DCOffset <Volt> | Set Voltage Offset CH1. Sets the DC offset voltage for channel 1. | Number |
| SOURce1:DCOffset? | Read Voltage Offset CH1. Reads the DC offset voltage for channel 1. | None |
| SOURce1:VOLTage:UNIT <Unit> | Set Voltage Unit CH1. Sets the amplitude unit for channel 1. | Text: VPP,VRMS,DBM |
| SOURce1:PHASe <Deg> | Set Phase CH1. Sets the output phase in degrees for channel 1. | Number |
| SOURce1:RAMP:SYMMetry <Pct> | Set Ramp Symmetry CH1. Sets the ramp symmetry percentage for channel 1. | Number: 0-100 |
| SOURce1:SQUare:DCYCle <Pct> | Set Square Duty Cycle CH1. Sets the square-wave duty cycle for channel 1. | Number |
| SOURce1:PULSe:WIDTh <Sec> | Set Pulse Width CH1. Sets the pulse width in seconds for channel 1. | Number |
| SOURce1:PULSe:DCYCle <Pct> | Set Pulse Duty Cycle CH1. Sets the pulse duty cycle for channel 1. | Number |
| SOURce1:FUNCtion USER | Set Arb Waveform CH1. Selects the arbitrary waveform for channel 1. | None |
| SOURce1:AM:STATe ON | Enable AM CH1. Enables AM modulation on channel 1. | None |
| SOURce1:AM:STATe OFF | Disable AM CH1. Disables AM modulation on channel 1. | None |
| SOURce1:AM:DEPTh <Pct> | Set AM Deviation CH1. Sets the AM depth percentage for channel 1. | Number |
| SOURce1:AM:SOURce <Src> | Set AM Source CH1. Sets the AM modulation source for channel 1. | Text: INTernal,EXTernal |
| SOURce1:AM:INTernal:FREQuency <Freq> | Set AM Int Freq CH1. Sets the internal AM modulating frequency for channel 1. | Number |
| SOURce1:FM:STATe ON | Enable FM CH1. Enables FM modulation on channel 1. | None |
| SOURce1:FM:STATe OFF | Disable FM CH1. Disables FM modulation on channel 1. | None |
| SOURce1:FM:DEViation <Freq> | Set FM Deviation CH1. Sets the FM frequency deviation for channel 1. | Number |
| SOURce1:FM:SOURce <Src> | Set FM Source CH1. Sets the FM modulation source for channel 1. | Text: INTernal,EXTernal |
| SOURce1:FM:INTernal:FREQuency <Freq> | Set FM Int Freq CH1. Sets the internal FM modulating frequency for channel 1. | Number |
| SOURce1:PM:STATe ON | Enable PM CH1. Enables PM modulation on channel 1. | None |
| SOURce1:PM:STATe OFF | Disable PM CH1. Disables PM modulation on channel 1. | None |
| SOURce1:PM:DEViation <Deg> | Set PM Deviation CH1. Sets the PM phase deviation for channel 1. | Number |
| SOURce1:PM:SOURce <Src> | Set PM Source CH1. Sets the PM modulation source for channel 1. | Text: INTernal,EXTernal |
| SOURce1:PM:INTernal:FREQuency <Freq> | Set PM Int Freq CH1. Sets the internal PM modulating frequency for channel 1. | Number |
| SOURce1:FSKey:STATe ON | Enable FSK CH1. Enables FSK modulation on channel 1. | None |
| SOURce1:FSKey:STATe OFF | Disable FSK CH1. Disables FSK modulation on channel 1. | None |
| SOURce1:FSKey:FREQuency <Freq> | Set FSK Hop Freq CH1. Sets the FSK hop frequency for channel 1. | Number |
| SOURce1:PWM:STATe ON | Enable PWM CH1. Enables PWM modulation on channel 1. | None |
| SOURce1:PWM:STATe OFF | Disable PWM CH1. Disables PWM modulation on channel 1. | None |
| SOURce1:SWEep:STATe ON | Enable Sweep CH1. Enables the frequency sweep on channel 1. | None |
| SOURce1:SWEep:STATe OFF | Disable Sweep CH1. Disables the frequency sweep on channel 1. | None |
| SOURce1:SWEep:TIME <Sec> | Set Sweep Time CH1. Sets the sweep time for channel 1. | Number |
| SOURce1:SWEep:SPACing <Type> | Set Sweep Spacing CH1. Sets the sweep spacing for channel 1. | Text: LINear,LOGarithmic |
| SOURce1:FREQuency:STARt <Freq> | Set Sweep Start Freq CH1. Sets the sweep start frequency for channel 1. | Number |
| SOURce1:FREQuency:STOP <Freq> | Set Sweep Stop Freq CH1. Sets the sweep stop frequency for channel 1. | Number |
| SOURce1:BURSt:STATe ON | Enable Burst CH1. Enables burst mode on channel 1. | None |
| SOURce1:BURSt:STATe OFF | Disable Burst CH1. Disables burst mode on channel 1. | None |
| SOURce1:BURSt:MODE <Mode> | Set Burst Mode CH1. Sets the burst mode for channel 1. | Text: TRIGgered,GATed,INFinity |
| SOURce1:BURSt:NCYCles <N> | Set Burst Cycles CH1. Sets the number of cycles per burst for channel 1. | Number |
| SOURce1:BURSt:INTernal:PERiod <Sec> | Set Burst Period CH1. Sets the internal burst period for channel 1. | Number |
| SOURce1:BURSt:PHASe <Deg> | Set Burst Phase CH1. Sets the burst start phase for channel 1. | Number |
| Command | What it does | Arguments |
|---|---|---|
| OUTPut ON | Turn On Output CH1. Enables channel 1 output. | None |
| OUTPut OFF | Turn Off Output CH1. Disables channel 1 output. | None |
| OUTPut? | Read Output State CH1. Reads channel 1 output state. | None |
| OUTPut1:LOAD <Ohm> | Set Output Load CH1. Sets channel 1 output load in ohms; use INFinity for high-Z. | Number |
| Command | What it does | Arguments |
|---|---|---|
| COUNter:STATe ON | Enable Counter. Enables the frequency counter. | None |
| COUNter:STATe OFF | Disable Counter. Disables the frequency counter. | None |
| Command | What it does | Arguments |
|---|---|---|
| TRIGger:SOURce <Src> | Set Trigger Source. Sets the trigger source. | Text: IMMediate,EXTernal,MANual,BUS |
| Command | What it does | Arguments |
|---|---|---|
| SYSTem:ERRor? | Read Error. Reads and clears the next error-queue entry. | None |
| Command | What it does | Arguments |
|---|---|---|
| <Output Variable>=<Equation> | Math. Variable equals an equation like (${Var_name}= ${Var_name}/2) | Number; Text |
| Command | What it does | Arguments |
|---|---|---|
| wait(<ms>) | Wait. Waits for number of milliseconds | Number |
| Command | What it does | Arguments |
|---|---|---|
| save2var <Variable_name> | Save2Variable. Saves last measurement to a variable | Text |
| Command | What it does | Arguments |
|---|---|---|
| *IDN? | Identify. Returns the instrument identification string (manufacturer, model, serial, firmware). | None |
| *RST | Reset. Resets the instrument to its default state. | None |
| *CLS | Clear Status. Clears all event registers and the error queue. | None |
| *TST? | Self Test. Runs the self-test and returns 0 for pass. | None |
| *OPC? | Operation Complete. Returns 1 when all pending operations are complete. | None |
| *WAI | Wait To Continue. Waits until all pending operations are complete. | None |
| *SAV <Slot> | Save State Slot. Stores the current state to a memory slot. | Number |
| *RCL <Slot> | Recall State Slot. Recalls a state from a memory slot. | Number |
This reference is generated from TestFlow's instrument library, which is drafted from GW Instek's programming documentation for the AFG-2012 and AFG-2025 and checked when the agent runs it. Ranges, timing, and option-dependent commands are defined by GW Instek's programming manual: check it before you rely on an edge case. Last updated November 17, 2026.
Yes. The GW Instek AFG-2012 accepts SCPI commands over its remote interfaces. TestFlow's instrument library holds 67 SCPI commands for it: 9 queries that read values or state, and 58 settings and actions.
Install PyVISA and a VISA backend, find the instrument's address with ResourceManager().list_resources(), open it, then send commands with write() and read values with query(). The example on this page sends *IDN?, OUTPut ON and OUTPut?.
OUTPut? (read output state ch1). Reads channel 1 output state. The full list of queries is in the command reference on this page, grouped by subsystem.
Yes. TestFlow is an AI agent for electronics testing: you describe the test, and it builds the automation from this command library, runs it on the GW Instek AFG-2012 through the TestFlow desktop app, and writes the report from the measured results.
Describe the test. TestFlow builds the workflow, runs it on your instruments, and writes the report. See it on a bench like yours.