With laser and photoelectric tube as laser photoelectric sensor, when a workpiece passes through the light area the light will be blocked by the workpiece and the photoelectric tube will emit a pulse signal, the counting for the passing workpiece just is the workpiece number. An on-line type automatic photoelectric counter is developed based on this photoelectric detection method. The laser light source is narrowed and collimated, thus solving the difficulty in counting for small workpiece. The experiments show that the instrument has the advantages of precision counting, fast detection speed and strong practicability.