Introduction: UCL - Embedded - Pick and Place

This instructable will go though how a 2D pick and place unit is made and how to code it.

Step 1: Compunets

1x Adrio Mega

2x stepper motors (we used JLB Stepper Motor, model 17H1352-P4130)

2x Stepper Motor Drive Controller Board Module L298N Dual H Bridge DC For Arduino

1x servo motor (We don't have the speck on this one)

3x 10k ohm resistors

2x Nylon wheals

1x 12v power supply

Some wood for the frame


Step 2: Construction

The first thing during the Construction face was to deside the size and shape of the pick and place mashine

First we build the basic shape wood. We built our pick and place frame 50cm by 25cm by 30cm. Everything except the frame, bridge and lifting arm, was manufactured with a lasercutter.

Here is a link to all the files

Then we wanted to the pulley system. Here we went with two 50mm rings and one 20mm ring. Then we put a paracord next to the 20mm with some glue. After which we squeezed the two 50mm rings on either side of the 20mm ring.



Then we need to design a slide guide to the arm. Here we made two sides and one back plate.

Which then was glued in a U form. Then we connected that to the bridge.

Side plate

Back plate

Now that the parts for moving the arm up and down are done. We need to move it back and forth.

When designing this we made sure that the teeth align with each other. So both items was created in the same project place.

Step 3: Code

The programming is pretty simple and consist of 5 parts

  1. Inclusion of Libraries and Setup of variables for internal and IO use
  2. Load inputs to Ram
  3. Sekvens, choosing the movement you want.
  4. Stepper/servo position control
  5. Output to the world

We will in broad strokes explain every part, but remember this is just one of many solutions.

1: Befor the void setup we included the 2 libraries we need for this projekt. Stepper and Servo. Using the included Libraries, saves you from learning every detail about stepper and servo motors.

<p>#include <Stepper.h></p><p><stepper.h>#include <Servo.h><servo.h></servo.h></stepper.h></p><p>const int stepsPerRevolution = 200;  // change this to fit the number of steps per revolution for your motor</p><p>// initialize the stepper library on pins 8 through 11:
Stepper XStepper(stepsPerRevolution, 22, 23, 24, 25);
Stepper YStepper(stepsPerRevolution, 28, 29, 30, 31);
 Servo Griper;  // create servo object to control a servo</p>

the Gripper need to get attach in the void setup

<p>void setup() {<br>  // initialize the serial port:
  Griper.attach(9); // attaches the servo on pin 9 to the servo object</p>

The rest of this section is just setup of Variable's and Constant's.

2: The first thing in the Void Loop is to load all the used inputs to a variable. This is done for two reasons. The first reason is to limit the CPU heavy tasks of reading a Input. The second reason, which is the most importand, to make sure that if an Input is used more than one time, it will have the same value throughout the entire scan. This makes writing consistent code way easier. This is a very common practice in PLC programming, but it also applies to embedded programming.

<p>//-------------------------Indput to RAM--------------------<br>  Xend =  digitalRead(34);
  Yend =  digitalRead(35);
   Ena =  digitalRead(36);</p>

3: In the sekvens part of the code, we just made a sekvens with the Switch and case commands. The sekvens part just gives signals to the Position control part of the code. This part can easily be customized to your application or used as is.

4: The Position of the servo is just controlled by the servo liberi, and an if statement for gripper open and closed.

The Stepper Control is a bit more tricky. The function compares the Setpoint (The position you want the arm to go to) and the Current position. If the current position is lover the, the function adds on to the position and asks the Stepper liberi function to take a positive step. The opposite is true for a to hig position. if the position is the same as the Setpoint, a XinPos bit is sat hig, and the stepper stops.

// SP controal X<p>if (XstepCount<xsp and="" not="" home){=""  ="" xstepcount="XstepCount+1;" xstep="1;"  xinpos="0;"   ="" }="" if="" (xstepcount="">Xsp and not Home){
  XinPos = 0;
if (XstepCount==Xsp){
  XinPos = 1;

5: Add the end of the code the motors is controlled with the liberi functions.

<p>//--------------------Output---------------------- <br>  // step one step:
  // step one step:
  YStepper.step(Ystep);</p><p>  Griper.write(GripSp);</p>

Step 4: Made By

casp6099 - Casper Hartung Christensen

rasm616d - Rasmus Hansen