10-22-2008 11:31 AM
Hi,
I am new to Measurement Studio and C#. I am trying to grab a waveform
off of my Agilent 54855a digital scope with a GPIB card, and plot it in my
C# program. I know that I have the waveform (it is a byte array), because
I can see it in my VisaTask.mxb window.
The problem (seems) to be when I try to plot the byte array using a
WaveFormGraph object, or a DigitalWaveFormGraph object. Neither
of those two Graphs are supposed to accept byte data. Is there some
other way to plot the waveform if it is a byte array?
Or maybe there is some larger problem I am missing.
Thanks,
Penny
10-23-2008 04:45 PM
Hi Penny,
The byte data type is actually similar to the char type in C and C++ in that the data is not treated as numbers for the purposes of mathematical operations. For this reason, the waveform chart doesn't know how to process the byte data. One thing to try would be to typecast the byte array into an integer or double array, and then pass that into your waveform graph. You can accomplish the typecasting with something like this:
byte[] byteData = new byte[size];
int [] intData= new int[size];
for (int k=0;k<integers.Length;k++)
10-24-2008 11:27 AM
Hi Al,
Thanks for the tip! Here is what eventually worked:
double[] doubleData = new double[(int)results.NumBytes];
for (int k = 0; k < (int)results.NumBytes; k++) doubleData[k] = (
double)results.BlockData[k]; AnalogWaveform<double> waveform = AnalogWaveform<double>.FromArray1D(doubleData);waveformGraph1.PlotWaveform(waveform);
Best regards,
Penny