Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

How to plot a byte array with WaveFormGraph?

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

 

Message 1 of 3
(4,751 Views)

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++)

           intData[k] = (int) byteData[k];
 
Let me know if you have any other questions or if this solution isn't working for you, and I'd be happy to help you further!

 

Al B.
Staff Software Engineer - TestStand
CTA/CLD
0 Kudos
Message 2 of 3
(4,726 Views)

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

 

0 Kudos
Message 3 of 3
(4,712 Views)