jeudi 19 novembre 2020

Codesys IF statement error with bit operation

The compiler gives an error for the following program. I can't solve it.

This is the Codesys system writing it in ST language. I want to operate a solenoid valve using bit operation.

CanRx := can_getDatabox (CAN_2, 10, ADR(CanRx_data), ADR(CanRxNumBytes));
Rx_test_1 := CanRx_data[1];
Rx_test_2 := CanRx_data[2];
Rx_test_3 := CanRx_data[3];
Rx_test_4 := CanRx_data[4];

IF(Rx_test_1 & 4 = 4)THEN
  out (OUT_1_POH_CL, 1500);
  ELSE IF(Rx_test_1 & 8 = 8)THEN
  out (OUT_1_POH_CL, 0);
END_IF

Compiler error:

 Error: 4011:Callback_MAIN_Task(XX): Type mismatch in parameter 1 of 'AND':Cannot convert 'INT' to 'ANY_BIT'  
 Error: 4024:Callback_MAIN_Task(XX): Expecting END_IF_before"

Aucun commentaire:

Enregistrer un commentaire