Echelon NodeBuilder FX/PL Examples User Manual

Page 32

Advertising
background image

24

Using the NodeBuilder FX/PL Example

13. Repeat steps 11 and 12, but set CP Name to UCPTmaxTemp.

14. Right-click the UFPTtranslator functional profile and select Open. The Modify Functional

Profile Template dialog opens.

15. Add one configuration property of each of the new types to the Mandatory CPs folder. Name

them cpTransInMin and cpTransInMax, respectively.

16. Change the “Applies To” setting so that the cpTransInMin/cpTransInMax properties apply to

the input network variable, and cpTransOutMin/cpTransOutMax to the output network
variable. Click OK.

17. In the Program Interface pane of the Code Wizard, right-click the Translator functional block and

select Refresh from the shortcut menu. The functional block will be refreshed to include the new
configuration properties that you added to the functional profile.

18. Assign default values to each new configuration property on the Translator functional block. The

following values will cause the functional block to behave just as it did after Step 5: Implementing
a Simple Type Translator
.

cpTransInMin 0
cpTransInMax
3000
cpTransOutMin
0
cpTransOutMax
10000

This step sets defaults for the configuration properties on this device only. This is different than
setting the defaults in the functional profile, which will set the defaults for all functional blocks
created from that functional profile unless they are otherwise specified.

19. Click Generate and Close.

20. Click Yes to generate resource files.

21. Open Translator.nc from the Source Files folder and add the following code in bold to the

TranslatorprocessNV()

function:

void TranslatorprocessNV(void)
{
long lValue;

// get scaled value:

lValue = Translator::nviTempP;

// limit temperature to supported range 0-30.00 Celcius

lValue = max(Translator::nviTempP::cpTransInMin,

min(lValue,

Translator::nviTempP::cpTransInMax));

Translator::nvoPercentage = (short)muldiv(2L*lValue,

Translator::nvoPercentage::cpTransOutMax,

Translator::nviTempP::cpTransInMax);

This code takes a SNVT_temp_p value, which has a range of -273.17 to 327.66 in steps of 0.01,
and converts it into a SNVT_lev_percent value, which has a range of 163.84% to +163.83%
in steps of 0.005%. See the SNVT and SCPT Master List for more information.

This particular application limits the output signal range to between 0 and 100%. It also limits the
range of the valid input values from 0 to 30

° Celsius for room temperature values (for example,

30

° C or more results in a 100% output signal; 0° C or less results in a 0% output signal.

In this step, all the above limits are hardcoded. Step 6 shows how to make these limits
changeable.

With hard-coded factors, and using unscaled network variable values, the formula for conversion
is:

percentage = (tempP * 2) * ( 100 / 30 ) = tempP * 20 / 3

Advertising