PCSGU250 with MS Visual C++

Hi,

I would like to write a program using MS Visual C++ (under MS Visual Studio 2010 Express) and the PCSGU250.dll to control my PCSGU250 scope and function generator.

I’ve had a look at the previous post http://forum.velleman.eu/viewtopic.php?f=10&t=4657&hilit=pcsgu250+c%23+.net and also at the C# demo code.

I can see how to create a header file: I should be able to pretty much cut this straight out of the C# demo code.

But what about a .lib file? Do I need one and is there one already available? If I don’t actually need one how do I persuade the linker to link the functions from the DLL? Alternatively is there a freely available DLL-to-LIB converter for MSVC++ (I’m assuming I can’t use the Borland tool due to differences in the .lib file format)?

Many thanks!

Please see this thread for a solution:
viewtopic.php?f=10&t=5443

Thank you.

I created the following as a header file. Using this seems to be giving me good results (Microsoft Visual C++ 2010 Express under XP SP3).

#using <mscorlib.dll>
using namespace System::Runtime::InteropServices; 
// for DllImportAttribute

namespace PCSGU250DLL
{
	[DllImport("PCSGU250.dll", CharSet=CharSet::Ansi)] extern bool Start_PCSGU250();  
	[DllImport("PCSGU250.dll", CharSet=CharSet::Ansi)] extern void Stop_PCSGU250();  
	[DllImport("PCSGU250.dll", CharSet=CharSet::Ansi)] extern void Show_PCSGU250(int Visible);  

	[DllImport("PCSGU250.dll", CharSet=CharSet::Ansi)] extern void RunOn(int Run_on);
	[DllImport("PCSGU250.dll", CharSet=CharSet::Ansi)] extern void SingleOn(int Single_on);
	[DllImport("PCSGU250.dll", CharSet=CharSet::Ansi)] extern void Voltage1(int Volts);
	[DllImport("PCSGU250.dll", CharSet=CharSet::Ansi)] extern void Voltage2(int Volts);
	[DllImport("PCSGU250.dll", CharSet=CharSet::Ansi)] extern void Time(int Rate);
	[DllImport("PCSGU250.dll", CharSet=CharSet::Ansi)] extern void Coupling1(int AC_DC_GND);   
	[DllImport("PCSGU250.dll", CharSet=CharSet::Ansi)] extern void Coupling2(int AC_DC_GND);  
	[DllImport("PCSGU250.dll", CharSet=CharSet::Ansi)] extern void TrgLevel(int Trg_Level);   
	[DllImport("PCSGU250.dll", CharSet=CharSet::Ansi)] extern void YPosition1(int y_pos);
	[DllImport("PCSGU250.dll", CharSet=CharSet::Ansi)] extern void YPosition2(int y_pos);
	[DllImport("PCSGU250.dll", CharSet=CharSet::Ansi)] extern void TrgOn(int trg_on);
	[DllImport("PCSGU250.dll", CharSet=CharSet::Ansi)] extern void TrgEdge(int Positive_Negative);   
	[DllImport("PCSGU250.dll", CharSet=CharSet::Ansi)] extern void TrgSource(int Trg_Source);   
	[DllImport("PCSGU250.dll", CharSet=CharSet::Ansi)] extern bool GetSettings(int* SettingsArray);  
	[DllImport("PCSGU250.dll", CharSet=CharSet::Ansi)] extern void ReadCh1(int* Buffer);
	[DllImport("PCSGU250.dll", CharSet=CharSet::Ansi)] extern void ReadCh2(int* Buffer);
	[DllImport("PCSGU250.dll", CharSet=CharSet::Ansi)] extern bool DataReady();

	[DllImport("PCSGU250.dll", CharSet=CharSet::Ansi)] extern void StartGen();  
	[DllImport("PCSGU250.dll", CharSet=CharSet::Ansi)] extern void StopGen();  
	[DllImport("PCSGU250.dll", CharSet=CharSet::Ansi)] extern void SetGen(int func, float freq, float ampl, float offset);  
	[DllImport("PCSGU250.dll", CharSet=CharSet::Ansi)] extern void SetLibWave(float freq, float ampl, float offset, char* filename);
	[DllImport("PCSGU250.dll", CharSet=CharSet::Ansi)] extern void SetSweep(float freq1, float freq2, float ampl, float offset, float time);  
}

Now I have some more questions please:

I want to measure an impedance (DUT), which I will drive from the function generator output via a known source impedance with the generator output connected directly back to the channel 2 input and the voltage across the DUT being measured on channel 1. I need to calculate the voltage difference between the two channels.

What is the relative timing of the sampled data for channels 1 and 2? Are both channels sampled simultaneously?

Is it possible to access the built-in Math functions (under the Math menu?) If so, do these functions take account of any difference in the sample timing?

Is it possible to read back any of the calculated Waveform Parameters?

Is there a way to check if the PCGSU250 is connected to the PC?

Is there a way to set the Probe x1 x10 options?

Is there a way to switch the oscilloscope channels on and off?

Many thanks.

I’m sorry, the answer to most of your questions is ‘no’ due to the limitations of the PCSGU250.dll.

[quote]Are both channels sampled simultaneously?[/quote]Yes.

[quote]Is it possible to access the built-in Math functions (under the Math menu?)[/quote] Sorry, there is no access to the math functions via the DLL.

[quote]Is it possible to read back any of the calculated Waveform Parameters?[/quote]This is also not possible via the DLL.

[quote]Is there a way to check if the PCGSU250 is connected to the PC?[/quote]No. If the hardware is not connected, the software goes to demo mode and is still “seen” by the DLL.

[quote]Is there a way to set the Probe x1 x10 options?[/quote]No. There is no effect to the raw data read from the oscilloscope hardware if the probe setting is x1 or x10. This setting just specifies how to treat the data in the software.

[quote]Is there a way to switch the oscilloscope channels on and off?[/quote] This is also not possible via the DLL.

OK, not to worry. Having the two channels sampled simultaneously will at least make combining them straightforward.

Thanks for your help.