1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 | VAR stConfig : MNR.stCounter2Config; J : INT; awSrvAnwser : ARRAY [1..2] OF WORD; uiMode : UINT; uiDirection : UINT; uiActiveEdge : UINT; uiCapture : UINT; END_VAR IsGet FOR J := 1 TO 2 DO awSrvAnwser[J] := MEM.PackBytesToWord(THIS^._abyIntRxBuf[1], THIS^._abyIntRxBuf[0]); END_FOR /// COUNTER2 Configuration; /// Mode; /// * Off, /// * Pulse counting, /// * Quadrature encoder, /// Direction (only for pulse counting mode): /// * Up /// * [FUTURE] external control, low/high = up/down /// Active Edge (only for pulse counting mode): /// * Rising /// * Falling /// * Both /// CAPTURE function active edge: /// * Disabled /// * [FUTURE] rising /// * [FUTURE] falling /// * [FUTURE] both eCounterMode.Off : stConfig.eMode := eCounterMode.Off; //0x00 eCounterMode.QuadratureEncoder : stConfig.eMode := eCounterMode.QuadratureEncoder; //0x02 ELSE // Weird value returns? stConfig.eMode := eCounterMode.Off; END_CASE eCounterDirection.Up : stConfig.eDirection := eCounterDirection.Up; //0x00 uiActiveEdge := BOOL_TO_UINT(awSrvAnwser[2].6) + BOOL_TO_UINT(awSrvAnwser[2].7); CASE uiActiveEdge OF eCounterActiveEdge.Falling : stConfig.eActiveEdge := eCounterActiveEdge.Falling; //0x01 uiCapture := BOOL_TO_UINT(awSrvAnwser[2].8) + BOOL_TO_UINT(awSrvAnwser[2].9); CASE uiCapture OF eCounterCapture.Rising : stConfig.eCapture := eCounterCapture.Rising; //0x01 eCounterCapture.Both : stConfig.eCapture := eCounterCapture.Both; //0x02 stConfig.eCapture := eCounterCapture.Disabled; //0x00 // update classic status; //Counter2Config := stConfig; |