Contec CONPROSYS nano CPSN-PCB271-S1-041 Reference Manual page 132

Table of Contents

Advertisement

 Sample
When repeating counting up of Counter Input Data (CH0).
Internal I/O Mapping
Variable declaration
uiState: UINT := 0;
dwCntValue: DWORD;
wMatchStatus: BYTE;
Program
CASE uiState OF
0:
CNT_COMP_SET := 100;
CNT_VALUE_SET := 0;
CNT_VALUE_SET_FLAG := 16#01;
uiState := 1;
1:
CNT_VALUE_SET_FLAG := 16#00;
CNT_START := 16#01;
uiState := 2;
2:
dwCntValue := CNT_VALUE;
wMatchStatus := CNT_MATCH_STATUS AND 16#01;
IF wMatchStatus <> 0 THEN
CNT_MATCH_RESET := CNT_MATCH_RESET OR 16#01;
CNT_VALUE_SET_FLAG := CNT_VALUE_SET_FLAG OR 16#01;
uiState := 3;
END_IF
3:
CNT_MATCH_RESET := CNT_MATCH_RESET AND 16#FE;
CNT_VALUE_SET_FLAG := CNT_VALUE_SET_FLAG AND 16#FE;
uiState := 2;
END_CASE
Programing with CODESYS
CPSN-PCB271-S1-041 Reference Manual (Software)
— 132 —

Advertisement

Table of Contents
loading

Table of Contents