Here is an overview of
Q5 (PC817C optocoupler), its operation, notable characteristics, and how it fits in the PC817 family.
All specifications above are taken directly from the PC817/TPC817 datasheet for the C rank. If you want, I can compute a recommended R5 value from your drive voltage and target LED current, and suggest a pull-up value based on your logic thresholds.