📄 hp662xa.c
字号:
To prevent tripping the power supply's over-voltage and over-current protection, the protection and protection level attributes must be set in the correct order: If the user is turning protection on, set the protection level first. If the user is turning protection off, turn the protection off first. */ if (ovpEnabled) { viCheckParm( Ivi_SetAttributeViReal64 (vi, channel, HP662XA_ATTR_VOLTAGE_LIMIT, 0, voltageLimit), 3, "Voltage Limit"); viCheckParm( Ivi_SetAttributeViBoolean (vi, channel, HP662XA_ATTR_OVP_ENABLED, 0, ovpEnabled), 5, "Over Voltage Protection Enabled"); } else { viCheckParm( Ivi_SetAttributeViBoolean (vi, channel, HP662XA_ATTR_OVP_ENABLED, 0, ovpEnabled), 5, "Over Voltage Protection Enabled"); viCheckParm( Ivi_SetAttributeViReal64 (vi, channel, HP662XA_ATTR_VOLTAGE_LIMIT, 0, voltageLimit), 3, "Voltage Limit"); } if (ocpEnabled) { viCheckParm( Ivi_SetAttributeViReal64 (vi, channel, HP662XA_ATTR_CURRENT_LIMIT, 0, currentLimit), 4, "Current Limit"); viCheckParm( Ivi_SetAttributeViBoolean (vi, channel, HP662XA_ATTR_OCP_ENABLED, 0, ocpEnabled), 6, "Over Current Protection Enabled"); } else { viCheckParm( Ivi_SetAttributeViBoolean (vi, channel, HP662XA_ATTR_OCP_ENABLED, 0, ocpEnabled), 6, "Over Current Protection Enabled"); viCheckParm( Ivi_SetAttributeViReal64 (vi, channel, HP662XA_ATTR_CURRENT_LIMIT, 0, currentLimit), 4, "Current Limit"); } checkErr( HP662XA_CheckStatus (vi));Error: HP662XA_GetRangeChangeStatus (vi, channel, &error); Ivi_UnlockSession (vi, VI_NULL); return error;}/***************************************************************************** * Function: HP662XA_Initiate * Purpose: This function initiates output changes. *****************************************************************************/ViStatus _VI_FUNC HP662XA_Initiate (ViSession vi){ return VI_SUCCESS;}/***************************************************************************** * Function: HP662XA_Abort * Purpose: This function aborts all pending output changes. *****************************************************************************/ViStatus _VI_FUNC HP662XA_Abort (ViSession vi){ return VI_SUCCESS;}/***************************************************************************** * Function: HP662XA_QueryOutputProtection * Purpose: This function determines if the power supply has tripped the * over-voltage or over-current protection. * * The power supply trips the over-voltage protection when it * detects a voltage on the output that is higher than the voltage * you specify with the HP662XA_ATTR_VOLTAGE_LIMIT * attribute and the HP662XA_ATTR_OVP_ENABLED * attribute is set to VI_TRUE. * * The power supply trips the over-current protection when it * detects a current on the output that is higher than the current * you specify with the HP662XA_ATTR_CURRENT_LIMIT * attribute and the HP662XA_ATTR_OCP_ENABLED * attribute is set to VI_TRUE. *****************************************************************************/ViStatus _VI_FUNC HP662XA_QueryOutputProtection (ViSession vi, ViConstString channel, ViBoolean* ovpTripped, ViBoolean* ocpTripped){ return HP662XA_GetProtectionStatus (vi, channel, ovpTripped, ocpTripped, VI_NULL);}/***************************************************************************** * Function: HP662XA_ResetOutputProtection * Purpose: This function clears existing over-voltage and over-current * conditions. If the power supply trips over-voltage or * over-current protection, the user must call this function * before the power supply can connect its output in the * HP662XA_ConnectOutput function. * * The power supply trips over-voltage protection when it detects * a voltage on the output that is higher than the voltage you * specify with the HP662XA_ATTR_VOLTAGE_LIMIT * attribute and the HP662XA_ATTR_OVP_ENABLED * attribute is set to VI_TRUE. * * The power supply trips over-current protection when it detects * a current on the output that is higher than the current you * specify with the HP662XA_ATTR_CURRENT_LIMIT * attribute and the HP662XA_ATTR_OCP_ENABLED * attribute is set to VI_TRUE. *****************************************************************************/ViStatus _VI_FUNC HP662XA_ResetOutputProtection (ViSession vi, ViConstString channel){ ViStatus error = VI_SUCCESS; ViBoolean ovpTripped; ViBoolean ocpTripped; ViConstString coercedChannel; checkErr( Ivi_LockSession(vi, VI_NULL)); if (!Ivi_Simulating (vi)) /* call only when locked */ { ViSession io = Ivi_IOSession (vi); /* call only when locked */ checkErr( Ivi_SetNeedToCheckStatus (vi, VI_TRUE)); /* Make sure the output stays disconnected. */ checkErr( HP662XA_QueryOutputProtection (vi, channel, &ovpTripped, &ocpTripped)); if (ovpTripped || ocpTripped) { checkErr( Ivi_SetAttributeViBoolean (vi, channel, HP662XA_ATTR_OUTPUT_CONNECTED, 0, VI_FALSE)); } checkErr( Ivi_CoerceChannelName (vi, channel, &coercedChannel)); viCheckErr( viPrintf (io, "OVRST %s;OCRST %s;", coercedChannel, coercedChannel)); } checkErr( HP662XA_CheckStatus (vi));Error: Ivi_UnlockSession(vi, VI_NULL); return error;}/***************************************************************************** * Function: HP662XA_ConfigureDCV * Purpose: This function configures the power supply to generate a * DC voltage on a channel. *****************************************************************************/ViStatus _VI_FUNC HP662XA_ConfigureDCV (ViSession vi, ViConstString channel, ViReal64 dcVoltage){ ViStatus error = VI_SUCCESS; checkErr( Ivi_LockSession (vi, VI_NULL)); viCheckParm( Ivi_SetAttributeViReal64 (vi, channel, HP662XA_ATTR_DC_VOLTAGE, 0, dcVoltage), 3, "Voltage"); checkErr( HP662XA_CheckStatus (vi));Error: HP662XA_GetRangeChangeStatus (vi, channel, &error); Ivi_UnlockSession (vi, VI_NULL); return error;}/***************************************************************************** * Function: HP662XA_GenerateDCV * Purpose: This function configures the power supply to generate a * DC voltage on a channel and intiates the output change. *****************************************************************************/ViStatus _VI_FUNC HP662XA_GenerateDCV (ViSession vi, ViConstString channel, ViReal64 dcVoltage){ ViStatus error = VI_SUCCESS; ViStatus status; checkErr( Ivi_LockSession (vi, VI_NULL)); status = HP662XA_ConfigureDCV (vi, channel, dcVoltage); checkErr( status); checkErr( HP662XA_Initiate (vi)); checkErr( HP662XA_CheckStatus (vi));Error: if ((status > 0) && (error >= 0)) error = status; Ivi_UnlockSession (vi, VI_NULL); return error;} /***************************************************************************** * Function: HP662XA_ConfigureMeasurement * Purpose: This function configures the measurement the power supply takes * on a channel. *****************************************************************************/ViStatus _VI_FUNC HP662XA_ConfigureMeasurement (ViSession vi, ViConstString channel, ViInt32 measureFunction){ ViStatus error = VI_SUCCESS; checkErr( Ivi_LockSession (vi, VI_NULL)); viCheckParm( Ivi_SetAttributeViInt32 (vi, channel, HP662XA_ATTR_MEASURE_FUNCTION, 0, measureFunction), 3, "Measure Function"); checkErr( HP662XA_CheckStatus (vi));Error: Ivi_UnlockSession (vi, VI_NULL); return error;}/***************************************************************************** * Function: HP662XA_InitiateMeasurement * Purpose: This function initiates the measurement subsystem. *****************************************************************************/ViStatus _VI_FUNC HP662XA_InitiateMeasurement (ViSession vi){ ViStatus error = VI_SUCCESS; ViInt32 numberOfChannels; ViInt32 measureFunction; ViReal64 measurement; ViBoolean simulating; ViBoolean useSpecificSimulation; ViSession io; ViString cmd; ViConstString channel; ViInt32 i; IviRangeTablePtr measureFunctionRangeTable; checkErr( Ivi_LockSession (vi, VI_NULL)); simulating = Ivi_Simulating (vi); useSpecificSimulation = Ivi_UseSpecificSimulation (vi); if (!simulating) { io = Ivi_IOSession (vi); checkErr( Ivi_SetNeedToCheckStatus (vi, VI_TRUE)); } /* Take a measurement on each channel. */ checkErr( Ivi_GetAttributeViInt32 (vi, VI_NULL, HP662XA_ATTR_NUM_CHANNELS, 0, &numberOfChannels)); for (i=1; i<=numberOfChannels; i++) { checkErr( Ivi_GetNthChannelString (vi, i, &channel)); checkErr( Ivi_GetAttributeViInt32 (vi, channel, HP662XA_ATTR_MEASURE_FUNCTION, 0, &measureFunction));
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -