11 - machine design

This page holds my individual contribution to the machine design group assignment.
The group assignment page can be found here.
04 - making a gripper
I worked on a mechanical gripper that can pick up bricks using a servo motor, I used this file from Thingiverse as the basic design. After laser cutting it out of 3mm acrylic I hacked some pieces together to make it more compact, make the servo fit better and I added shrink tubing around the end to give it a better grip.
05 - designing a bed
The last thing I designed and built was the bed of the machine, because the machine needs to hold a wide variety of parts and we wanted it to be reconfigurable we designed a bed that allows various dividers to be placed to create either small or big pockets.
The bed rests on a wooden support that we drilled screws through to grip through the cardboard.
HERO SHOTS
I worked on getting the stepper motors to work, so I used the CNC shield and an Arduino Uno.
The CNC shield does not require any drivers or libraries as it simply passes the pins from the Uno on to different female headers, optimized for the job. Because we also wanted the Uno to drive the servo and handle button inputs, we had to use some of the pins that serve a different function according to the shield to do the things we needed specifically for this project. That is why we started by studying this handy pinout image.
The motor driver I used with the shield is the DRV8825. We used three of them, for X, Y and Z axis.
As these things can get quite hot, we added a heatsink to each board.
To get started I followed this tutorial.
As described in this tutorial, there are pins underneath the DRV8825 that need to be connected to determine the precision of microsteps.
Because we didn’t have the right jumper for this, we took female header pins and folded and soldered the legs together.
I followed this schematic to determine the configuration for the most precision, which meant connecting all sets of pins in the vertical direction.
The next step was finding a suitable power supply for the motors, and working out how much current they draw. To do this, I ran this simple sketch on the Arduino Uno with the CNC shield, DRC8825’s and stepper motors attached.
#define EN 8
//Direction pin
#define X_DIR 5
#define Y_DIR 6
#define Z_DIR 7
//Step pin
#define X_STP 2
#define Y_STP 3
#define Z_STP 4
//DRV8825
int delayTime=30; //Delay between each pause (uS)
int stps=6400;// Steps to move
void step(boolean dir, byte dirPin, byte stepperPin, int steps)
{
digitalWrite(dirPin, dir);
delay(100);
for (int i = 0; i < steps; i++) {
digitalWrite(stepperPin, HIGH);
delayMicroseconds(delayTime);
digitalWrite(stepperPin, LOW);
delayMicroseconds(delayTime);
}
}
void setup(){
pinMode(X_DIR, OUTPUT); pinMode(X_STP, OUTPUT);
pinMode(Y_DIR, OUTPUT); pinMode(Y_STP, OUTPUT);
pinMode(Z_DIR, OUTPUT); pinMode(Z_STP, OUTPUT);
pinMode(EN, OUTPUT);
digitalWrite(EN, LOW);
}
void loop(){
step(false, X_DIR, X_STP, stps); //X, Clockwise
step(false, Y_DIR, Y_STP, stps); //Y, Clockwise
step(false, Z_DIR, Z_STP, stps); //Z, Clockwise
delay(100);
step(true, X_DIR, X_STP, stps); //X, Counterclockwise
step(true, Y_DIR, Y_STP, stps); //Y, Counterclockwise
step(true, Z_DIR, Z_STP, stps); //X, Counterclockwise
delay(100);
}
This simple sketch moves each motor a few steps forward and back, one at a time. This allowed us to check if each motor was functioning as it should, and how much current it draws.
We powered the motors with a lab power supply, which read that at 12 volt, one motor drew 620mA. The power supply is rated at 3A, so some quick math led me to believe that 3 x 620mA = 1.86A which I thought the power supply would therefore be totally fine to handle.

This was not the case, as soon as I powered two motors at the same time the power supply would fail. The reason for this is that when a motor first powers on, it draws A LOT of current, a lot more than when it is already running, so this spike in current draw from two motors at the same time appeared to be over 3A causing the power supply to fail. It is hard to see this problem as the spike happens so fast that the display on the power supply can’t even catch up and display it properly. The solution was to switch to a different power supply that is rated at 8A which worked well at 12 volt.

HOMING
To ensure that the machine knows it’s position after a path and always starts at the same point, we added buttons to each stage that tell the machine where it is when pressed.
The button you see here gets pressed by a LEGO brick to make sure there is a good connection between the button and the stage, as the cardboard is too flexible for these rigid buttons.

CODE
To keep the code clean and easy to adjust, I divided it up into three separate sketches, one main sketch called BrickPicker.ino, operation.ino and reference.ino. All three files can be downloaded at the bottom of the page. When using this sketch, make sure to put them all in the same folder.
The first sketch, BrickPicker.ino has the job of defining all the variables and laying the foundation basically for everything else to work like including the servo library etc.

The other main function of this sketch is to wait for a button to be pressed, triggering a set of commands in the operation sketch.

Once a button is pressed, the operation sketch is triggered, first the machine will calibrate using the reference sketch, then the path in the operation sketch is followed.


After an operation is complete, the machine will start reading the button states again and waits for a new command.
bed DXF

gripper DXF

base DXF

control panel DXF

Arduino code 1

Arduino code 2

Arduino code 3
