Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

Adding ConfigureStandardWaveform to an Instrument Specific Driver

I have downloaded an instrument specific IVI driver for the Tektronix AWG520. Since the instrument supports standard waveforms, I am adding the functionality to the driver by adding the function tkawg5x0_ConfigureStandardWaveform. I have run into a problem when trying to implement the Duty Cycle attribute. When I use LabWindows/CVI to add the Class attributes for the Standard waveform group, it automatically adds the Duty Cycle High attribute. This is fine with me. My question is when should this attribute get set to the proper value? There are no functions in any of the IFI-FGEN extension classes that I could find that take in a Duty Cycle High parameter from the user. It seems very silly
that I should have to write an instrument specific function that is not supported in an IVI extension class simply to allow the user to set the duty cycle to a particular value. Any help on this matter is greatly appreciated!
Thanks!
0 Kudos
Message 1 of 4
(3,614 Views)
Hi,

Attribute IVIFGEN_ATTR_FUNC_DUTY_CYCLE_HIGH does not have a high level function defined in IviFgen spec. Specification for Fgen you can find on htt://www.ivifounsation.org . You can create your specific high-level function for this attribute.

If you want set/get this attribute in class driver you can use:
IviFgen_SetAttributeViReal64(vi, "CHANNEL1", IVIFGEN_ATTR_FUNC_DUTY_CYCLE_HIGH, 10.0);

or

IviFgen_GetAttributeViReal64(vi, "CHANNEL1", IVIFGEN_ATTR_FUNC_DUTY_CYCLE_HIGH, &duty_cycle);

Your driver has high-level functions tkawg5x0_SetAttributeViReal64,
tkawg5x0_GetAttributeViReal64, etc.

It's not important that every attribute, must have high-level function.

Zdenek

comments:
a) I very quickly look to your source and whe
n you add an extension group, you should be add this information to TKAWG5X0_ATTR_GROUP_CAPABILITIES attribute too. So you should be add ",IviFgenStdFunc" to default value of this attribute.

b) Default callback is called automatically when you don't implement check callback. So you don't need following callbacks: tkawg5x0AttrFuncAmplitude_CheckCallback,tkawg5x0AttrFuncDCOffset_CheckCallback,tkawg5x0AttrFuncDutyCycleHigh_CheckCallback, etc.
Message 2 of 4
(3,614 Views)
Thank you for looking over the code and pointing out those items. I am not sure what you mean by "It's not important that every attribute, must have high-level function." If I want the user to be able to specify a duty cycle, then I need a way for him to input this information. Are you suggesting that I create a function called tkawg5x0_ConfigurePulse, with the parameters being passed in being the vi session, channel name, and duty cycle? Then if I am understanding you correctly, in this function I would use the following function to set the attribute to the value being passed in:
viFgen_GetAttributeViReal64(vi, "CHANNEL1", IVIFGEN_ATTR_FUNC_DUTY_CYCLE_HIGH, &duty_cycle);

sorry about so many questions, but this is my first time trying to do this.


Your help is greatly appreciated.
Thanks!
0 Kudos
Message 3 of 4
(3,614 Views)
User can use IviFgen_SetAttribute for every public attribute. These functions are common for all attributes and they are exported for users. This is reason why some attributes don't have high-level function.

You can use tkawg5x0_Set/GetAttribute in code too, but I suggest use funcion Ivi_SetAttribute.
If you want implement high-level function which sets one attribute, use following example:

ViStatus _VI_FUNC tkawg5x0_ConfigurePulse(ViSession vi, ViConstString channelName, ViReal64 dutyCycle)
{
return Ivi_SetAttributeViReal64(vi, channelName, IVIFGEN_ATTR_FUNC_DUTY_CYCLE_HIGH, IVI_VAL_DIRECT_USER_CALL, dutyCycle);
}

Flag IVI_VAL_DIRECT_USER_CALL means that session should be locked and when value has been written to ins
trument, driver will call Check Staus Callback. (of course when check status is enabled.)

Implementation with IVI_VAL_DIRECT_USER_CALL is same as following implementation:
ViStatus _VI_FUNC tkawg5x0_ConfigurePulse(ViSession vi, ViConstString channelName, ViReal64 dutyCycle)
{
ViStatus error = VI_SUCCESS;

checkErr( Ivi_LockSession (vi, VI_NULL));

checkErr( Ivi_SetAttributeViReal64(vi, channelName, IVIFGEN_ATTR_FUNC_DUTY_CYCLE_HIGH, 0, dutyCycle));

checkErr( tkawg5x0_CheckStatus (vi));

Error:
Ivi_UnlockSession (vi, VI_NULL);
return error;
}

Zdenek
0 Kudos
Message 4 of 4
(3,614 Views)