Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

How do I trigger on a status byte?

Solved!
Go to solution

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!

Robot Happy

 

 

 

 

 

 

0 Kudos
Message 1 of 8
(5,617 Views)

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,

Ben

National Instruments
Certified LabVIEW Associate Developer
Certified TestStand Developer
0 Kudos
Message 2 of 8
(5,601 Views)

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

 

 

 

 

 

0 Kudos
Message 3 of 8
(5,596 Views)

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?

 

Robot Indifferent

 

 

0 Kudos
Message 4 of 8
(5,591 Views)

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.

Ben

National Instruments
Certified LabVIEW Associate Developer
Certified TestStand Developer
0 Kudos
Message 5 of 8
(5,569 Views)

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

 

0 Kudos
Message 6 of 8
(5,562 Views)
Solution
Accepted by topic author Penny

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.

 

 

 

 

Ben

National Instruments
Certified LabVIEW Associate Developer
Certified TestStand Developer
0 Kudos
Message 7 of 8
(5,547 Views)

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

 

0 Kudos
Message 8 of 8
(5,543 Views)