Miniature photoelectric sensor detects carton position during packaging operations