Car lamp base key detection.

The diversity of car lamps makes it necessary to design a lamp type depended key in the lamp base so only the exact comparable lamp types are exchangeable.
PGU20 lamp Small lamps use a smaller type of lamp holder e.g. P18 class, a larger lamp use a larger lamp holder e.g. PGxx class.
Basically the outer contour and dimensions per class is equal so a maximum of production efficiency is achievable.
The difference of the lamp type per class is created by the (small) pins on the outside of the lamp base. In the lamp holder is notch designed so the key of the base fits in the lamp holder.
The number of pins, position, and dimensions of each pin is de key of the lamp.
The P18 (see image) is a small lamp holder type with 3 pins under an angle of 120 degrees.
The position of these pins is fixed only the size and the contour (asymmetry) of the pin is different. For the PGxx class two subclasses PG20 and PGU20 are defined, both are also available in a white and a black version.
P18 base PG20 base white PG20 base black PGU20 base black Both types can have a metal ring on top of the base. Basically the classes PG20 and PGU20 are comparable but the PGU20 is equipped with two extra clips (see image, top and bottom).
Take for instance the left top pin of (purple marked circle) PG20 white and black version. The pin of the white version is slightly broader then the same pin of the black version. This small difference gives a different key. Take a closer look and you see the distance is also different!
As already mentioned the PGU20 does have extra clips on top and bottom. Some keys of the PGU20 does have on one side a slightly broader clip then on the other side (not visible in this image). Actually the difference in key can be very small, so an accurate measurement of the pin position and dimensions is necesarry.

PG20 white incl metal ring and axis For a correct assembly of the lamp and the lamp base the correct lamp base has to be feed in the assembly equipment. First the center of the base and the rotation of the base with respect to the camera is measured.
When a good image with a good contrast in the pin area is created the software can detect the position of the pin with respect to the axis of the base. But also the dimensions (width, length) of the pin can be measured. Of course more software is necessary to decode the key even when the base is 180 degrees rotated. The problem in this case is to crease a good image.
The images already given show the base without a clamping device.
This clamping device is necessary for accurate positioning the base so the lamp with the two thin wire can be placed on the right position. The two thin wires of the lamp must fit in the two holes in the base.
P18 on merlon holder small white P18 on merlon holder small black PG20 on merlon holder small white PGU20 on merlon holder small black.jpg The first design is an aluminum clamp equipped with four merlons.
Camera setup: camera on top of the base and a ring led to illuminate the base.
The background of the clamp is also made of aluminum. The result of this illumination at the lamp base shows a bad contrast around the key pins (see images). The P18 base shows a relative good result but the shade on the aluminum background cause some reliable detection problems on ppm level.
For the PGxx bases the local contrast of the pins is very bad so a reliable accurate detection is not achievable. Also the edges of the merlons are too close to the key pins (see images containing several detail).
Detail detection PG20 black Detail detection PGU20 left bot black Detail detection PGU20 right bot black Detail detection PGU20 right top black
Also the edges of the merlons are too close to the key pins (see images containing several detail).

Background improvements

The first improvement is to decrease the size of the merlons so more detecting space is created around the pins. For the P18 base basically an improvement but there are bad areas around the edges of the key pins, so an not reliable detection.
P18 small merlons white metal parts P18 small merlons black PG20 small merlons white PG20 small merlons black PGU20 small merlons black PGU20 small merlons black with ring

For PGxx versions the contrast at the key pin area is much better, almost no shade of the merlons.
But:
The rotation angle of the base of PGxx class is measured detecting the large clips on the right en left side (see images). This rotation detection is not reliable (assembly equipment has to run at ppm level!) because of the dark area at that particular area. Aluminum is a lousy reflector.

So a redesign of the clamp is necessary.

Redesign of the clamp, background improvement

The final version is realized with synthetic material. In this particular case Teflon is used and for positioning 4 round pins are used.
Afterwards it’s an obvious solution, afterwards every thing is simple.
P18 final clamp PGU20 final clamp PG20 final clamp This Teflon background shows much better results, no merlons who create as shadow area, the pins edges are clearly visible and very good to detect.
Using these images a very reliable pin detection is possible and with enough smart software the key of the lamp base can be decoded. Of course when a base with the wrong key is position in the clamp an error is given.

Clue: create a stable and good image with a maximum of contrast around the detection area. And if necessary change the mechanics.
There is a huge difference between mechanical and optical requirements.