Decoupling capacitors upsetting 74HC74 output
Your divider pull-up on the output of the LM311 is only providing a logic high of
$$ V_{oh} = 12 \dfrac{4.7}{10+4.7} = 3.84 V $$

A more suitable value forR7 in the EIA12 series would be 6k8, which would yield a output high as,

$$ V_{oh} = 12 \dfrac{6.8}{10+6.8} = 4.86 V $$