In this post, I will write about the CN0569 from Analog Devices is a gesture sensing board based on two ADPD2140 light angle sensors. In this project, I use it for a quite simple job: it tells the Nicla Vision that something is falling down the chute, so the accelerometer and the microphone are ready when the item hits the plate.
In this post I explain how the board works, how I use it today, and the tests I run to get a better knowledged of the sensor.
What is inside the CN0569
The EVAL-CN0569-PMDZ is a 68.58 × 20.32 mm board with a 6-pin Pmod connector, and it has three main parts (see Analog Devices CN0569 user guide):

- One lamp.A single infrared LED at 850 nm. According to the circuit note, it sits 6 mm from the first sensor and 19 mm from the second one.
- Two sensors. Two ADPD2140 infrared light angle sensors. Each sensor is made of four photodiodes (two horizontal and two vertical)
- One brain. The ADPD1080 photometric front end, which drives the LED, reads the photodiodes, delivers a 16-bit result per channel and talks I²C.
The evaluation kit comes with two small 3D-printed optical baffles, one for each sensor.
How angles are measured

Inside an ADPD2140 there are four photodiodes with a common cathode, two for the horizontal axis (XL and XR) and two for the vertical axis (YT and YB), under a small aperture (see Analog Devices, CN0569 circuit note). When the light comes straight from the front, the spot falls in the middle and XL and XR get the same current. When it comes from the left, the light passes the aperture at an angle and the spot lands more on XR. It's the trick of a sundial, but with photodiodes instead of a stick.
The angle comes from a ratio of the currents, something like (XR − XL) / (XR + XL). This is a simplified version, and ADI's circuit note gives the exact equations. The ratio is meaningful here because the brightness of the object cancels out: a white carton and a dark bottle in the same place give different totals, but the same ratio.
Two sensors at a known distance give two angles to the same object, and that is enough to triangulate its position.
How the room light is filtered out
The ADPD1080 integrates the photodiode current while the LED is on, then switches the LED off and integrates again for the same time with the opposite sign. The ambient light is in both halves, so it cancels. The LED reflection is only in the first half, so it stays. The pulses are repeated and summed before the conversion, and the board delivers up to 512 samples per second.
This doesn't make the sensor immune to a window full of sun. Light that changes fast, or light strong enough to saturate the photodiodes, still creates issues. But a normal kitchen lamp should not be a problem.
Thrash detection
The board sits in the black sensor case, screwed on the inside of the clear lid that is also the back wall of the chute. It looks across the chute, about 10 cm above the gate plate.

At the moment, the firmware uses only a small part of the board:
- Time slot A sums all the photodiodes into one 16-bit value.
- The ADPD1080 produces 500 samples per second into its FIFO. The Nicla empties the FIFO every 10 ms (about 5 samples per read) and compares each sample with a slow running baseline.
- When an item passes, it reflects more light, the value goes over the baseline plus a threshold, and the capture of the impact is armed.
Thsi means, at the moment, I'm using a gesture sensor as an expensive light barrier. But it has the advantage that it doesn't need a reflector on the other side and it robust enough to ignore most of the room light. Furthemore, I could use the sensor in the future to add some features like
- the same item knocks differently depending on where it hits. If the sensor can give me the angles where the item crosses the beam, they also tell me roughly where it lands, and that position can become two more features for the classifier.
- The time an item stays in front of the sensor, together with the time from detection to impact, gives an estimate of its speed and size. A bottle cap and a jar should not need the microphone to be told apart.
- The total of the photodiodes, corrected for distance, is a rough reflectivity at 850 nm. Paper is bright, while glass and dark plastic are dim. It's one more number that doesn't depend on the knock.
- Time slot B (the time in the acquisition frame when the LED is off) cna be used to measure ambient light. If it changes too fast, the firmware can be more careful.
- A swipe in front of the lid could mean "you sorted it wrong", and the bin could keep that sample for the next training.
The whole decision process is shown in the diagram below.

The sensor never reads zero. Even with nothing in the beam, some infrared comes back from the walls and the lid, a little LED light leaks straight to the photodiodes, and there is an electronic offset. This empty-beam reading is the baseline, and it moves slowly when a lamp is switched on, when the cover gets dirty or when the board warms up. So the firmware keeps updating it: every sample moves the baseline 1 % of the way towards the new reading, which at 500 samples per second follows a slow change in about 0.2 s. A falling item passes too fast to change baseline significantly.
The decision takes four steps:
- For each sample the firmware computes level = raw − baseline, which is how much more light comes back than with the beam empty.
- When the level goes over a threshold (300 counts), something is in the beam. The firmware counts it, arms the impact capture and freezes the baseline, so the item doesn't become part of the background.
- The beam is clear again only when the level drops below half of the threshold. The gap between the two lines is a hysteresis, and it stops one wobbly item from being counted twice.
- The highest level during the pass says how much margin there was. About twice the threshold is comfortable. Just over 300 means the next item of the same kind could be missed.
The other knobs only change how much light goes into each sample: the LED current step and the number of pulses summed per sample. More light makes the bump of the item bigger, but it makes the baseline bigger too, and the sum must stay below 65535 or the ADC saturates.
The baseline
On the bench, in open air, the empty-beam baseline was about 300 counts. With the board behind the 3 mm polycarbonate lid and the same settings, it went to about 19,400. The lid is the brightest object the sensor sees, because:
- Polycarbonate reflects about 5 % of the 850 nm light at normal incidence. With two surfaces, about one tenth of the LED light comes back, and it comes back from a few millimetres away.
- The light that an item sends back falls roughly with the square of the distance. An item at 8 cm is about 20 to 30 times farther than the lid, so even a white carton sends back a small fraction of what the lid does.
The result is that the item's bump of a few hundred counts sits on top of 20,000 counts that do nothing useful. They use most of the available range of the 16-bit ADC, and they bring their own noise.
Detection distance
I run a simple test to determine the optmial combination of LED current (5, 8, 10, 12 and 15) and pulses per sample (8, 16, 32 and 64). With the sensor mounted behind the lid, I run throuhg these steps
- watit for the baseline to stabilize
- slowly bring an item towards the sensor
- write down the distance at which it detects it
I tried four materials: cardboard, plastic, glass and foam. Foam is never detected, so it has not been included in the detection distance table.

With 32 and 64 pulses the sketch never got to the item: the lid alone filled the 16-bit range with the beam still empty, in every run. The distance table leaves those settings out.

Detection distance, in cm:
| LED step | Pulses | Cardbiard | Plastic | Glass |
| 5 | 8 | 6 | 7 | 9 |
| 5 | 16 | 8 | 6 | 6 |
| 8 | 8 | 7 | 6 | 8 |
| 8 | 16 | 7 | 10 | 6 |
| 10 | 8 | 5 | 8 | 7 |
| 10 | 16 | Saturated | 11 | 10 |
| 12 | 8 | 5 | 8 | 6 |
| 15 | 8 | 6 | 9 | 8 |
Empty-beam baseline, raw counts (the range covers the four runs):
| LED step | 8 pulses | 16 pulses | 32 pulses | 64 pulses |
| 5 | 19,356 to 19,437 | 38,854 to 43,747 | 65,535 | 65,535 |
| 8 | 26,419 to 29,252 | 52,774 to 53,864 | 65,535 | 65,535 |
| 10 | 30,661 to 32,118 | 61,203 to 65,535 | 65,535 | 65,535 |
| 12 | 34,600 to 44,274 | 65,535 | 65,535 | 65,535 |
| 15 | 40,277 to 41,386 | 65,535 | 65,535 | 65,535 |
Peak level at detection, counts over the baseline (threshold 300):
| LED step | Pulses | Cardboard | Plastic | Glass | Foam |
| 5 | 8 | 995 | 301 | 583 | 687 |
| 5 | 16 | 376 | 903 | 327 | 311 |
| 8 | 8 | 522 | 828 | 487 | 300 |
| 8 | 16 | 529 | 309 | 499 | 796 |
| 10 | 8 | 680 | 449 | 548 | 501 |
| 10 | 16 | Saturated | 635 | 760 | 532 |
| 12 | 8 | 562 | 504 | 434 | 1428 |
| 15 | 8 | 534 | 575 | 434 | 3428 |
A note on the last table: the sketch stops looking at the first sample over the threshold, so the peak says how far past the line the item got in that moment, and it depends on how fast the item came in. It is not a measure of range.
What I take from the numbers:
- The detection distance is 5 to 11 cm, against the "up to 20 cm" of a hand in open air. The best setting was step 10 with 16 pulses (11 cm for the plastic, 10 cm for the glass), but the cardboard run saturated at that setting, so it has no margin. The second option is step 8 and 16 pulses.
- More light doesn't give a longer range. Doubling the pulses doubles the baseline, and so does going from step 5 to step 15, but the distance moves by a couple of centimetres at most, and not always in the right direction, because the lid's reflection grows as fast as the item's.
- Glass and plastic did as well as cardboard, which I didn't expect. These are only four samples moved by hand, though, so I'd wait for the drop test before drawing conclusions on the classes.
- The chute is about 14 cm wide, so an item that falls along the far wall can pass unseen. More current won't close that gap. The solution is to drill 30 × 10 mm window in the lid, but this go against all my considerations about the protection provided by the lid itself
Drop test
I tried to drop each of the three trash classes (glass, plastic, paper) twenty time. For each drop I recorded the peak over the baseline. (Note that LED changes to red when item is detected)
Results are as follow
| Class | Detected | Peak over baseline |
| Glass | 20/20 | 458 to 617 |
| Plastic | 20/20 | 305 to 543 |
Lights
I run drop test with the IR sensor reading the light from LED lamp, in the dark and with a fluorescent lamp. In all the three scenarios, the baseline algorithm was enough to filter out the effects of the environment light and itmes were all successfully detected
Conclusions
The CN0569 board was designed to detect a hand in open air, whereas, in my case, it is mounted in a box behind a plastic window. Despite that, the sensor looks to behave quite well for this application:
- LED light traveling through the clear lid raises the baseline, but detection is still reliable. So I don't think it will be necessart to drill a window in the clear lid.
- Black items (like the foam I tested with) absorb near infrared, so it may give almost no reflection.
- The opposite wall of the chute is about 14 cm away, so it's too far to interfere with object detection.
- An item very close to the lid can saturate the ADC.
- The sensor is about 4 cm below the rim of the chute. An item released at the rim reaches it at about 1 m/s, and one dropped from 20 cm above the bin at about 2 m/s. A 6 cm bottle then stays in front of the board for 30 to 60 ms, or 15 to 30 samples, and a bottle cap for half of that. It should be enough, but at the moment I didn't test with small items.
- Condensation or a drop of yogurt on the lid changes the baseline. The firmware follows slow drifts only when nothing is in front of the sensor, but sooner or later the window will need a cloth.
What's next?
I would like to thank element14 and Analog Devices for the kit and for the documentation of the CN0569. Soon, I will start experimenting with the ADXL372.
Thanks for reading and see you soon!