nai sg utils
Edit this on GitLab
nai sg utils
Explanation
About the Sample Application Code
This sample code demonstrates various functions used to interact with North Atlantic Industries' (NAI) embedded function modules, particularly for strain gauge (SG) configurations and operations. Below is a detailed explanation of what each part of the code does:
Includes
#include <stdio.h> #include <ctype.h> #include <stdlib.h> #include <string.h> #include "include/naiapp_boardaccess_menu.h" #include "include/naiapp_boardaccess_query.h" #include "include/naiapp_boardaccess_access.h" #include "include/naiapp_boardaccess_display.h" #include "include/naiapp_boardaccess_utils.h" #include "nai_sg_utils.h" #include "nai.h" #include "naibrd.h" #include "functions/naibrd_sg.h"
-
'stdio.h', 'ctype.h', 'stdlib.h', 'string.h': Standard C libraries for input/output operations, character operations, general utilities, and string handling.
-
'naiapp_boardaccess_*': Headers for board access functionalities specific to NAI’s software.
-
'nai_sg_utils.h': Utility functions for strain gauge operations.
-
'nai.h', 'naibrd.h', 'naibrd_sg.h': Headers representing the NAI board and strain gauge functionalities.
Function: 'SG_DisplayCfg'
Displays the SG configuration settings.
Parameters: - 'cardIndex': Index of the card. - 'module': Module number. - 'maxchan': Maximum number of channels.
Responsibilities: - Retrieve and display various strain gauge settings for each channel. - Settings include gain range, excitation mode, excitation voltage, bridge sensitivity, sensor full scale, and remote sense status.
Function: 'SG_DisplayCalData'
Displays the SG calibration settings.
Parameters: - 'cardIndex', 'module': Index of the card and the module number.
Responsibilities: - Retrieve and display calibration interval, type, and status. - Also shows the status of enabled calibration channels.
Function: 'SG_DisplayForceTable'
Displays the SG standard operations force table.
Parameters: - 'cardIndex', 'module', 'maxchan': Index of the card, module number, and maximum number of channels.
Responsibilities: - Display outputs, output voltages, and various status bits such as BIT status, open status, AD error, and AD no reference status for each channel.
Function: 'SG_DisplayRangeScaledTable'
Displays the SG standard operations range-scaled table.
Parameters: - 'cardIndex', 'module', 'maxchan': Index of the card, module number, and maximum number of channels.
Responsibilities: - Display 24-bit and 16-bit range-scaled data, output voltages, and various status bits for each channel.
Function: 'SG_DisplayUnscaledTable'
Displays the SG standard operations unscaled table.
Parameters: - 'cardIndex', 'module', 'maxchan': Index of the card, module number, and maximum number of channels.
Responsibilities: - Display 24-bit and 16-bit unscaled data, output voltages, and various status bits for each channel.
Function: 'SG_DisplayStandardOpsData'
Displays the SG standard operations for Gen 5 SG modules.
Parameters: - 'cardIndex', 'module', 'maxchan': Index of the card, module number, and maximum number of channels.
Responsibilities: - Retrieve and display vital operation metrics such as output, strain, min/max strain, and raw AD readings. - Display various status bits indicating BIT status, open status, strain alarms, and alerts.
Function: 'SG_Gen5_DisplayCfg'
Displays the SG configuration settings for Gen 5 SG modules.
Parameters: - 'cardIndex', 'module', 'maxchan': Index of the card, module number, and maximum number of channels.
Responsibilities: - Retrieve and display settings including excitation voltage, bridge configuration, PGA gain, remote sense, nominal resistance, gauge factor, Poisson ratio, lead resistance, sample rate, strain thresholds, and imbalance offset. - Display settings for internal bridge completion.
Function: 'SG_DisplayStandardOpsDataRaw'
Displays the raw hex register values for vital operation metrics for Gen 5 SG modules.
Parameters: - 'cardIndex', 'module', 'maxchan': Index of the card, module number, and maximum number of channels.
Responsibilities: - Retrieve and display raw hex values of output, strain, min/max strain, raw AD readings, and various status bits.
Function: 'SG_Gen5_DisplayCfgRaw'
Displays the SG configuration settings with raw hex register values for Gen 5 SG modules.
Parameters: - 'cardIndex', 'module', 'maxchan': Index of the card, module number, and maximum number of channels.
Responsibilities: - Retrieve and display raw hex values including excitation voltage, nominal resistance, gauge factor, Poisson ratio, lead resistance, strain thresholds, imbalance offset, and internal bridge completion settings.
Utility Function: 'check_status'
This utility function is used to check the status of various operations, ensuring error handling and proper execution.
Enumerations and Definitions: - The code uses various enumerations and typedefs such as 'nai_sg_gain_range_t', 'nai_sg_excitation_mode_t', 'nai_sg_remote_sense_t', 'nai_sg_cal_type_t', and status bits to represent configuration values and status types. These are likely defined in the included header files.
This sample code can be used as a reference or starting point for working with NAI�s strain gauge functions, providing detailed output and configuration data for various operations and settings associated with their embedded function modules.
#include <stdio.h>
#include <ctype.h>
#include <stdlib.h>
#include <string.h>
/* Common Sample Program include files */
#include "include/naiapp_boardaccess_menu.h"
#include "include/naiapp_boardaccess_query.h"
#include "include/naiapp_boardaccess_access.h"
#include "include/naiapp_boardaccess_display.h"
#include "include/naiapp_boardaccess_utils.h"
/* Common SG Sample Program include files */
#include "nai_sg_utils.h"
/* naibrd include files */
#include "nai.h"
#include "naibrd.h"
#include "functions/naibrd_sg.h"
/**************************************************************************************************************/
/**
<summary>
This function displays the SG Configuration settings.
</summary>
*/
/**************************************************************************************************************/
void SG_DisplayCfg(int32_t cardIndex, int32_t module, int32_t maxchan)
{
nai_sg_gain_range_t range;
float32_t fRange = 0.0;
nai_sg_excitation_mode_t mode;
char sMode[3] = "DC";
float32_t excitationvolt;
float32_t bridgesensitivity;
float32_t bridgesensitivitymVV;
float32_t sensorfs;
nai_sg_remote_sense_t sense;
int32_t chan;
printf("\n\nSG Configuration:\n");
printf("Ch Range Excitation Excitation Br. Sens. Sensor Remote Drive\n");
printf(" Mode Volt (mV/V) FS Sense\n");
printf("---------------------------------------------------------------------------\n");
for (chan = 1; chan <= maxchan; chan++)
{
check_status(naibrd_SG_GetGainRange(cardIndex, module, chan, &range));
switch (range)
{
case SG_GEN3_GAIN_RANGE_128:
fRange = 0.0078125;
break;
case SG_GEN3_GAIN_RANGE_64:
fRange = 0.015625;
break;
case SG_GEN3_GAIN_RANGE_32:
fRange = 0.03125;
break;
case SG_GEN3_GAIN_RANGE_16:
fRange = 0.0625;
break;
case SG_GEN3_GAIN_RANGE_8:
fRange = 0.125;
break;
case SG_GEN3_GAIN_RANGE_1:
fRange = 1.0;
break;
default:
break;
}
check_status(naibrd_SG_GetExcitationMode(cardIndex, module, chan, &mode));
if(mode == 1)
{
sMode[0] = 'A';
}
else
{
sMode[0] = 'D';
}
check_status(naibrd_SG_GetExcitation(cardIndex, module, chan, &excitationvolt));
check_status(naibrd_SG_GetBridgeSensitivity(cardIndex, module, chan, &bridgesensitivity));
bridgesensitivitymVV = bridgesensitivity * 1000;
check_status(naibrd_SG_GetSensorFS(cardIndex, module, chan, &sensorfs));
check_status(naibrd_SG_GetRemoteDriveSense(cardIndex, module, chan, &sense));
printf("%d %.7f %s %12.4f %10.4f %9.2f %7d\n",
chan, fRange, sMode, excitationvolt, bridgesensitivitymVV, sensorfs, sense);
}
}
/**************************************************************************************************************/
/**
<summary>
This function displays the SG Calibration settings.
</summary>
*/
/**************************************************************************************************************/
void SG_DisplayCalData(int32_t cardIndex, int32_t module)
{
nai_sg_cal_type_t calType;
uint32_t calInterval;
float32_t calIntervalSec;
float32_t outputDataRate;
nai_sg_chop_stab_enable_t chopStabEnable;
nai_sg_SINC_filter_t SINCFilter;
uint32_t ODRScale;
nai_sg_reject_60Hz_enable_t reject60Hz;
uint32_t rawCalChan;
printf("\n\nSG Calibration Options:\n");
printf("Cal Interval Calibration Calibration Channel Enabled\n");
printf(" (sec) Type 4 3 2 1\n");
printf("----------------------------- ------------------------------------------------\n");
check_status(naibrd_SG_GetCalInterval(cardIndex, module, &calInterval));
check_status(naibrd_SG_GetOutputDataCfg(cardIndex, module, &chopStabEnable, &SINCFilter, &ODRScale, &reject60Hz, &outputDataRate));
calIntervalSec = (float32_t)(calInterval * 256 / outputDataRate);
printf("%6.1f ", calIntervalSec);
check_status(naibrd_SG_GetCalType(cardIndex, module, &calType));
switch (calType)
{
case SG_GEN3_CAL_OFF:
printf(" Off ");
break;
case SG_GEN3_CAL_INT_ZERO_INT_FULL:
printf(" Internal Cal ");
break;
case SG_GEN3_CAL_CAL_SYS_ZERO_SCALE:
printf(" System Offset ");
break;
case SG_GEN3_CAL_CAL_SYS_FULL_SCALE:
printf(" System Gain ");
break;
default:
printf("Invalid Cal Type ");
break;
}
check_status(naibrd_SG_GetRaw(cardIndex, module, NAI_SG_RAW_CAL_CHAN, &rawCalChan));
if( ((rawCalChan >> 3) & 1) == 1 )
{
printf(" ON ");
}
else
{
printf(" - ");
}
if( ( (rawCalChan >> 2) & 1 ) == 1 )
{
printf(" ON ");
}
else
{
printf(" - ");
}
if( ( (rawCalChan >> 1) & 1 ) == 1 )
{
printf(" ON ");
}
else
{
printf(" - ");
}
if( (rawCalChan & 1) == 1 )
{
printf(" ON\n");
}
else
{
printf(" -\n");
}
}
/**************************************************************************************************************/
/**
<summary>
This function displays the SG Standard Operations Force Table.
</summary>
*/
/**************************************************************************************************************/
void SG_DisplayForceTable(int32_t cardIndex, int32_t module, int32_t maxchan)
{
float32_t output;
float32_t outputvv;
nai_status_bit_t bitstat;
nai_status_bit_t openstat;
nai_status_bit_t aderrstat;
nai_status_bit_t adnorefstat;
int32_t chan;
printf("\n\nSG Standard Operations Force:\n");
printf("Ch Output Output BIT Open AD Err AD No Ref\n");
printf(" (V/V) Status Status Status Status\n");
printf("---------------------------------------------------------------------------\n");
for (chan = 1; chan <= maxchan; chan++)
{
check_status(naibrd_SG_GetOutput(cardIndex, module, chan, &output));
check_status(naibrd_SG_GetOutputVV(cardIndex, module, chan, &outputvv));
check_status(naibrd_SG_GetStatus(cardIndex, module, chan, NAI_SG_STATUS_BIT_LATCHED, &bitstat));
check_status(naibrd_SG_GetStatus(cardIndex, module, chan, NAI_SG_STATUS_OPEN_LATCHED, &openstat));
check_status(naibrd_SG_GetStatus(cardIndex, module, chan, NAI_SG_STATUS_AD_ERR_LATCHED, &aderrstat));
check_status(naibrd_SG_GetStatus(cardIndex, module, chan, NAI_SG_STATUS_AD_NO_REF_LATCHED, &adnorefstat));
printf("%d %12.6f %f %d %d %d %d\n",
chan, output, outputvv, bitstat, openstat, aderrstat, adnorefstat);
}
}
/**************************************************************************************************************/
/**
<summary>
This function displays the SG Standard Operations Range Scaled Table.
</summary>
*/
/**************************************************************************************************************/
void SG_DisplayRangeScaledTable(int32_t cardIndex, int32_t module, int32_t maxchan)
{
int32_t rawDataRangeScaled24Bit;
float32_t outputvv;
int32_t rawDataRangeScaled16Bit;
nai_status_bit_t bitstat;
nai_status_bit_t openstat;
nai_status_bit_t aderrstat;
nai_status_bit_t adnorefstat;
int32_t chan;
printf("\n\nSG Standard Operations Range Scaled:\n");
printf("Ch Raw 24 Bit Data Output Raw 16 Bit Data BIT Open AD Err AD No Ref\n");
printf(" Range Scaled (V/V) Range Scaled Status Status Status Status\n");
printf("----------------------------------------------------------------------------------------\n");
for (chan = 1; chan <= maxchan; chan++)
{
check_status(naibrd_SG_GetRawOutput(cardIndex, module, chan, NAI_SG_CHAN_24_OUTPUT_SCALED, &rawDataRangeScaled24Bit));
check_status(naibrd_SG_GetOutputVV(cardIndex, module, chan, &outputvv));
check_status(naibrd_SG_GetRawOutput(cardIndex, module, chan, NAI_SG_CHAN_16_OUTPUT_SCALED, &rawDataRangeScaled16Bit));
check_status(naibrd_SG_GetStatus(cardIndex, module, chan, NAI_SG_STATUS_BIT_LATCHED, &bitstat));
check_status(naibrd_SG_GetStatus(cardIndex, module, chan, NAI_SG_STATUS_OPEN_LATCHED, &openstat));
check_status(naibrd_SG_GetStatus(cardIndex, module, chan, NAI_SG_STATUS_AD_ERR_LATCHED, &aderrstat));
check_status(naibrd_SG_GetStatus(cardIndex, module, chan, NAI_SG_STATUS_AD_NO_REF_LATCHED, &adnorefstat));
printf("%d %*d %f %*d %d %d %d %d\n",
chan, 7, rawDataRangeScaled24Bit, outputvv, 4, rawDataRangeScaled16Bit, bitstat, openstat, aderrstat, adnorefstat);
}
}
/**************************************************************************************************************/
/**
<summary>
This function displays the SG Standard Operations Unscaled Table.
</summary>
*/
/**************************************************************************************************************/
void SG_DisplayUnscaledTable(int32_t cardIndex, int32_t module, int32_t maxchan)
{
int32_t rawDataUnscaled24Bit;
float32_t outputvv;
int32_t rawDataUnscaled16Bit;
nai_status_bit_t bitstat;
nai_status_bit_t openstat;
nai_status_bit_t aderrstat;
nai_status_bit_t adnorefstat;
int32_t chan;
printf("\n\nSG Standard Operations Unscaled:\n");
printf("Ch Raw 24 Bit Output Raw 16 Bit BIT Open AD Err AD No Ref\n");
printf(" Data Unscaled (V/V) Data Unscaled Status Status Status Status\n");
printf("----------------------------------------------------------------------------------------\n");
for (chan = 1; chan <= maxchan; chan++)
{
check_status(naibrd_SG_GetRawOutput(cardIndex, module, chan, NAI_SG_CHAN_24_OUTPUT_UNSCALED, &rawDataUnscaled24Bit));
check_status(naibrd_SG_GetOutputVV(cardIndex, module, chan, &outputvv));
check_status(naibrd_SG_GetRawOutput(cardIndex, module, chan, NAI_SG_CHAN_16_OUTPUT_UNSCALED, &rawDataUnscaled16Bit));
check_status(naibrd_SG_GetStatus(cardIndex, module, chan, NAI_SG_STATUS_BIT_LATCHED, &bitstat));
check_status(naibrd_SG_GetStatus(cardIndex, module, chan, NAI_SG_STATUS_OPEN_LATCHED, &openstat));
check_status(naibrd_SG_GetStatus(cardIndex, module, chan, NAI_SG_STATUS_AD_ERR_LATCHED, &aderrstat));
check_status(naibrd_SG_GetStatus(cardIndex, module, chan, NAI_SG_STATUS_AD_NO_REF_LATCHED, &adnorefstat));
printf("%d %*d %f %*d %d %d %d %d\n",
chan, 7, rawDataUnscaled24Bit, outputvv, 5, rawDataUnscaled16Bit, bitstat, openstat, aderrstat, adnorefstat);
}
}
/**************************************************************************************************************/
/**
<summary>
This function displays the SG Standard Operations Table for Gen 5 SG modules.
</summary>
*/
/**************************************************************************************************************/
void SG_DisplayStandardOpsData(int32_t cardIndex, int32_t module, int32_t maxchan)
{
int32_t chan = 0;
float64_t vOutVExc = 0.0;
float64_t strain = 0.0;
float64_t minStrain = 0.0;
float64_t maxStrain = 0.0;
uint32_t rawADReading = 0u;
nai_status_bit_t bitStatusLatched = 0u;
nai_status_bit_t bitStatusRealtime = 0u;
nai_status_bit_t openStatusLatched = 0u;
nai_status_bit_t openStatusRealtime = 0u;
nai_status_bit_t strainAlarmLoStatusLatched = 0u;
nai_status_bit_t strainAlarmLoStatusRealtime = 0u;
nai_status_bit_t strainAlertLoStatusLatched = 0u;
nai_status_bit_t strainAlertLoStatusRealtime = 0u;
nai_status_bit_t strainAlertHiStatusLatched = 0u;
nai_status_bit_t strainAlertHiStatusRealtime = 0u;
nai_status_bit_t strainAlarmHiStatusLatched = 0u;
nai_status_bit_t strainAlarmHiStatusRealtime = 0u;
printf("\n\nSG Standard Operations:\n");
printf("Ch Output Strain Min Strain Max Strain Raw AD BIT Open Strain Alarm Strain Alert Strain Alert Strain Alarm\n");
printf(" (V/V) (microstrain) (microstrain) (microstrain) Reading Status Status Low Status Low Status High Status High Status\n");
printf(" (R/L) (R/L) (R/L) (R/L) (R/L) (R/L) \n");
printf("-----------------------------------------------------------------------------------------------------------------------------------------------\n");
for (chan = 1; chan <= maxchan; chan++)
{
check_status(naibrd_SG_GetOutputVoutVexc(cardIndex, module, chan, &vOutVExc));
check_status(naibrd_SG_GetStrain(cardIndex, module, chan, &strain));
check_status(naibrd_SG_GetMinStrainValue(cardIndex, module, chan, &minStrain));
check_status(naibrd_SG_GetMaxStrainValue(cardIndex, module, chan, &maxStrain));
check_status(naibrd_SG_GetRawADReading(cardIndex, module, chan, &rawADReading));
check_status(naibrd_SG_GetStatus(cardIndex, module, chan, NAI_SG_STATUS_BIT_LATCHED, &bitStatusLatched));
check_status(naibrd_SG_GetStatus(cardIndex, module, chan, NAI_SG_STATUS_BIT_REALTIME, &bitStatusRealtime));
check_status(naibrd_SG_GetStatus(cardIndex, module, chan, NAI_SG_STATUS_OPEN_LATCHED, &openStatusLatched));
check_status(naibrd_SG_GetStatus(cardIndex, module, chan, NAI_SG_STATUS_OPEN_REALTIME, &openStatusRealtime));
check_status(naibrd_SG_GetStatus(cardIndex, module, chan, NAI_SG_STATUS_HIGH_STRAIN_ALERT_1_LATCHED, &strainAlertHiStatusLatched));
check_status(naibrd_SG_GetStatus(cardIndex, module, chan, NAI_SG_STATUS_HIGH_STRAIN_ALERT_1_REALTIME, &strainAlertHiStatusRealtime));
check_status(naibrd_SG_GetStatus(cardIndex, module, chan, NAI_SG_STATUS_HIGH_STRAIN_ALERT_2_LATCHED, &strainAlarmHiStatusLatched));
check_status(naibrd_SG_GetStatus(cardIndex, module, chan, NAI_SG_STATUS_HIGH_STRAIN_ALERT_2_REALTIME, &strainAlarmHiStatusRealtime));
check_status(naibrd_SG_GetStatus(cardIndex, module, chan, NAI_SG_STATUS_LOW_STRAIN_ALERT_1_LATCHED, &strainAlertLoStatusLatched));
check_status(naibrd_SG_GetStatus(cardIndex, module, chan, NAI_SG_STATUS_LOW_STRAIN_ALERT_1_REALTIME, &strainAlertLoStatusRealtime));
check_status(naibrd_SG_GetStatus(cardIndex, module, chan, NAI_SG_STATUS_LOW_STRAIN_ALERT_2_LATCHED, &strainAlarmLoStatusLatched));
check_status(naibrd_SG_GetStatus(cardIndex, module, chan, NAI_SG_STATUS_LOW_STRAIN_ALERT_2_REALTIME, &strainAlarmLoStatusRealtime));
printf("%2d %12.8f %13.6f %13.6f %13.6f 0x%08X (%1d/%1d) (%1d/%1d) (%1d/%1d) (%1d/%1d) (%1d/%1d) (%1d/%1d)\n",
chan, vOutVExc, strain, minStrain, maxStrain, rawADReading, bitStatusRealtime, bitStatusLatched, openStatusRealtime,
openStatusLatched, strainAlarmLoStatusRealtime, strainAlarmLoStatusLatched, strainAlertLoStatusRealtime,
strainAlertLoStatusLatched, strainAlertHiStatusRealtime, strainAlertHiStatusLatched, strainAlarmHiStatusRealtime,
strainAlarmHiStatusLatched);
}
}
/**************************************************************************************************************/
/**
<summary>
This function displays the SG Configuration settings for Gen 5 SG modules.
</summary>
*/
/**************************************************************************************************************/
void SG_Gen5_DisplayCfg(int32_t cardIndex, int32_t module, int32_t maxchan)
{
int32_t chan = 0;
float64_t excitationVolt = 0.0;
nai_sg_bridge_config_type_t bridgeConfig = 0u;
nai_sg_pga_gain_type_t pgaGain = 0u;
nai_sg_remote_sense_t remoteSense = 0u;
float64_t nominalRes = 0.0;
float64_t gaugeFactor = 0.0;
float64_t poissonRatio = 0.0;
float64_t leadRes = 0.0;
nai_sg_sample_rate_type_t sampleRate = 0u;
float64_t strainAlarmLoThres = 0.0;
float64_t strainAlertLoThres = 0.0;
float64_t strainAlertHiThres = 0.0;
float64_t strainAlarmHiThres = 0.0;
float64_t imbalanceOffset = 0.0;
bool_t useInternalBridgeComp = FALSE;
char strBridgeConfig[20] = "";
char strPGAGain[20] = "";
char strRemoteSense[20] = "";
char strSampleRate[20] = "";
char strBridgeComp[20] = "";
printf("\n\nSG Configuration:\n");
printf("Ch Excitation Bridge PGA Remote Nominal Gauge Poisson Lead Sample Strain Alarm Strain Alert Strain Alert Strain Alarm Imbalance Internal \n");
printf(" (V) Configuration Gain Sense Resistance Factor Ratio Resistance Rate Low Threshold Low Threshold High Threshold High Threshold Offset Bridge \n");
printf(" (Ohms) (Ohms) (Hz) (microstrain) (microstrain) (microstrain) (microstrain) Completion\n");
printf("-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------\n");
for (chan = 1; chan <= maxchan; chan++)
{
check_status(naibrd_SG_GetExcitationSignal(cardIndex, module, chan, &excitationVolt));
check_status(naibrd_SG_GetBridgeConfiguration(cardIndex, module, chan, &bridgeConfig));
switch (bridgeConfig)
{
case NAI_SG_BRIDGE_CONFIG_QUARTER_BRIDGE_1:
sprintf(strBridgeConfig, "Quarter Bridge 1");
break;
case NAI_SG_BRIDGE_CONFIG_QUARTER_BRIDGE_2:
sprintf(strBridgeConfig, "Quarter Bridge 2");
break;
case NAI_SG_BRIDGE_CONFIG_HALF_BRIDGE_1:
sprintf(strBridgeConfig, " Half Bridge 1 ");
break;
case NAI_SG_BRIDGE_CONFIG_HALF_BRIDGE_2:
sprintf(strBridgeConfig, " Half Bridge 2 ");
break;
case NAI_SG_BRIDGE_CONFIG_FULL_BRIDGE_1:
sprintf(strBridgeConfig, " Full Bridge 1 ");
break;
case NAI_SG_BRIDGE_CONFIG_FULL_BRIDGE_2:
sprintf(strBridgeConfig, " Full Bridge 2 ");
break;
case NAI_SG_BRIDGE_CONFIG_FULL_BRIDGE_3:
sprintf(strBridgeConfig, " Full Bridge 3 ");
break;
default:
sprintf(strBridgeConfig, " Unknown ");
break;
}
check_status(naibrd_SG_GetPGAGain(cardIndex, module, chan, &pgaGain));
switch (pgaGain)
{
case NAI_SG_PGA_GAIN_1:
sprintf(strPGAGain, " 1 ");
break;
case NAI_SG_PGA_GAIN_2:
sprintf(strPGAGain, " 2 ");
break;
case NAI_SG_PGA_GAIN_4:
sprintf(strPGAGain, " 4 ");
break;
case NAI_SG_PGA_GAIN_8:
sprintf(strPGAGain, " 8 ");
break;
case NAI_SG_PGA_GAIN_16:
sprintf(strPGAGain, " 16 ");
break;
case NAI_SG_PGA_GAIN_32:
sprintf(strPGAGain, " 32 ");
break;
default:
sprintf(strPGAGain, "Unknown");
break;
}
check_status(naibrd_SG_GetRemoteDriveSense(cardIndex, module, chan, &remoteSense));
switch (remoteSense)
{
case SG_GEN5_LOCAL_SENSE:
sprintf(strRemoteSense, " Local ");
break;
case SG_GEN5_REMOTE_SENSE:
sprintf(strRemoteSense, "Remote ");
break;
default:
sprintf(strRemoteSense, "Unknown");
break;
}
check_status(naibrd_SG_GetNominalResistance(cardIndex, module, chan, &nominalRes));
check_status(naibrd_SG_GetGaugeFactor(cardIndex, module, chan, &gaugeFactor));
check_status(naibrd_SG_GetPoissonRatio(cardIndex, module, chan, &poissonRatio));
check_status(naibrd_SG_GetLeadResistance(cardIndex, module, chan, &leadRes));
check_status(naibrd_SG_GetSampleRate(cardIndex, module, chan, &sampleRate));
switch (sampleRate)
{
case NAI_SG_SAMPLE_RATE_2P5_SPS:
sprintf(strSampleRate, " 2.5 ");
break;
case NAI_SG_SAMPLE_RATE_5_SPS:
sprintf(strSampleRate, " 5 ");
break;
case NAI_SG_SAMPLE_RATE_10_SPS:
sprintf(strSampleRate, " 10 ");
break;
case NAI_SG_SAMPLE_RATE_16P6666_SPS:
sprintf(strSampleRate, " 16.6666");
break;
case NAI_SG_SAMPLE_RATE_20_SPS:
sprintf(strSampleRate, " 20 ");
break;
case NAI_SG_SAMPLE_RATE_50_SPS:
sprintf(strSampleRate, " 50 ");
break;
case NAI_SG_SAMPLE_RATE_60_SPS:
sprintf(strSampleRate, " 60 ");
break;
case NAI_SG_SAMPLE_RATE_100_SPS:
sprintf(strSampleRate, " 100 ");
break;
case NAI_SG_SAMPLE_RATE_400_SPS:
sprintf(strSampleRate, " 400 ");
break;
case NAI_SG_SAMPLE_RATE_1200_SPS:
sprintf(strSampleRate, " 1200 ");
break;
case NAI_SG_SAMPLE_RATE_2400_SPS:
sprintf(strSampleRate, " 2400 ");
break;
case NAI_SG_SAMPLE_RATE_4800_SPS:
sprintf(strSampleRate, " 4800 ");
break;
case NAI_SG_SAMPLE_RATE_7200_SPS:
sprintf(strSampleRate, " 7200 ");
break;
case NAI_SG_SAMPLE_RATE_14400_SPS:
sprintf(strSampleRate, "14400 ");
break;
case NAI_SG_SAMPLE_RATE_19200_SPS:
sprintf(strSampleRate, "19200 ");
break;
case NAI_SG_SAMPLE_RATE_38400_SPS:
sprintf(strSampleRate, "38400 ");
break;
default:
sprintf(strSampleRate, " Unknown ");
break;
}
check_status(naibrd_SG_GetStrainAlertValue(cardIndex, module, chan, NAI_SG_LOW_STRAIN_ALERT_2_VALUE, &strainAlarmLoThres));
check_status(naibrd_SG_GetStrainAlertValue(cardIndex, module, chan, NAI_SG_LOW_STRAIN_ALERT_1_VALUE, &strainAlertLoThres));
check_status(naibrd_SG_GetStrainAlertValue(cardIndex, module, chan, NAI_SG_HIGH_STRAIN_ALERT_1_VALUE, &strainAlertHiThres));
check_status(naibrd_SG_GetStrainAlertValue(cardIndex, module, chan, NAI_SG_HIGH_STRAIN_ALERT_2_VALUE, &strainAlarmHiThres));
check_status(naibrd_SG_GetImbalanceOffsetValue(cardIndex, module, chan, &imbalanceOffset));
check_status(naibrd_SG_GetUseInternalBridgeCompletion(cardIndex, module, chan, &useInternalBridgeComp));
switch (useInternalBridgeComp)
{
case FALSE:
sprintf(strBridgeComp, "Disabled");
break;
case TRUE:
sprintf(strBridgeComp, "Enabled ");
break;
default:
sprintf(strBridgeComp, "Unknown ");
break;
}
printf("%2d %10.5f %s %s %s %10.4f %10.4f %10.4f %10.4f %s %14.6f %14.6f %14.6f %14.6f %10.4f %s\n",
chan, excitationVolt, strBridgeConfig, strPGAGain, strRemoteSense, nominalRes, gaugeFactor, poissonRatio, leadRes, strSampleRate,
strainAlarmLoThres, strainAlertLoThres, strainAlertHiThres, strainAlarmHiThres, imbalanceOffset, strBridgeComp);
}
}
/**************************************************************************************************************/
/**
<summary>
This function displays the SG Standard Operations Table for Gen 5 SG modules. The raw hex register values are
displayed for each reading.
</summary>
*/
/**************************************************************************************************************/
void SG_DisplayStandardOpsDataRaw(int32_t cardIndex, int32_t module, int32_t maxchan)
{
int32_t chan = 0;
uint32_t vOutVExcRaw = 0u;
uint32_t strainRaw = 0u;
uint32_t minStrainRaw = 0u;
uint32_t maxStrainRaw = 0u;
uint32_t rawADReading = 0u;
nai_status_bit_t bitStatusLatched = 0u;
nai_status_bit_t bitStatusRealtime = 0u;
nai_status_bit_t openStatusLatched = 0u;
nai_status_bit_t openStatusRealtime = 0u;
nai_status_bit_t strainAlarmLoStatusLatched = 0u;
nai_status_bit_t strainAlarmLoStatusRealtime = 0u;
nai_status_bit_t strainAlertLoStatusLatched = 0u;
nai_status_bit_t strainAlertLoStatusRealtime = 0u;
nai_status_bit_t strainAlertHiStatusLatched = 0u;
nai_status_bit_t strainAlertHiStatusRealtime = 0u;
nai_status_bit_t strainAlarmHiStatusLatched = 0u;
nai_status_bit_t strainAlarmHiStatusRealtime = 0u;
printf("\n\nSG Standard Operations:\n");
printf("Ch Output Strain Min Strain Max Strain Raw AD BIT Open Strain Alarm Strain Alert Strain Alert Strain Alarm\n");
printf(" (V/V) (microstrain) (microstrain) (microstrain) Reading Status Status Low Status Low Status High Status High Status\n");
printf(" (R/L) (R/L) (R/L) (R/L) (R/L) (R/L) \n");
printf("-----------------------------------------------------------------------------------------------------------------------------------------------\n");
for (chan = 1; chan <= maxchan; chan++)
{
check_status(naibrd_SG_GetChannelRaw(cardIndex, module, chan, NAI_SG_RAW_CHAN_OUTPUT_VV, &vOutVExcRaw));
check_status(naibrd_SG_GetChannelRaw(cardIndex, module, chan, NAI_SG_RAW_CHAN_OUTPUT, &strainRaw));
check_status(naibrd_SG_GetChannelRaw(cardIndex, module, chan, NAI_SG_RAW_CHAN_MIN_STRAIN, &minStrainRaw));
check_status(naibrd_SG_GetChannelRaw(cardIndex, module, chan, NAI_SG_RAW_CHAN_MAX_STRAIN, &maxStrainRaw));
check_status(naibrd_SG_GetRawADReading(cardIndex, module, chan, &rawADReading));
check_status(naibrd_SG_GetStatus(cardIndex, module, chan, NAI_SG_STATUS_BIT_LATCHED, &bitStatusLatched));
check_status(naibrd_SG_GetStatus(cardIndex, module, chan, NAI_SG_STATUS_BIT_REALTIME, &bitStatusRealtime));
check_status(naibrd_SG_GetStatus(cardIndex, module, chan, NAI_SG_STATUS_OPEN_LATCHED, &openStatusLatched));
check_status(naibrd_SG_GetStatus(cardIndex, module, chan, NAI_SG_STATUS_OPEN_REALTIME, &openStatusRealtime));
check_status(naibrd_SG_GetStatus(cardIndex, module, chan, NAI_SG_STATUS_HIGH_STRAIN_ALERT_1_LATCHED, &strainAlertHiStatusLatched));
check_status(naibrd_SG_GetStatus(cardIndex, module, chan, NAI_SG_STATUS_HIGH_STRAIN_ALERT_1_REALTIME, &strainAlertHiStatusRealtime));
check_status(naibrd_SG_GetStatus(cardIndex, module, chan, NAI_SG_STATUS_HIGH_STRAIN_ALERT_2_LATCHED, &strainAlarmHiStatusLatched));
check_status(naibrd_SG_GetStatus(cardIndex, module, chan, NAI_SG_STATUS_HIGH_STRAIN_ALERT_2_REALTIME, &strainAlarmHiStatusRealtime));
check_status(naibrd_SG_GetStatus(cardIndex, module, chan, NAI_SG_STATUS_LOW_STRAIN_ALERT_1_LATCHED, &strainAlertLoStatusLatched));
check_status(naibrd_SG_GetStatus(cardIndex, module, chan, NAI_SG_STATUS_LOW_STRAIN_ALERT_1_REALTIME, &strainAlertLoStatusRealtime));
check_status(naibrd_SG_GetStatus(cardIndex, module, chan, NAI_SG_STATUS_LOW_STRAIN_ALERT_2_LATCHED, &strainAlarmLoStatusLatched));
check_status(naibrd_SG_GetStatus(cardIndex, module, chan, NAI_SG_STATUS_LOW_STRAIN_ALERT_2_REALTIME, &strainAlarmLoStatusRealtime));
printf("%2d 0x%08X 0x%08X 0x%08X 0x%08X 0x%08X (%1d/%1d) (%1d/%1d) (%1d/%1d) (%1d/%1d) (%1d/%1d) (%1d/%1d)\n",
chan, vOutVExcRaw, strainRaw, minStrainRaw, maxStrainRaw, rawADReading, bitStatusRealtime, bitStatusLatched, openStatusRealtime,
openStatusLatched, strainAlarmLoStatusRealtime, strainAlarmLoStatusLatched, strainAlertLoStatusRealtime,
strainAlertLoStatusLatched, strainAlertHiStatusRealtime, strainAlertHiStatusLatched, strainAlarmHiStatusRealtime,
strainAlarmHiStatusLatched);
}
}
/**************************************************************************************************************/
/**
<summary>
This function displays the SG Configuration settings for Gen 5 SG modules. The raw hex register values are
displayed for each of the following: excitation voltage, nominal resistance, gauge factor, position ratio,
lead resistance, strain alarm low threshold, strain alert low threshold, strain alert high threshold,
strain alarm high threshold, and imbalance offset value.
</summary>
*/
/**************************************************************************************************************/
void SG_Gen5_DisplayCfgRaw(int32_t cardIndex, int32_t module, int32_t maxchan)
{
int32_t chan = 0;
uint32_t excitationVoltRaw = 0u;
nai_sg_bridge_config_type_t bridgeConfig = 0u;
nai_sg_pga_gain_type_t pgaGain = 0u;
nai_sg_remote_sense_t remoteSense = 0u;
uint32_t nominalResRaw = 0u;
uint32_t gaugeFactorRaw = 0u;
uint32_t poissonRatioRaw = 0u;
uint32_t leadResRaw = 0u;
nai_sg_sample_rate_type_t sampleRate = 0u;
uint32_t strainAlarmLoThresRaw = 0u;
uint32_t strainAlertLoThresRaw = 0u;
uint32_t strainAlertHiThresRaw = 0u;
uint32_t strainAlarmHiThresRaw = 0u;
uint32_t imbalanceOffsetRaw = 0u;
bool_t useInternalBridgeComp = FALSE;
char strBridgeConfig[20] = "";
char strPGAGain[20] = "";
char strRemoteSense[20] = "";
char strSampleRate[20] = "";
char strBridgeComp[20] = "";
printf("\n\nSG Configuration:\n");
printf("Ch Excitation Bridge PGA Remote Nominal Gauge Poisson Lead Sample Strain Alarm Strain Alert Strain Alert Strain Alarm Imbalance Internal \n");
printf(" (V) Configuration Gain Sense Resistance Factor Ratio Resistance Rate Low Threshold Low Threshold High Threshold High Threshold Offset Bridge \n");
printf(" (Ohms) (Ohms) (Hz) (microstrain) (microstrain) (microstrain) (microstrain) Completion\n");
printf("-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------\n");
for (chan = 1; chan <= maxchan; chan++)
{
check_status(naibrd_SG_GetChannelRaw(cardIndex, module, chan, NAI_SG_RAW_CHAN_EXCITATION_VOLT, &excitationVoltRaw));
check_status(naibrd_SG_GetBridgeConfiguration(cardIndex, module, chan, &bridgeConfig));
switch (bridgeConfig)
{
case NAI_SG_BRIDGE_CONFIG_QUARTER_BRIDGE_1:
sprintf(strBridgeConfig, "Quarter Bridge 1");
break;
case NAI_SG_BRIDGE_CONFIG_QUARTER_BRIDGE_2:
sprintf(strBridgeConfig, "Quarter Bridge 2");
break;
case NAI_SG_BRIDGE_CONFIG_HALF_BRIDGE_1:
sprintf(strBridgeConfig, " Half Bridge 1 ");
break;
case NAI_SG_BRIDGE_CONFIG_HALF_BRIDGE_2:
sprintf(strBridgeConfig, " Half Bridge 2 ");
break;
case NAI_SG_BRIDGE_CONFIG_FULL_BRIDGE_1:
sprintf(strBridgeConfig, " Full Bridge 1 ");
break;
case NAI_SG_BRIDGE_CONFIG_FULL_BRIDGE_2:
sprintf(strBridgeConfig, " Full Bridge 2 ");
break;
case NAI_SG_BRIDGE_CONFIG_FULL_BRIDGE_3:
sprintf(strBridgeConfig, " Full Bridge 3 ");
break;
default:
sprintf(strBridgeConfig, " Unknown ");
break;
}
check_status(naibrd_SG_GetPGAGain(cardIndex, module, chan, &pgaGain));
switch (pgaGain)
{
case NAI_SG_PGA_GAIN_1:
sprintf(strPGAGain, " 1 ");
break;
case NAI_SG_PGA_GAIN_2:
sprintf(strPGAGain, " 2 ");
break;
case NAI_SG_PGA_GAIN_4:
sprintf(strPGAGain, " 4 ");
break;
case NAI_SG_PGA_GAIN_8:
sprintf(strPGAGain, " 8 ");
break;
case NAI_SG_PGA_GAIN_16:
sprintf(strPGAGain, " 16 ");
break;
case NAI_SG_PGA_GAIN_32:
sprintf(strPGAGain, " 32 ");
break;
default:
sprintf(strPGAGain, "Unknown");
break;
}
check_status(naibrd_SG_GetRemoteDriveSense(cardIndex, module, chan, &remoteSense));
switch (remoteSense)
{
case SG_GEN5_LOCAL_SENSE:
sprintf(strRemoteSense, " Local ");
break;
case SG_GEN5_REMOTE_SENSE:
sprintf(strRemoteSense, "Remote ");
break;
default:
sprintf(strRemoteSense, "Unknown");
break;
}
check_status(naibrd_SG_GetChannelRaw(cardIndex, module, chan, NAI_SG_RAW_CHAN_NOMINAL_RESISTANCE, &nominalResRaw));
check_status(naibrd_SG_GetChannelRaw(cardIndex, module, chan, NAI_SG_RAW_CHAN_GAUGE_FACTOR, &gaugeFactorRaw));
check_status(naibrd_SG_GetChannelRaw(cardIndex, module, chan, NAI_SG_RAW_CHAN_POISSON_RATIO, &poissonRatioRaw));
check_status(naibrd_SG_GetChannelRaw(cardIndex, module, chan, NAI_SG_RAW_CHAN_LEAD_RESISTANCE, &leadResRaw));
check_status(naibrd_SG_GetSampleRate(cardIndex, module, chan, &sampleRate));
switch (sampleRate)
{
case NAI_SG_SAMPLE_RATE_2P5_SPS:
sprintf(strSampleRate, " 2.5 ");
break;
case NAI_SG_SAMPLE_RATE_5_SPS:
sprintf(strSampleRate, " 5 ");
break;
case NAI_SG_SAMPLE_RATE_10_SPS:
sprintf(strSampleRate, " 10 ");
break;
case NAI_SG_SAMPLE_RATE_16P6666_SPS:
sprintf(strSampleRate, " 16.6666");
break;
case NAI_SG_SAMPLE_RATE_20_SPS:
sprintf(strSampleRate, " 20 ");
break;
case NAI_SG_SAMPLE_RATE_50_SPS:
sprintf(strSampleRate, " 50 ");
break;
case NAI_SG_SAMPLE_RATE_60_SPS:
sprintf(strSampleRate, " 60 ");
break;
case NAI_SG_SAMPLE_RATE_100_SPS:
sprintf(strSampleRate, " 100 ");
break;
case NAI_SG_SAMPLE_RATE_400_SPS:
sprintf(strSampleRate, " 400 ");
break;
case NAI_SG_SAMPLE_RATE_1200_SPS:
sprintf(strSampleRate, " 1200 ");
break;
case NAI_SG_SAMPLE_RATE_2400_SPS:
sprintf(strSampleRate, " 2400 ");
break;
case NAI_SG_SAMPLE_RATE_4800_SPS:
sprintf(strSampleRate, " 4800 ");
break;
case NAI_SG_SAMPLE_RATE_7200_SPS:
sprintf(strSampleRate, " 7200 ");
break;
case NAI_SG_SAMPLE_RATE_14400_SPS:
sprintf(strSampleRate, "14400 ");
break;
case NAI_SG_SAMPLE_RATE_19200_SPS:
sprintf(strSampleRate, "19200 ");
break;
case NAI_SG_SAMPLE_RATE_38400_SPS:
sprintf(strSampleRate, "38400 ");
break;
default:
sprintf(strSampleRate, " Unknown ");
break;
}
check_status(naibrd_SG_GetChannelRaw(cardIndex, module, chan, NAI_SG_RAW_CHAN_STRAIN_ALARM_LO_THRESHOLD, &strainAlarmLoThresRaw));
check_status(naibrd_SG_GetChannelRaw(cardIndex, module, chan, NAI_SG_RAW_CHAN_STRAIN_ALERT_LO_THRESHOLD, &strainAlertLoThresRaw));
check_status(naibrd_SG_GetChannelRaw(cardIndex, module, chan, NAI_SG_RAW_CHAN_STRAIN_ALERT_HI_THRESHOLD, &strainAlertHiThresRaw));
check_status(naibrd_SG_GetChannelRaw(cardIndex, module, chan, NAI_SG_RAW_CHAN_STRAIN_ALARM_HI_THRESHOLD, &strainAlarmHiThresRaw));
check_status(naibrd_SG_GetChannelRaw(cardIndex, module, chan, NAI_SG_RAW_CHAN_IMBALANCE_OFFSET, &imbalanceOffsetRaw));
check_status(naibrd_SG_GetUseInternalBridgeCompletion(cardIndex, module, chan, &useInternalBridgeComp));
switch (useInternalBridgeComp)
{
case FALSE:
sprintf(strBridgeComp, "Disabled");
break;
case TRUE:
sprintf(strBridgeComp, "Enabled ");
break;
default:
sprintf(strBridgeComp, "Unknown ");
break;
}
printf("%2d 0x%08X %s %s %s 0x%08X 0x%08X 0x%08X 0x%08X %s 0x%08X 0x%08X 0x%08X 0x%08X 0x%08X %s\n",
chan, excitationVoltRaw, strBridgeConfig, strPGAGain, strRemoteSense, nominalResRaw, gaugeFactorRaw, poissonRatioRaw, leadResRaw,
strSampleRate, strainAlarmLoThresRaw, strainAlertLoThresRaw, strainAlertHiThresRaw, strainAlarmHiThresRaw, imbalanceOffsetRaw,
strBridgeComp);
}
}