Micro800™ 4 ch universal thermistor input module – Spectrum Controls 2080sc-NTC User Manual

Page 21

Advertising
background image

Micro800™ 4 Ch Universal Thermistor Input Module

21

Publication 0100198-01 Rev. A


(* Translate channel configurations. *)

FOR chan_idx := 0 TO 3 BY 1 DO

(* Copy the 3 word parameters. *)

FOR i := 0 TO 2 BY 1 DO

CASE chan_idx OF

0: tmp_result :=

ANY_TO_DINT(S1_CFG_CH_0_Parms[i]);

1: tmp_result :=

ANY_TO_DINT(S1_CFG_CH_1_Parms[i]);

2: tmp_result :=

ANY_TO_DINT(S1_CFG_CH_2_Parms[i]);

3: tmp_result :=

ANY_TO_DINT(S1_CFG_CH_3_Parms[i]);

END_CASE;

raw_config_array[idx]

:=

ANY_TO_USINT(tmp_result); (* Low byte *)

tmp_result := SHR(tmp_result, 8);

raw_config_array[idx+1]

:=

ANY_TO_USINT(tmp_result); (* High byte *)

idx := idx + 2;

(* Skip to next word

offset *)

END_FOR;

(* Copy the 3 string parameters. *)

FOR i := 0 TO 2 BY 1 DO

CASE chan_idx OF

0: tmp_string := S1_CFG_CH_0_string[i];

1: tmp_string := S1_CFG_CH_1_string[i];

2: tmp_string := S1_CFG_CH_2_string[i];

3: tmp_string := S1_CFG_CH_3_string[i];

END_CASE;

(* Transfer the string into the config array *)

(* Only 16 chars will fit into chan config. *)

FOR str_idx := 1 TO 16 BY 1 DO

raw_config_array[idx] :=

ANY_TO_USINT(ASCII(tmp_string, str_idx));

idx := idx + 1;

END_FOR;

END_FOR;

END_FOR;

ELSIF (S1_CFG_Trigger = 0 AND

previous_trigger = 0 AND

DelayTimer.Q = TRUE AND

WriteConfig.Sts = 1) THEN

CfgEnableWrite := FALSE;

CfgTimerEnable := FALSE; (* Reset timer *)

END_IF;

(* Override the config write for an amount of time defined by STARTUP_TIME *)
(* This is a one-time startup event *)


WriteConfig(CfgEnableWrite, Slot_ID, OFFSET_CFG, CFG_N_BYTES,
raw_config_array);

(*********************************************)
(* INPUTS *)
(*********************************************)
WriteInputLatch(true, Slot_ID, OFFSET_INP_LATCH, 1, InputLatch_val);
ReadInputs(true, Slot_ID, OFFSET_INPUT, INPUT_N_BYTES, raw_input_array);
idx := 0;

FOR i := 0 TO 3 BY 1 DO

Advertising