Converting PLC Controller to Cortex Controller