Model railroad crossing

Thanks for all your help. After trying all your suggestions I removed the the PLC and hard wired the circuit. The system works much better, there must have been a spike coming from the PLC.