11-04-2008 03:58 PM
Hi,
As a C# beginner, I am working on grabbing a waveform off of
my Agilent oscilloscope using C#.NET and Measurement Studio.
So far it is working great. Now I want to take the project one step
further, and grab the waveform only when the scope has been
triggered. (For now I am going to trigger the scope manually,
then eventually I will use an external trigger pulse.)
So far I have figured out how to grab a status byte off of the
scope, the LSB of which turns positive after the scope triggers.
I would like to use that status byte to tell my C# program when
to grab the waveform and do my calculations on it.
If anyone could give me a hint as to what the first step would
be, that would be great.
Thanks!
Solved! Go to Solution.
11-05-2008 02:29 PM
Penny,
I have just a few questions.
1. What's the model number of your oscope?
2. Are you using VISA or 488.2?
3. Which method are you using now to read the status byte?
Thanks,
11-05-2008 03:20 PM
Hi Ben,
The oscope is an Agilent 54855A, and I am using VISA
and Measurement Studio with a GPIB cable. I am currently
reading the status byte with the VisaTask.mxb code that
(miraculously) appeared when I built the project from a
NI-VISA Windows template.
Since my last message, I have drag-and-dropped an
LED indicator onto my Form.cs[design]. It seems like
there should be some way to hook it up to the LSB of
the status byte...? Then I could trigger my code on the
changing of that LED(?)
Thanks,
Penny
11-05-2008 04:41 PM
Hi again,
While I am at it, I am trying to create a "gauge" indicator on my Form1.cs,
and then "bind" it to a real number that I read in from the scope with
VisaTask.mxb, "lengthNumBytes"=4. So far I cannot get that gauge to
read '4'. I right-clicked on the "gauge", then went to Properties/DataBindings/Tag
and Properties/DataBindings/Value. I set them both equal to lengthNumBytes,
which I know equals 4.
Is there something that I am missing, with the obvious exception of a
C# intro lecture?
11-06-2008 02:42 PM
Penny,
I am currently looking into this, but I do have a few more questions.
1. Are you using the instrument driver for the 54855A? You can obtain this from NI.com/idnet and use it with Measurement Studio by running the Measurement Studio Instrument Driver .NET Wizard. Information on this wizard can be found here. I haven't looked into the contents of this instrument driver, but they usually make programming much easier.
2. When programming using VisaTask.mxb are you adding a Query and Parse step and then feeding it a command to return a status byte? If so, what command are you feeding it? If not, how are you reading this status byte.
Some other thoughts on what you are doing: You shouldn't need an LED to trigger your code. You can do it behind the scenes with the data from the status byte. There is a C# method for reading the status byte called ReadStatusByte. This returns a StatusByteFlags type which contains the contents of that byte. You can use that information to trigger your board.
For the data binding, you may be having problems with the data from the lenthNumBytes variable being protected or not available to the Form class.
11-06-2008 04:00 PM
Hi Ben,
Thanks for the reply. I did not know about that Wizard; I am going
to look into it.
In the meantime yes, I am adding a 'Query and Parse' step to
VisaTask.mxb, with the command '*STB?'. It returns the status
byte.
I would like to do the triggering behind the scenes with that ReadStatusByte
method, as you suggest. If I were to do that, would that mean that
I would just delete the Query and Parse step in VisaTask.mxb, or
would it mean that I should keep the Query and Parse step in place,
and somehow feed the resulting STB into the ReadStatusByte method.
Thanks again,
Penny
11-07-2008 02:14 PM
Penny,
I've modified the SimpleReadWrite example that ships with Measurement Studio to provide an example of how this could be done. Look at the code for MainForm.cs to see what I did. The new method is called TrigButton_Click. You will need to modify it before it will work with your instrument.
This example does several things on the Click of the TrigButton control
1. Reads the status byte using the ReadStatusByte method
2. Checks the status byte for a "0" value and conditionally does step 3.
3. Triggers a voltage read from my Instrument Simulator and displays it in the readTextBox TextBox control
These steps may be easier using the imported instrument driver from ni.com/idnet. I would like you to still check into using that.
11-07-2008 04:15 PM
Hi Ben,
THANKS! That is a great working example to look at.
I'm going to keep working on this for a while and see
how far I can get.
Meanwhile I am waiting for the .NET Wizard to be
emailed to me, so I will try that too.
I appreciate all of the help. Maybe now I can get
some traction with this stuff.
Thanks,
Penny