What is inside the CN0569

How angles are measured

How the room light is filtered out
Thrash detection

- 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.
- 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.

- 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 baseline
- 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

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.

| 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 |
| 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 |
| 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 |
- 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
| Class | Detected | Peak over baseline |
| Glass | 20/20 | 458 to 617 |
| Plastic | 20/20 | 305 to 543 |
Lights
Conclusions
- 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.