Supported platforms: CODESYS 2.3, CODESYS 3.5

ADC_To_Ohm (FUN)

Description

This function calculates the resistance (Ohm) value with given ADC values of the sensor value and reference input value. The returned value (WORD) is presented with no decimals (1000 = 1kOhm).

 

The hardware specific library provides global (enumeration) G_AIType for value scaling.

 

Limitations

This function will work only with:

  • voltage input with a pull-up resistor

  • current input with 220ohm pull-down resistor

 

The used input shall be configured as the selected type.

                

 

Inputs

CODESYS 2.3CODESYS 2.3

Input variable name

Data type

Range

Description

i_ADCValue

WORD

0..65535

AD converter value to be scaled

i_AIType

BYTE

0..G_ADScaleArrMax

Index number that defines the AI input type and range

i_ReferenceADCValue

WORD

0..65535

AD converter value of the reference voltage measurement (=supply of the sensor)

i_ReferenceAIType

BYTE

0..G_ADScaleArrMax

Index number that defines the reference input type and range

 

 

CODESYS 3.5CODESYS 3.5

Input variable name

Data type

Range

Description

i_ADCValue

WORD

0..65535

AD converter value to be scaled

i_AIType

ADData

 

Structure that defines the AI input type and range

i_ReferenceADCValue

WORD

0..65535

AD converter value of the reference voltage measurement (=supply of the sensor)

i_ReferenceAIType

ADData

 

Structure that defines the reference input type and range

 

 

Return value

Return value

Data type

Range

Description

 

WORD

0..65535

Scaled sensor resistance value

Example code

See also

 

 

Source file Topic000246.htm

Last updated 24-Apr-2025