franko,

some points:
- cokekid seems to be right. try to increase the pull-up to 10K.
-
Problems are,it stops the Hmtr at three pulses instead of four and if the beam isn't broken in quick succession,hmtr continues to run no matter how many times beam is broken.
seems to be your PULSIN DATAPLS,1,i is the culprit. if theres anyway you can monitor your WORD "i", verify it. If you have a serial port, plug it. otherwise you'll be convinced of what you will find out. then recode. it's my style of debugging.