When I was set the task of developing a project for the end of robotics, I reallly wanted to do something that was relevant to me. As I have a great interest in playing cards I decided to try and develop a card dealer that could work for three players. The game of choice that I wanted the car dealer to deal would be Texas Hold’em. For anyone not familer with the game, here you go: http://www.texasholdem-poker.com/beginnersintro
So after deciding on the project I had to come up with a design that would work for the resouces and technology that I had available to me:
- DC Motor
- Stepper Motor
- Servo
- Distance Sensor
- dsPic
My thinking behind it was to try and keep it as simple as possible(not to over complicate things) but it would still work efficiently.
Design Proocess.
So after looking at the Motors available to me, I decided to go with the Stepper Motor to rotate the dealer to the approiate angle. I decided on this motor because it is quite easy to motor the motor to precise angles, also the servo can do this with possibly greater speed but after looking up the both motors datasheet, the stepper motor prevailed due to its greater torque, which would b a valuable commodity when having to rotate the base.
Next was probably the hardest part how to actually despence the cards to the players. After alot of thinking and keeping in mind to try and keep it simple, I came up with just two rollers driven by a DC motor that would be continuously going so all you would have to do is to feed a card into it and hopefully it would shoot the card out.
So that only left me with actually feeding the card into the rollers. I decided to do this with another DC motor by pulseing it on and off at a given time. This motor would be connected to a roller hovering above the cards.
I decided to make the structure out of balsa wood due to its light weight. I got a bag of it from an Arts and Craft shop. It would be joined together using a hot glue gun.
So with the structure nailed down albiet only in the head I decided to move on to the code.
Code
Before I started to write the code for this, I needed to decided on what angles I wanted the stepper to move to. The full spectrum of movement I retriscted to 180 degrees.Starting position at 0 degrees.
So with three players playing,I put the:
- Players 60 degrees apart.( three players).Player 1 @ 60 dergees ,Player 2 @ 120 dergrees, Player 3 @ 180 degrees.
- The burn cards to be dropped at 45 degrees.
- Flops cards to be dropped at 60, 70 and 80 degrees.
- Turn card to be dropped at 85 degrees.
- River card to be dropped at 95 degrees.
So when the stepper motor is at each of these points, the DC motor will pulse and drive a card into the front rollers.
Below is my final code used:
// // dsPIC30F4011 Card Dealer Mini Project // Written by James McMahon // Last updated 10-12-2013 // #include <xc.h> #include <libpic30.h> // Configuration settings _FOSC(CSW_FSCM_OFF & FRC_PLL16); // Fosc=16x7.5MHz, Fcy=30MHz _FWDT(WDT_OFF); // Watchdog timer off _FBORPOR(MCLR_DIS); // Disable reset pin // Function prototypes void step_forward(); void step_back(); void steps(int n); // global variables double step_angle; long step_time; int main() { // Make all port D & B pins outputs. TRISD = 0; TRISB = 0; // Stepper properties step_time = 300000L; // 10ms step_angle = 0.17578125; // 360.0 divided by 2048 while(1) { steps(60 / step_angle); __delay32(30000000); // step 1..player 1 1st card LATB=0b0001;__delay32(20000000); LATB=0b0000;__delay32(30000000); steps(60 / step_angle); __delay32(30000000); // step 2..player 2 1st card LATB=0b0001;__delay32(20000000); LATB=0b0000;__delay32(30000000); steps(60 / step_angle); __delay32(30000000); // step 3..player 3 1st card LATB=0b0001;__delay32(20000000); LATB=0b0000;__delay32(30000000); steps(-180 / step_angle); __delay32(30000000); // step 4 ..return to the start LATB=0b0000;__delay32(30000000); steps(60 / step_angle); __delay32(30000000); // step 5..player 1 2nd card LATB=0b0001;__delay32(20000000); LATB=0b0000;__delay32(30000000); steps(60 / step_angle); __delay32(30000000); // step 6..player 2 2st card LATB=0b0001;__delay32(20000000); LATB=0b0000;__delay32(30000000); steps(60 / step_angle); __delay32(30000000); // step 7..player 3 2nd card LATB=0b0001;__delay32(20000000); LATB=0b0000;__delay32(30000000); steps(-180 / step_angle); // step 8..return to the start piont steps(45 / step_angle); __delay32(30000000); // step 9..burn 1st card LATB=0b0001;__delay32(20000000); LATB=0b0000;__delay32(30000000); steps(15 / step_angle); __delay32(30000000); // step 10..flop 1st card LATB=0b0001;__delay32(20000000); LATB=0b0000;__delay32(30000000); steps(10/ step_angle); __delay32(30000000); // step 11..flop 2nd card LATB=0b0001;__delay32(20000000); LATB=0b0000;__delay32(30000000); steps(10/ step_angle); __delay32(30000000); // step 12..flop 3rd card LATB=0b0001;__delay32(20000000); LATB=0b0000;__delay32(30000000); steps(-35 / step_angle); __delay32(30000000); // step 13..burn 2nd card LATB=0b0001;__delay32(20000000); LATB=0b0000;__delay32(30000000); steps(40 / step_angle); __delay32(30000000); // step 14..the turn card LATB=0b0001;__delay32(20000000); LATB=0b0000;__delay32(30000000); steps(-40/ step_angle); __delay32(30000000); // step 15..burn 3rd card LATD=0b0001;__delay32(20000000); LATB=0b0000;__delay32(30000000); steps(50/ step_angle); __delay32(30000000); // step 16..the river card LATB=0b0001;__delay32(20000000); LATB=0b0000;__delay32(30000000); steps(-100/ step_angle); __delay32(90000000); // step 17..return to the start point steps(0/ step_angle); __delay32(960000000); // step 18..finished } return 0; } void steps(int n) { if (n > 0) { while (n > 0) { step_forward(); n = n - 1; } } else { while (n < 0) { step_back(); n = n + 1; } } } void step_forward() { // Turn off the previous phase and turn // on the next one. if (LATD == 0b0001) LATD = 0b0010; else if (LATD == 0b0010) LATD = 0b0100; else if (LATD == 0b0100) LATD = 0b1000; else if (LATD == 0b1000) LATD = 0b0001; else LATD = 0b0001; // Delay to allow rotor to move. __delay32(step_time); } void step_back() { // Turn off the previous phase and turn // on the next one. if (LATD == 0b0001) LATD = 0b1000; else if (LATD == 0b0010) LATD = 0b0001; else if (LATD == 0b0100) LATD = 0b0010; else if (LATD == 0b1000) LATD = 0b0100; else LATD = 0b0001; // Delay to allow rotor to move. __delay32(step_time); }
Building Process
Balsa Wood and Hot Glue (Excellent stuff to work with, easy to manipulate).9
Balsa Wood Used
Here you can see the two front roller, they are driven by the shaft that is extended to the right, motor will be attached to there.
Also you can see that there are elastic bands round the rollers, these are used to rotate the top roller. Have the bands(very left & very right) in a 8 shape so that the top roller runs in opposite direction.The other two bands in the middle are there just for traction reasons.
In this photo you can see the funnel type guides. These will make sure that the position of the card going into the rollers is correct.
Position of cards on platform.
With motors in place.
In this photo you can see the motor and roller that feed the two front rotors. I used hurling grip around the roller for traction.
Build up a frame around the motor shaft
Spring underneath the cards to keep upwards force on the rollerso that there is always a card in contact with the roller.
Used a Connector to attach the shaft of the motor to the roller shaft.
Stepper motor glued to board. Also thsi is my revised version of the connection on the stepper motor to the dealer. My first attempt was to build a frame up around the shaft of the stepper but it ended up spinning inside it. This way gave the stepper more grip.
Slot for stepper motor underneath frame.
Finished model
Here are a few videos:
In these first 2 videos you can see the basic fuction of the dealer but also you can see the way the stepper motor is moving the dealer as well as I had hoped.This was due to the stepper spinning inside the mount I had made first.
These videos are of the dealer with the revised connection to the stepper motor. As you can see it moves alot smoother but still there could be better with a larger stepper.
Conclusion
There are a few things I would do differently, the rollers at the front,I would use gears instead of elastic bands. The bands worked well but the amount of time in the early stages where the elastic bands would roll off and would take alot of patience and time trying to coax the band back up on the roller.
The next thing I would change would be the size of the stepper motor that I used, I felt that it was a tad bit small. But the major problem I encountered was the wires coming from all the motors would get caught in the structure, thus restricting the movement.
There are also alot more features that I could add to this in the futre, like distance sensor to locate a player. Also if you could develop way to turn the cards for the flop, river and turn cards.I think this could bdone by using an axilwith a servo to rotate the deck of cards. But that would take a bit more thinking.
Overall thought I am happy the way it turned out and I really enjoyed the building and the seeing your plans coming together and it working out for once. Hope you enjoyed. Bye now.