Making an PWM / pulse train while moving

Hi,
I’m trying to make an ouput pulse while the robot is going from waypoint 1 to 2, but it’s important to make constant pulses in defined positions with valves. How can i do it? I’ve tried a thread with digital output HIGH then wait and LOW, but it’s generating pulses in aleatories positions, i couldn’t regulate it. May be i can define every position and send the pulse, but the motion should be continous, i don’t know how to make it.
I have an UR10e.
Thanks.