This was my portion of the design of an assembly to sort pills of two sizes and four colors as part of a final course project. My subsystem focused on color detection, assuming sizes have already been separated, and subsequent sorting
My first ideas were to create either a multi axis gantry system, or a wheel of some kind that scans each pill and then rotates a slide to get the pill to its correct container.
Eventually, I decided that a servo motor rotating a platform with a solenoid would be both simple and fun to work with. This video shows the very first version of this design with the solenoid controlled by plugging in the power supply with a protection diode across the terminals.
Controlling the solenoid from the STM32 Nucleo was surprisingly difficult. I had never used transistors or MOSFETs before this and I also was using random parts I could scavenge from the lab, which added complexity to the circuit. A proper logic level N-channel MOSFET would have made this quite simple but since I didn't have one, I had to drive a transistor to power the MOSFET from the 12V power supply, and the MOSFET gate voltage was 10V so I had to create a voltage divider as well. I needed a diode to protect my circuit from any back EMF from the solenoid. This took about six hours to figure out and then another 3 hours to turn it into a soldered assembly without making any mistakes.
I created this rough schematic to power every team member's subassembly. Though, this was before I knew the details of the solenoid wiring. A lot of the components included here were not in the final design. I really just wanted to show off my colorful diagram.
The initial sensor choice was the (left) APDS9960. I quickly found out that this I2C sensor was very sensitive to light and tried to make mechanical modifications to include some external LEDs in the measurement chamber. This was not working consistently so after lots of of trial and error, I switched to the TCS34725 (right) which has an onboard LED and overall better filtering.
This was also my first time using I2C so getting the communication working took lots of time reading through datasheets.
6th iteration of measurement stage
Cutout on 3D printed stage for LED and sensor
Bottom view of stage with sensor
The pictures at the right show the final assembly of one side of the color subsystem. The funnel was later added to locate the big pills coming in from the rest of the system.
When designing, I was very conscious of manufacturing and assembly.
DFM: Designed to include no or minimal 3D printed supports.
DFA: Made sure geometry was easy to orient to install threaded inserts. Included adjustable slots for precise components. Ensured adequate room was left to access all fasteners and considered order of assembly.
Problem: Small pills would sometimes land tilted due to the cutout for the sensor, then get launched away from the cup.
Solution: Funny enough, a nice clear piece of tape over the hole did the trick, though some code values had to be changed due to the tape interfering with measurements on the "clear" channel needed to detect black colored pills.
Problem: Upgrading from the breadboard to the soldered PCB resulted in the solenoid actuating faster, thus launching the pill with more velocity and causing the pill to overshoot the cup.
Solution: Reprinted the cups 15 mm taller to prevent any wildly shot pills and modified the small pill measurement stage to direct pills downwards.
Problem: Small pills would not arrive from previous subsystem in a controlled manner
Solution: I tried the funnel but wasn't having much success. A teammate suggested rotating the whole subsystem 90 degrees so the pill would slide in on its long axis and this ended up working extremely well.
Problem: Occasionally, a pill would get stuck in a weird position but still get sensed by the color sensor
Solution: Programmed the system to actuate the solenoid twice. The first time was usually enough to dislodge the stuck pill, the second fire would shoot it correctly.