in data 11-16-2006 09:38 AM
I am using Measurement Studio within C# VS .NET 2003 to display data in wavegraph control.I want to get an acquisition data from Oscilloscope such as when I click the “OnClickPloty1_button” in the my Window-Form(GUI), I can view the data in wave form. Infact, for example, if the Oscilloscope sent "500000 pixel", the acquisition data is made by means the instruction “buffer= mbSession.ReadByteArray” in the code, that returns only “200027” pixel, but don’t whole pixel-set of data sent. This is my question: Is this the right way to get it?
I have traied some examples:
C:\Instruments\MeasurementStudio70\DotNET\Examples\Visa\SimpleAsynchronousReadWrite or
C:\Instruments\MeasurementStudio70\DotNET\Examples\GIPIB\SimpleAsynchronousReadWrite
The code modified is :
private const int sizePoints = 550000;
private byte[]buffer = new byte[sizePoints];
{
try
{ ..
buffer = mbSession.ReadByteArray(sizePoints);
buffer.CopyTo(data,0);
waveformPlot1.PlotY(data);
}
catch(Exception exp)
{
MessageBox.Show(exp.Message);
}
}
Thank you very much!
in data 11-21-2006 11:20 AM
Greetings INCARD,
In response to your question, from the Measurement Studio side, it looks fine. All that you are trying to do is read in x number of points (x being sizeOfPoints) from a GPIB bus (I'm guessing using VISA) and then take that array and plot it to a graph?
From my understanding, you have it set up in such a way that when you click on a button, the program will signal that callback function. It looks like you are trying to set it up so that a user clicks a button and a certain number of bytes are read in to an array of bytes, to be displayed on a graph. It looks fine; the only hesitation I would have is the process of converting the byte array to a double array. Currently, you are using a CopyTo function, which I'm not sure how that translates the bytes to double (since a double is represented by 4 bytes). There would be the question of how exactly that function (which is not ours) copies byte values to double values, whether through 1) Take the first byte and align it with the first index of the double (and thus truly representing a double with 1 byte), or 2) Copy byte for byte such that 4 elements of the byte array would correspond to 1 element of the double array. Of course, all of this is really just a matter of the set up of your system (a question for yourself is what kind of data are you expecting on the GPIB bus), but like I said it would just be my only consideration of problem areas.
Give it a try and best of luck!