National Instruments 374318A-01 Network Card User Manual


 
Chapter 4 Getting Started with Measurement Studio
Measurement Studio for MCC User Manual 4-24 ni.com
' convert the string to a double
Dim D As Double = Convert.ToDouble(S.Replace(NlChar, NullChar))
'Plot the point
WaveformGraph1.PlotYAppend(D, 1)
Next
System.Runtime.InteropServices.Marshal.FreeHGlobal(Buffer)
[C#]
stringwrtString = "val?";
int rdBufSize = 100;
char nlChar = '\n';
char nullChar = '\0';
addressprimaryAddress = new Address(2);
int boardNum = 0;
// open a gpib device
Device device = new Device(boardNum, primaryAddress);
// allocate a buffer to hold the data
IntPtr buffer =
System.Runtime.InteropServices.Marshal.AllocHGlobal(rdBufSize);
// read and plot 100 samples
for (int i=0; i<100; i++)
{
// write the string (val?) to the Fluke45
device.Write(wrtString);
// read the response from the Fluke45
string s = device.ReadString(rdBufSize);
// replace the newline character with a null and
// convert the string to a double
double d = Convert.ToDouble(s.Replace(nlChar, nullChar));
// plot the point
waveformGraph1.PlotYAppend(d, 1);
}
System.Runtime.InteropServices.Marshal.FreeHGlobal(buffer);
3. Select File»Save Form1.cs to save your application.
4. Select Debug»Start Without Debugging to run the application.
5. After your program builds and runs, click Run. Notice each time you
click the Run button, the graph shows the acquired value.