2

I have this function to send a command via GPIB connection to a Function generator (Stanford Research Systems, Synthesized Function Generator, model DS345) to change it's amplitude, frequency, and offset. However, when I uncomment the line:

fprintf(obj1, Offs_str)

(which sends the offset value to the function generator), the instrument outputs a 'syntax error'. This is the syntax specified in the manual. Also, if I change the amplitude command to anything other than 0.0 (i.e. change the command to fprintf(obj1, 'AMPL1.1VP')), the same syntax error is produced.

It's a long shot, but does anyone have experience using instrument control with a DS345 function generator? Or perhaps there is some issue with the instrumental control syntax?

function [] = FG_on(Offs)

    %Convert Offset input to string 
    Offs_str = strcat('OFFS',num2str(Offs),'VP');

    %create GPIB handle
    obj1 =  instrfind('Type', 'gpib', 'BoardIndex', 1, 'PrimaryAddress',...
    19, 'Tag', '');

    %Open connection
    fopen(obj1);    

    %Sampling Frequency
    fprintf(obj1, 'FSMP1000'); 
    %Amplitude
    fprintf(obj1, 'AMPL0.0VP');
    %Offset
    %fprintf(obj1, Offs_str);
    %Modulation Type
    fprintf(obj1, 'MTYP5');
    %Function Type
    fprintf(obj1, 'FUNC5');
 end
  • Haven't used this exact kit, but is it safe to assume that the FSMP, MTYP5 and FUNC5 commands always work? If so, I think you can eliminate incorrect line terminations etc. Does the order of commands make any difference? – J Richard Snape Feb 23 '15 at 15:47

1 Answers1

0

I guess there is no need for the 'VP' at the end of the offset definition. An offset is just a voltage, specifying Vpp or Vrms doesn't really make sense.

Try:

Offs_str = ['OFFS' num2str(Offs)];

For the amplitude, in the manual it seems that there is a space between 'AMPL' and the value. So maybe you should try 'AMPL 1.0VP'.

Ratbert
  • 5,463
  • 2
  • 18
  • 37