Basic computer control PCSGU250 generator

Hello all. I want to run an experiment using just the function generator portion of the PCSGU250. (Readout is with a different instrument.) However, I have no C++ or Pascal programming experience, which makes using the manufacturer-supplied .DLL file tough. I am comfortable with Matlab, but the Matlab support e.g. here (mathworks.com/matlabcentral/ … -generator) is for a newer version of Matlab than what I have. I also tried to import the dll into python using << mydll = cdll.LoadLibrary(“PCSGU250.dll”) >> after importing ctypes. The error message is that the .dll is “not a valid Win32 application.”

So I guess the question is if 1) anyone out there has had similar issues with python, 2) if anyone has a workaround for Matlab (I have version 7.0 and it needs 7.8), or 3) if anyone has had success compiling a command-line control program for the PCSGU250. If so, I would sincerely appreciate a look at your code.

Thanks much!

OK, I have made some progress, largely through trial and error. It turns out that the variable types in the header are very important. It was not hard to get Start_PCSGU250 and StartGen working correctly, but the problem was with the variables passed to SetGen. In particular, the frequency and amplitude variables have to be type “float” rather than “double.” This was not clear from the documentation. Here is my working header file:

#ifdef __cplusplus
extern "C" { 
#endif 

#define FUNCTION __declspec(dllimport) 

FUNCTION void __stdcall Start_PCSGU250(void);
FUNCTION void __stdcall Stop_PCSGU250(void);
FUNCTION void __stdcall StartGen(void);
FUNCTION void __stdcall StopGen(void);
FUNCTION void __stdcall SetGen(int func, float freq, float ampl, float offset);
/* FUNCTION void __stdcall SetLibWave(double freq, double ampl, float offset, char file) */ 
#ifdef __cplusplus
}
#endif

The header file is simply called header.h. I can now load the library using loadlibrary('PCSGU250.dll','header') The matlab code then for starting the GUI is calllib('PCSGU250','Start_PCSGU250') And I can now set the function generator output using calllib('PCSGU250','SetGen',1,100,5,0) This sets a sine wave with frequency 100 Hz, peak-to-peak voltage 5 V, and zero offset.