Back to projects

Card Analysis and Robotic Dispensing System

A robot that deals and sorts cards, reaching 98 percent suit sorting accuracy against a 95 percent target.

Overview

Context
For MTE 100, the first-year Mechatronics design course, a team of four built a VEX IQ robot to make card games fairer. It had to deal to a chosen number of players seated evenly in a circle, shuffle, and sort a 52-card deck by suit, with at most 2 sorting errors and 2 misfires per deck (95 percent).
Action
I worked on the mechanical design, built most of the chassis and the custom color-coded deck, and wrote the suit sorting code, which reads a color patch on each card with an optical sensor under the tray.
Result
The robot met every criterion and sorted with 98 percent accuracy at the demo, against a 95 percent target.
Learning
Many of the hardest problems came from the cards, not the robot. Card weight, surface finish, and color all changed how the robot behaved, so I now test with the real materials as early as possible.

What I did

  • Worked on mechanical design and co-wrote the IMU-based PID rotation for a robot that deals and sorts cards
  • Wrote C++ hue-based suit classification, tuning hue ranges to fix blue and red misreads
  • Co-built the chassis, sensor mount, and color-coded deck, iterating on jams and double dealing
  • Reached 98 percent suit sorting accuracy at the demo against a 95 percent target

Photos

Engineering decisions

  • A chassis built to turn, not drive. The robot only needs to rotate in place between players, so the chassis is a rigid rectangle with the drive wheels at the rear and omni wheels at the front. A turret layout was considered, but the rectangle was simpler to build and rotated with enough control.
  • Angled tray. A flat tray worked when dealing many cards quickly, but dealing a single card often pulled the next one out with it. Tilting the whole tray upward lets gravity push back against the friction between cards.
  • Flywheel with backspin. A rubber wheel under the tray pulls the bottom card out, then spins backward to pull any half-ejected card back in. A chain drive moved the motor to the top of the tray, because the first version, with the motor under the tray, left no room for the optical sensor.
  • A weighted arm on the stack. Near the end of a deck, there was not enough weight left for the last cards to grip the wheel. A gravity arm now presses on the stack.
  • Detecting an empty tray. A distance sensor was considered but was not accurate enough. A piece of cyan plastic on the arm falls over the optical sensor when the tray is empty, and cyan is the color the sensor reads most reliably, so one sensor detects both the suit and an empty tray.
  • Hue ranges instead of built-in colors. I classified suits with hue ranges I could tune, instead of the sensor's built-in color names, which gave me control when colors were misread.
  • PID rotation. A simple turn-until-heading loop overshot, which mixed up the piles. A PID controller on the gyro heading reduced overshoot so each player's pile stayed separate.

Mistakes and fixes

  • The wrong deck, twice. The first deck was a used casino deck with punched holes, some right where the color patches had to go. The second deck was lighter and more slippery and caused double dealing. A heavier, less slippery deck, plus cleaning the flywheel regularly, fixed dispensing.
  • Blue read as red. Blue patches on the diamond cards were often read as red, because light reflecting off the card shifted the reading. I widened the hue ranges and made the blue patches larger so enough blue light reached the sensor.
  • Jams when reversing. Cards caught on the front rod when the flywheel pulled them back. A strip of clear tape over the rod and sensor formed a ramp that stopped the jams.
  • A drooping shaft. Late in testing, the flywheel shaft sagged because a square shaft sat in a round hole. Extra washers in the right positions fixed it.

What I would change

  • Put the larger sprocket on the flywheel shaft for finer control of each card
  • Use a wider, grippier flywheel to reduce slipping and double dealing
  • Center the pivot of the chassis so the robot turns faster and needs less table space

Tools

  • C++
  • VEX IQ
  • IMU-based PID
  • Optical sensor