VB:
'****************************************************************************
' Copyright © 2010 Agilent Technologies Inc. All rights
' reserved.
'
' You have a royalty-free right to use, modify, reproduce and distribute
' the Sample Application Files (and/or any modified version) in any way
' you find useful, provided that you agree that Agilent has no
' warranty, obligations or liability for any Sample Application Files.
'
' Agilent Technologies provides programming examples for illustration only,
' This sample program assumes that you are familiar with the programming
' language being demonstrated and the tools used to create and debug
' procedures. Agilent support engineers can help explain the
' functionality of Agilent software components and associated
' commands, but they will not modify these samples to provide added
' functionality or construct procedures to meet your specific needs.
'****************************************************************************
'****************************************************************************
'This sample program is intended to use with Microsoft Visual studio 6.0
'and Agilent Visa Object library.
'
'Sample program execution requires VISA library installation as prerequisite.
'
'Add below libraries in project reference in Project\reference menu prior to execution of sample 'program:
'VISA COM 3.0 Type Library, Location:\VisaCom\GlobMgr.dll
'VISA COM 488.2 Formatted I/O 1.0, Location:\VisaCom\BasFrmIO.dll
'VISA COM Resource Manager 1.0, Location:\bin\AgtRM.dll
' ****************************************************************************
' """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
'Signal SUM Example is a sample program that demonstrates the capablity of adding a modulation
'source, in this case channel 2, to a signal on channel 1 and outputting the sum on channel 1.
'
'Algorithm:
' 1. Configure channel 1 and channel 2 signals.
' 2. Enable channels output.
' 3. Set the type of modulation on channel 1 to SUM.
' 4. Enable modulation output.
' 5. Set the source for channel 1 modulation to channel 2.
' 6. Set the amplitude of the sum.
' 7. For verification, route the channel 1 signal to an oscilloscope to see the result.
'
'Channel 1 Parameters:
' Wave Shape: Sine
' Frequency: 1000 Hz
' Amplitude: 2 Volt Peak to Peak
' Offset: 0 Volt
' Output Impedence: 50 Ohm
'
'Channel 2 Parameters:
' Wave Shape: Square
' Frequency: 1000 Hz
' Amplitude: 2 Volt Peak to Peak
' Offset: 0 Volt
' Output Impedence: 50 Ohm
'
'Modulation:
' Modulation type: Sum Modulation.
' Sum Amplitude: 1%
'
' Sum State: ON
'
' Channel1 Output: Enabled
' Channel2 Output: Enabled
'
'""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
Private Sub Command1_Click()
Dim io_mgr As VisaComLib.ResourceManager
Dim mfIo As VisaComLib.FormattedIO488
Set io_mgr = New AgilentRMLib.SRMCls
Set mfIo = New FormattedIO488
Set mfIo.IO = io_mgr.Open(Text1.Text, NO_LOCK, 2000, "")
On Error GoTo MyError
' This program sets up a waveform by selecting the waveshape
' and adjusting the frequency, amplitude, and offset.
With mfIo
' Clear and reset instrument
.WriteString "*CLS"
.WriteString "*RST"
Sleep 1000
' Send commands to set the desired configuration on channel 1
.WriteString "SOURCE1:FUNCTION SIN"
.WriteString "SOURCE1:FREQUENCY 1000"
.WriteString "SOURCE1:VOLT:UNIT VPP"
.WriteString "SOURCE1:VOLT 2"
.WriteString "SOURCE1:VOLT:OFFSET 0"
.WriteString "OUTPUT1:LOAD 50"
' Send commands to set the desired configuration on channel 2
.WriteString "SOURCE2:FUNCTION SQU"
.WriteString "SOURCE2:FREQUENCY 1000"
.WriteString "SOURCE2:VOLT:UNIT VPP"
.WriteString "SOURCE2:VOLT 2"
.WriteString "SOURCE2:VOLT:OFFSET 0"
.WriteString "OUTPUT2:LOAD 50"
' Enable both channel outputs
.WriteString "OUTPUT1 ON"
.WriteString "OUTPUT2 ON"
Sleep 1000
' Enable the modulation on channel 1
.WriteString "SOURCE1:SUM:STATE ON"
' Set modulation source for channel 1 to channel 2
.WriteString "SOURCE1:SUM:SOURCE CH2"
' Set amplitude of modulation to 1%
.WriteString "SOURCE1:SUM:AMPLITUDE 1"
End With
Text2.Text = "Output set as SUM signal on Channel 1"
Exit Sub
MyError:
Text2 = Err.Description
Resume Next
End Sub
Private Sub Form_Load()
Text2.Text = ""
End Sub
'****************************************************************************
' Copyright © 2010 Agilent Technologies Inc. All rights
' reserved.
'
' You have a royalty-free right to use, modify, reproduce and distribute
' the Sample Application Files (and/or any modified version) in any way
' you find useful, provided that you agree that Agilent has no
' warranty, obligations or liability for any Sample Application Files.
'
' Agilent Technologies provides programming examples for illustration only,
' This sample program assumes that you are familiar with the programming
' language being demonstrated and the tools used to create and debug
' procedures. Agilent support engineers can help explain the
' functionality of Agilent software components and associated
' commands, but they will not modify these samples to provide added
' functionality or construct procedures to meet your specific needs.
'****************************************************************************
'****************************************************************************
'This sample program is intended to use with Microsoft Visual studio 6.0
'and Agilent Visa Object library.
'
'Sample program execution requires VISA library installation as prerequisite.
'
'Add below libraries in project reference in Project\reference menu prior to execution of sample 'program:
'VISA COM 3.0 Type Library, Location:
'VISA COM 488.2 Formatted I/O 1.0, Location:
'VISA COM Resource Manager 1.0, Location:
' ****************************************************************************
' """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
'Signal SUM Example is a sample program that demonstrates the capablity of adding a modulation
'source, in this case channel 2, to a signal on channel 1 and outputting the sum on channel 1.
'
'Algorithm:
' 1. Configure channel 1 and channel 2 signals.
' 2. Enable channels output.
' 3. Set the type of modulation on channel 1 to SUM.
' 4. Enable modulation output.
' 5. Set the source for channel 1 modulation to channel 2.
' 6. Set the amplitude of the sum.
' 7. For verification, route the channel 1 signal to an oscilloscope to see the result.
'
'Channel 1 Parameters:
' Wave Shape: Sine
' Frequency: 1000 Hz
' Amplitude: 2 Volt Peak to Peak
' Offset: 0 Volt
' Output Impedence: 50 Ohm
'
'Channel 2 Parameters:
' Wave Shape: Square
' Frequency: 1000 Hz
' Amplitude: 2 Volt Peak to Peak
' Offset: 0 Volt
' Output Impedence: 50 Ohm
'
'Modulation:
' Modulation type: Sum Modulation.
' Sum Amplitude: 1%
'
' Sum State: ON
'
' Channel1 Output: Enabled
' Channel2 Output: Enabled
'
'""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
Private Sub Command1_Click()
Dim io_mgr As VisaComLib.ResourceManager
Dim mfIo As VisaComLib.FormattedIO488
Set io_mgr = New AgilentRMLib.SRMCls
Set mfIo = New FormattedIO488
Set mfIo.IO = io_mgr.Open(Text1.Text, NO_LOCK, 2000, "")
On Error GoTo MyError
' This program sets up a waveform by selecting the waveshape
' and adjusting the frequency, amplitude, and offset.
With mfIo
' Clear and reset instrument
.WriteString "*CLS"
.WriteString "*RST"
Sleep 1000
' Send commands to set the desired configuration on channel 1
.WriteString "SOURCE1:FUNCTION SIN"
.WriteString "SOURCE1:FREQUENCY 1000"
.WriteString "SOURCE1:VOLT:UNIT VPP"
.WriteString "SOURCE1:VOLT 2"
.WriteString "SOURCE1:VOLT:OFFSET 0"
.WriteString "OUTPUT1:LOAD 50"
' Send commands to set the desired configuration on channel 2
.WriteString "SOURCE2:FUNCTION SQU"
.WriteString "SOURCE2:FREQUENCY 1000"
.WriteString "SOURCE2:VOLT:UNIT VPP"
.WriteString "SOURCE2:VOLT 2"
.WriteString "SOURCE2:VOLT:OFFSET 0"
.WriteString "OUTPUT2:LOAD 50"
' Enable both channel outputs
.WriteString "OUTPUT1 ON"
.WriteString "OUTPUT2 ON"
Sleep 1000
' Enable the modulation on channel 1
.WriteString "SOURCE1:SUM:STATE ON"
' Set modulation source for channel 1 to channel 2
.WriteString "SOURCE1:SUM:SOURCE CH2"
' Set amplitude of modulation to 1%
.WriteString "SOURCE1:SUM:AMPLITUDE 1"
End With
Text2.Text = "Output set as SUM signal on Channel 1"
Exit Sub
MyError:
Text2 = Err.Description
Resume Next
End Sub
Private Sub Form_Load()
Text2.Text = ""
End Sub
/****************************************************************************
' Copyright © 2010 Agilent Technologies Inc. All rights
' reserved.
'
' You have a royalty-free right to use, modify, reproduce and distribute
' the Sample Application Files (and/or any modified version) in any way
' you find useful, provided that you agree that Agilent has no
' warranty, obligations or liability for any Sample Application Files.
'
' Agilent Technologies provides programming examples for illustration only,
' This sample program assumes that you are familiar with the programming
' language being demonstrated and the tools used to create and debug
' procedures. Agilent support engineers can help explain the
' functionality of Agilent software components and associated
' commands, but they will not modify these samples to provide added
' functionality or construct procedures to meet your specific needs.
****************************************************************************/
/****************************************************************************
'This sample program is intended to use with Microsoft Visual C++ 2005
'and Agilent Visa Object library.
'
'Sample program execution requires VISA library installation as prerequisite.
'
'Header file
'at VISA install location. User must point to the file, if not detected
'automatically. Add above header file containing directory as additional
'dependencies for C/C++ project compilation.
'
'Add visa32.lib library reference as additional dependencies for linker
'in this project. This library can be located at
'
****************************************************************************/
/* Signal SUM Example is a sample program that demonstrates the capablity of adding a modulation
* source, in this case channel 2, to a signal on channel 1 and outputting the sum on channel 1.
Algorithm:
1. Configure channel 1 and channel 2 signals.
2. Enable channels output.
3. Set the type of modulation on channel 1 to SUM.
4. Enable modulation output.
5. Set the source for channel 1 modulation to channel 2.
6. Set the amplitude of the sum.
7. For verification, route the channel 1 signal to an oscilloscope to see the result.
Channel 1 Parameters:
Wave Shape: Sine
Frequency: 1000 Hz
Amplitude: 2 Volt Peak to Peak
Offset: 0 Volt
Output Impedence: 50 Ohm
Channel 2 Parameters:
Wave Shape: Square
Frequency: 1000 Hz
Amplitude: 2 Volt Peak to Peak
Offset: 0 Volt
Output Impedence: 50 Ohm
Modulation:
Modulation type: Sum Modulation.
Sum Amplitude: 1%
Sum State: ON
Channel1 Output: Enabled
Channel2 Output: Enabled
*/
#include
#include
#include
void main()
{
ViSession oRm, oMIO;
char strResult[256] = {0};
char noErrString[256] = {"+0,\"No error\"\n"};
char buf[256];
//Mention Visa connection string here.
char instAdd[] = "TCPIP0::146.223.123.106::inst0::INSTR";
//Open a resource manager and create a visa session for communication
viOpenDefaultRM(&oRm);
viOpen(oRm,instAdd,VI_NULL,VI_NULL,&oMIO);
//Query Idendity string and report.
viPrintf(oMIO,"*IDN?\n");
viScanf(oMIO,"%t",&buf);
printf("Instrument Identity String: %s \n", buf);
// Clear and reset instrument
viPrintf(oMIO,"*CLS\n");
viPrintf(oMIO,"*RST\n");
//Send commands to set the desired configuration on channel 1
viPrintf(oMIO,"SOURCE1:FUNCTION SIN\n");
viPrintf(oMIO,"SOURCE1:FREQUENCY 1000\n");
viPrintf(oMIO,"SOURCE1:VOLT:UNIT VPP\n");
viPrintf(oMIO,"SOURCE1:VOLT 2\n");
viPrintf(oMIO,"SOURCE1:VOLT:OFFSET 0\n");
viPrintf(oMIO,"OUTPUT1:LOAD 50\n");
//Send commands to set the desired configuration on channel 2
viPrintf(oMIO,"SOURCE2:FUNCTION SQU\n");
viPrintf(oMIO,"SOURCE2:FREQUENCY 1000\n");
viPrintf(oMIO,"SOURCE2:VOLT:UNIT VPP\n");
viPrintf(oMIO,"SOURCE2:VOLT 2\n");
viPrintf(oMIO,"SOURCE2:VOLT:OFFSET 0\n");
viPrintf(oMIO,"OUTPUT2:LOAD 50\n");
// Enable both channel outputs
viPrintf(oMIO,"OUTPUT1 ON\n");
viPrintf(oMIO,"OUTPUT2 ON\n");
// Enable the modulation on channel 1
viPrintf(oMIO,"SOURCE1:SUM:STATE ON\n");
// Set modulation source for channel 1 to channel 2
viPrintf(oMIO,"SOURCE1:SUM:SOURCE CH2\n");
// Set amplitude of modulation to 1%
viPrintf(oMIO,"SOURCE1:SUM:AMPLITUDE 1\n");
// Read Error
viQueryf(oMIO,"SYST:ERR?\n","%t",&strResult);
if(!(strcmp(strResult,noErrString)))
{
printf("Sum Signal generated without any error\n");
}
else
{
printf("Error reported: %s",strResult);
}
//Exit
printf("\nPress [Enter] to exit");
getchar();
viClose(oRm);
viClose(oMIO);
}