Problems with VM147

Have some problems with the VM147 counter module. It,s connected to a pcb with a lot of electromechanical relays and it seems that the relays interfere with the counter. It counts when it’s not suppose to and so on. I tried to use a optocoupler to isolate the counter input. A limit switch feeds the optocoupler with +12v and the opto grounds the counter input. But I still have problems with interference. Are there a good way to isolate the counter from the other components on the pcb. Some kind of circuit maybe.