У меня проблема с моей программой CODESYS. У меня есть три кнопки, которые определены как ввод. Для каждой кнопки хранится номер. Например, число 1. Теперь я создал программу, которая распознает край кнопки и сохраняет числовое значение (2) кнопки в массиве. Если теперь вы нажмете другую кнопку со значением (3), значение также снова будет сохранено в переменной. Две переменные должны быть сложены вместе. 2 + 3 = 23. У меня в программе такая проблема, что если я нажимаю кнопку тестер со значением 2, то получаю 22. Это неправильно. Я думаю проблема из-за помятости кнопки. Обнаружено несколько краев. Вот и хотел решить этот софт технически с опозданием. Ты хоть представляешь, как я могу это запрограммировать?
КОД:
IF (PLC_PRG.calls[5].gpio = TRUE) THEN // edge detection on gpio
IF (counter = 0) THEN // counter for the first value
floorstorage2[0] := PLC_PRG.calls[5].message.floorstore[5]; // save button value in the array to calculate the total
counter := 1;
ELSE
floorstorage2[1] := PLC_PRG.calls[5].message.floorstore[5]; // save button value in the array to calculate the total
counter := 0;
END_IF
END_IF
IF (PLC_PRG.calls[6].gpio = TRUE) THEN // edge detection on gpio
IF (counter = 0) THEN // counter for the first value
floorstorage2[0] := PLC_PRG.calls[6].message.floorstore[6]; // save button value in the array to calculate the total
counter := 1;
ELSE
floorstorage2[1] := PLC_PRG.calls[6].message.floorstore[6]; // save button value in the array to calculate the total
counter := 0;
END_IF
END_IF
IF (PLC_PRG.calls[7].gpio = TRUE) THEN // edge detection on gpio
IF (counter = 0) THEN // counter for the first value
floorstorage2[0] := PLC_PRG.calls[7].message.floorstore[7]; // save button value in the array to calculate the total
counter := 1;
ELSE
floorstorage2[1] := PLC_PRG.calls[7].message.floorstore[7]; // save button value in the array to calculate the total
counter := 0;
END_IF
END_IF
GlobalVar.floorstorage := concat(floorstorage2[0],floorstorage2[1]); // Total of value 1 and value 2 (1 + 2 = 12)