Technical Reference > CtAPI Functions > Function Reference > ctRawToEng


Converts the raw I/O Device scale variable into Engineering scale. This is not necessary for the Tag functions as CitectSCADA will do the scaling. Scaling is not necessary for digitals, strings or if no scaling occurs between the values in the I/O Device and the Engineering values. You need to know the scaling for each variables as specified in the CitectSCADA Variable Tags table.


ctRawToEng(pResult, dValue, pScale, dwMode)


Type: Double
Input/output: Output
Description: The resulting raw scaled variable.


Type: Double
Input/output: Input
Description: The engineering value to scale.


Input/output: Input
Description: The scaling properties of the variable.


Type: Dword
Input/output: Input
Description: The mode of the scaling. The following modes are supported:

CT_SCALE_RANGE_CHECK - Range check the result. If the variable is out of range then generate an error. The pResult still contains the raw scaled value.

CT_SCALE_CLAMP_LIMIT - Clamp limit to max or minimum scales. If the result is out of scale then set result to minimum or maximum scale (which ever is closest). No error is generated if the scale is clamped. Cannot be used with CT_SCALE_RANGE_CHECK or CT_SCALE_NOISE_FACTOR options.

CT_SCALE_NOISE_FACTOR - Allow noise factor for range check on limits. If the variable is our of range by less than 0.1 % then a range error is not generated.

Return Value

TRUE if successful, otherwise FALSE. Use GetLastError() to get extended error information.

Related Functions

ctOpen, ctEngToRaw


// SP123 is type INTEGER and has raw scale 0 to 32000 and Eng scale 
0 to 100
HANDLE hList = ctListNew(s_hCTAPI, 0);
HANDLE hTag = ctListAddEx(hList, "SP123", TRUE, 500, -1);
CTSCALE Scale = { 0.0, 32000.0, 0.0, 100.0};
CHAR valueBuf[256] = {0};
double dRawValue = 0.0;
double dSetPoint = 0.0;
ctListRead(hList, NULL);
ctListData(hTag, valueBuf, sizeof(valueBuf), 0);
dRawValue = strtod(valueBuf, NULL);
ctEngToRaw(&dSetPoint, dRawValue, &Scale, CT_SCALE_RANGE_CHECK);
// dSetPoint now contains the Engineering scaled setpoint.