Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

IVI range checking and coercion

Solved!
Go to solution

Hi,

 

I'm working on an IviScope driver for a digitizer module.

I have a question that keeps me busy.

 

Take for instance the IVISCOPE_ATTR_VERTICAL_RANGE attribute.

My instrument has 8 fixed vertical ranges. If the application selects a vertical range that isn't exactly one of these fixed ranges, the driver takes the rangetable and coerces the value to the next fitting range.

But if the application specifies a vertical range that is beyond the instrument's capabilities (say 50Vpp, where the instrument only does 20Vpp), rangechecking kicks in, saying "Invalid value for parameter or property". Even when in the InitWithOptions() option string I specify "RangeCheck=0". With disabled RangeChecking, I expected the driver to do no range checking, but only coercing. Am I right? And would the value be coerced down to the instrument's maximum vertical range?

 

Regards,

gggggl

 

0 Kudos
Message 1 of 9
(4,677 Views)

Hello,

 

Thank you for your posting in this forum. We will work on your issue as soon as possible but I think that you posted your issue two times under different numbers. If you are agree I will close this forum and will reply on the other one which you can find in the link below.

http://forums.ni.com/t5/Instrument-Control-GPIB-Serial/IVI-range-checking-and-coercion/m-p/1880841

 

Thanks and best regards,

 

Hossein

0 Kudos
Message 2 of 9
(4,664 Views)

Thank you for your support so far.

I was not aware I double-posted this question, but if it's the same, please close one of the two.

Thanks,

gggggl.

0 Kudos
Message 3 of 9
(4,657 Views)

Hello,

 

I found some documentations that could be useful. Take a look at them and don't hesitate to give me a feedback if I can do anything els for you.

 

Regards,

 

 

Download All
0 Kudos
Message 4 of 9
(4,612 Views)

Hello,

 

It depends on the implementation of the specific driver. You can check the source code(normally in this folder: C:\Program Files\IVI Foundation\IVI\Drivers\driver_name).

 

Assume the Range Table coerces the input parameters is as follows:

The first line of the table content defines how to coerce the value, in this case, it means coercing values between 100e-12 and 10 to Zero. If the value you input cannot find a line to match with in this range table, a C-Runtime error will occur and no value will be sent to the instrument. If how to coerce values out of range is defined in this Range Table, the value sent out will be coerced as defined.

However, the driver may use another way to implement coercing: callback method. It is more flexible to define complex conditions. If the driver uses this method instead of Range Table, you also need to investigate the code to know the actual actions the driver will take.

Hope this can help you. If you can't find the Range Table or callback method attached to this attribute, please post the source code and we can help analyze it for you or you can send it to instrument.drivers@ni.com.


Message 5 of 9
(4,587 Views)

Thank you jjp377. Although I suspected it would work like that, reading your post helps me to get a better understanding.

 

Yes, I can find the rangetables and callbacks in the driver, and understand that part.

 

What I don't understand: It is possible to disable RangeChecking, right? I read about it in the IVI spec. But I'm not sure how to do that.

I called the InitWithOptions function with "RangeCheck=0" in the optionsstring, and in Measurement & Automation Explorer, I un-checked the "Range Check" option for this driver session, and still I get an error if I set the attribute to a value outside the valid range.

 

Did I do something wrong with disabling the range checking? What behavior can I expect when I set an invalid value with RangeChecking disabled?

0 Kudos
Message 6 of 9
(4,578 Views)

Normally, if you call the InitWithOptions function with "RangeCheck=0" in the option string and the type of range table is IVI_VAL_RANGED, the value you set will be set to the instrument with no change. If the kind of range table is IVI_VAL_COERCED, the value will be coerced even if you set RangeCheck to zero. In this situation, you should make sure the range table define the coercing rules clearly. Otherwise, a c-runtime error will appear when you run the code. If the coercing range table is also defined correctly, the value will be set to the instrument with no change, of course this will cause a instrument specific error.

 

If the attribute you want to set is related to a hidden attribute, you should check the corresponding range checking methods too. It is more complex to describe. you could post the problem clearly for further analyzing.

 

0 Kudos
Message 7 of 9
(4,564 Views)
Solution
Accepted by topic author gggggl

Sorry. You could ignore the last reply. I update it as follows:

 

Normally, if you call the InitWithOptions function with "RangeCheck=0" in the option string and the type of range table is IVI_VAL_RANGED, the value you set will be set to the instrument with no change and a instrument specific error will occur. If the type of range table is IVI_VAL_COERCED, the value will be coerced even if you set RangeCheck to zero. In this situation, you should make sure the range table define the coercing rules clearly. Otherwise, a c-runtime error will appear when you run the code.

 

If the attribute you want to set is related to a hidden attribute, you should check the corresponding range checking methods too. It is more complex to describe. you could post the problem clearly for further analyzing.

Message 8 of 9
(4,561 Views)

Thank you. That makes it clear!

0 Kudos
Message 9 of 9
(4,554 Views)