I am using the RedScope 25MHz, which is obviously a PicoScope 2205 internally.
(Hardwareversion: 16 driver version: 2, 0, 5, 7)
Annoying but not critical:
- no code examples are installed, neither by installing picoscope 6 nor picoscope 5.20
- After some searching I manually extracted code sample files from the .cab files of ps 5.20. on the CD.
- There are NO Code samples for C#, neither on the CD nor on the website, at least I could find them. Why is this language ignored ?
Critical:
The Signal Generator is NOT working when called in C#. I wrote the necessary calls to the ps2000.dll like this:
The openunit() obviously works (device clicks and flashes), but SetSigGen() ALWAYS returns 0, which means "no errors", even if I send incorrect handles or data values (too high frequencies etc.).
Could someone please provide me with a short example how to use the built in signal generator within C# correctly ?
Hint: I noticed that the signal generator also does not work when started within picoscope 5.20 software (there its interface is rudimentary anyway...), but works fine from picoscope 6.0.
It would be great if someone could help me with my signal-generator problem, is anyone using this feature within a .NET application sucessfully ?
I guess I am making a mistake in the way I reference the ps2000_set_sig_gen_built_in function, but I can't find the error.
Please tell me if I should quote the whole code here so the problem can be reproduced directly (although the above mentioned lines are all you need anyway... )
Hi,
I don't have a PicoScope with a signal generator, but the way you call ps2000_set_sig_gen_built_in
looks suspicious:
A long in C# is always 64 bits wide, but the C-library might expect the long arguments only to be 32Bits wide!
You could try to cast your long (ulong) arguments to System.Int32 (or System.UInt32).
Dear Wayoda, you are absolutely right, the problem was the different "long" meaning. Thanks!
A comparison of typical types (see e.g. here: MSDN Article) shows that "long" is the only one who makes trouble. Tricky.
I had actually already managed to solve this problem on my own as the project is VERY urgent (and i am very late...).
The pico "programmers guide" only states "long" but not the actual size. This is a bit misleading for someone like me who only writes code occasionally and is not aware of the the internal bitlength.
The relevant hint for me was the post by AnthonyCSheehy in this forum (here) who obviously also stumbled across this problem.
By the way: The function call list for VB.NET in his post here is possibly also wrong in several calls. I noticed some "long" definitions there too...
One more thing: The programmer guide states that "0" will be returned by the ps2000_set_sig_gen_built_in function if everything was OK. After I finally managed to call the function correctly I found that actually "1" is returned for no errors. On the contrary, "0" means that problems have occured (e.g. too high voltages set). Am I doing something wrong ? This discrepancy was also very misleading during the debugging of the above mentioned problem!
@PICOTECH: This "long" problem is obviously a typical problem someone will face when he tries to adopt the picoscopes for .NET. Please update your documents accordingly. So hopefully other people could be spared time consuming debugging and forum waiting. (Or create some decent examples for all languages alltogether..., e.g. the Delphi, LV and VB examples don't even mention the usefull signal generator feature from what I have seen.)
I am using a PicoScope4226 with PicoScope6 on a Sony VAIO Model PCG-3J1M with a Windows 7 Home OS and it works perfectly.
I have also tried to use the C#-example from the SDK Version r10_1_0_8 using Visual Studio 2010 Professional. The code compiles fine and runs as it should if one rembers to set the processor type to x86. Unfortunately the example does not deal with the signal generator, so I have, like picouser99, tried to add code to import the signal generator functions into Imports class in the ps4000Imports.cs file:
Unfortunately the function return value is 46 (0x2E) PICO_SIGGEN_PARAMETER_ERROR, regardless of the values of amplitude and frequency. At first I had also made the mistake of using long and ulong, but correcting that after reading through the forum topic did not help.
Does anyone have a suggestion to solve the problem?
Other functions like BlockDataHandler runs fine reading the input and delivering sensible data.
The signal generator code in ps4000con.c transferred to C++ works after some type errors in the file have been corrected.
Many thanks Chris for the tip. I had made a mistake of using an erronous factor when converting from V to uV.
10^6 should be 1e6 not 10e6. Your fast answer saved my weekend. Thanks!