This is the code from the "Learning Motion Control and IO with Beckhoff TwinCAT PLCs" on youtube. It can be found here: https://www.youtube.com/playlist?list=PLE1CU6EebvTD29gsHo1djsKU7J5Dtp0Bn