Monday, December 23, 2013

The basics

I have been sharing my love and experience in reprap for a few years now, but I've forgotten everything I didn't know when I started. I can only remember it was a frustrating few months trying to piece together all of the new tools (talking software) to be able to get my Sells Mendel (oh yeah old school) just to print. I didn't know where to start, my head was already spinning just trying to keep up with the new nomenclature people were using including two and three letter abbreviations. So in order to help clear the fog, I am going to pour my knowledge into this blog, and hopefully it'll provide a lighthouse to at least get you going. Let me just say, this is not the only way, and it may not be the most elegant, but it's based on personal experience and that beats theory (aka "it should work") any day in my book.

Glossary: This will grow as I think of terms that maybe foreign (or someone tells me they need to be added)

  • Arduino - this is both a software for compiling and uploading firmware, and the hardware it runs on. I use an Arduino Meda with a RAMPS shield for both of my printers. They are well-known and well-supported.
  • BOM - bill of materials is a list of the parts you'll need to build the machine and where you can source them from. 
  • Driver - this is a hardware device that does the electrical switching of stepper motor coils to steps the motor forward or reverse. Common drivers are from Pololu and are the 4988 and 8825. I use both and like the 8825's on my delta. I did buy some for my Prusa during Black Friday, but have not installed them yet.
  • Filament - this is the plastic stock and can be 3mm or 1.75mm. I use both, and to be honest I still prefer 3mm. I also prefer PLA since I'm so sensitive to fumes., but you may like ABS.
  • Firmware - this is code that runs on the (for this discussion) Ardunio based controller. My CNC router has the PC has the controller and it sends signals to the drivers. For reprap, the PC send gcode to the controller which converts them into the step and direction signals (among other input and output signals)
  • GCode - this is the language of CNC machines. You can have G codes and M codes and which ones do what depend on your firmware. I use Marlin so that is what I'll talk to. 
  • Host software - this is your user interface (assuming you are not using a smart LCD controller and SD) to your printer. I use and like Repetier, and I have started using Cura as well.
  • Hotend - this is the heated nozzle where the filament is extruded. Common types are J-Head, Prusa, and E3D. 
  • OpenSCAD - this is opensource software that lets you create parametric 3D models using a c-like scripting language and simple geometric constructs. I use it and love it, but I'm no ninja with it. there are some great tutorials and you can learn a lot from reprap machines like 
  • Opensource - well to me it means free, someone creates something and puts it into the wild because they think others will find it useful. However, there is no promise of support so it's a take it or leave it proposition.
  • RAMPS - this is an Ardunio shield that allows you to easily connect stepper drivers, hotends, servos, endstops, fans, etc to your Arduino. I'm using an v1.3 and v1.4 and I have a 1.0 from my old Sells Mendel
  • Reprap - it means a lot of things, but to me it's is the community of machines, software, and people that build, support, and enjoy hobby 3D printing of the opensource kind. 
  • Slicer - this is software that takes a 3D model and slices into layers of gcode. Slicers can be integrated into the host software (Cura, Repetier, Pronterface) or stand along (Kisslicer)

Where do I start?

Well the first thing is I would say read forums, watch videos, and read the wiki's. The information is spread out all over the web. Google is your friend and reprap is a keyword you should always include in your searches.

Common Questions

  • I want a 3D printer, but I don't know which one. Or Which 3D printer is the best?
Ultimaker Original
Well, as with anything with so many options it depends. I went with a Mendel because that was the most popular and thus most stable/well supported. Mendels are still the most popular and I think Deltas are making a charge. Of course there is the Makerbot and a favorite of mine the Ultimaker, though I can't justify the shipping costs so I'll stick with repraps.

So you need to decide, why you want a printer? To show off, to learn about them, to print whatever you dream up? The thing I learned is that people sell these printers and they only want to report the good. These things are a full-time hobby, you will have to constantly care for and feed them. Most of what you print will be to improve the printer or decorate it somehow. I know of very few examples where anything printed was practical, it's more for show (printed vases, printed small robots, gear cubes, iPhone cases, hell just browse Thingiverse). And for me, that's what I wanted. A CNC machine I could watch, tweak, and share with friends and the community. In fact most of what I've printed recently are set to build the mini Kossel delta printer. I'm not
designing anything in particular. I made a toilet seat wrench, and a lampshade harp (the PLA sits on the LED light bulb to hold the shade), but mostly it's just stuff. So if that's your goal too, great. Now how big a thing do you want to print? Mendels typically have a 200mm by 200mm by 130mm build area. My mini Kossel is roughly (not accounting for the cone shapes at the top) 160mm diameter by 228mm tall. The biggest pieces I've printed are vases. But with a large print area comes a large footprint. I learned with my Mendel that I like to print one part at a time, not a whole sheet. The reason, if you have just one piece of a plate (a collection of 3D objects to print at one time) unstick, it can ruin all of them and if it happens late into a print...oh wow what a loss of time and material. Anyway, since I only print one object at a time, my actual build area is satisfied by the min Kossel. As a bonus, it fits on a relatively small wall shelf 16"wide and 12" deep. So I like the compactness. If you need/want bigger then look at the Kossel or Rostock, or Prusa i3.

  • Ok I picked a printer now what?
Well, you need to read everything you can about that printer. Find a forum that caters to your printer and start reading. Learn what people are having issues with (calibration is a big one) and try to find the answer. I'll most likely start a mini Kossel FAQ in a future post, my head is swimming with ideas and I'm not that fast a typist. Once you feel comfortable with that printer, it's BOM, and it's warts you need to plan your orders. It's not a bad idea to create a new forum post asking people to review your planned orders (unless you are using the stock BOM with known working part numbers) to see if the stepper motors will be suitable, power supply with work, etc.

  • I got my parts, is there a user guide on how to put this all together?
Maybe, maybe not. Hopefully this is something you find out in your process in identifying a printer model you like. For example, I knew I wanted to build a delta and there were 3 or 4 models to pick from 3DR, Kossel, Rostock, and the mini Kossel. When I saw that the mini used a linear rail guide
Linear rail guide
 that sealed the deal for me. Even though I had experience with the ball bushings and smooth rod, the mini Kossel just looked so simple and effective and the videos by Johann were very impressive, especially the auto-probe. I almost went with the 3DR, but I didn't like the idea of using Spectra, or having that much printed plastic as the frame of the machine. I also didn't want to look at roller guide like the Cerebus pup having to fiddle with tightening offset screws (my opinion, I have no experience with the v or w-wheels).

Again, those were my criteria, you may put a higher price on initial cost or potential maintenance. With the rails, you screw them down, grease the trucks and you are go there is nothing to adjust. The only thing I have not been impressed with is the auto-probe. I had it probing, but I couldn't tell it did anything, YMMV but I say leave it off your list and leave it off your printer.

mini Kossel belt tensioners
But I didn't answer your question. the mini is so straight forward I only needed to look at photos on Flickr to see what went where. the top printed pieces as belt tensioners was not obvious and I wasn't sure which screws were used where (I used 8mm screws on the rails at first for example), and I did need to remove some of the horizontal pieces to add nuts after I had the frame together. There is at least one online guide to use but you need to be prepared to adjust to what you have on hand unless you bought one of their kits. That's the nature of tinkering. Know up front you are on your own and you accept all responsibility for your actions (mistakes included). There is a large community and we foster a brotherhood and an eagerness to help so don't be afraid to ask before you do something you are unsure of. However, just because you "read it in the forums" you should confirm the source. Some people are so eager to "give back" that they don't always check their facts (hearsay) or don't speak from direct experience...asker beware.

  • Ok, it's together, now how do I wire it up?
RAMPS 1.4
Ok, well now we are getting into a forest of trees. There are so many electronics options and I said I only speak from personal experience so I am only going to talk from the Arduino/Ramps perspective.wiring diagram and familiarize yourself with the components. For a the most basic delta you will have 4 stepper motors and drivers, 3 endstops (connected to the MAX inputs and I'm leaving the probe off), a 12 volt power supply, a hotend heater and a hotend temperature probe. I think it's a bit too low level to discuss extending your wires on your stepper or how to solder wires on here, but if I'm wrong, let me know I can can add it. You will need to decide where your controller will be. I put mine at the top and ran the towers stepper wires up to it. Your choice, but you want it some place where you can put a cooling fan on the stepper drivers. Scroll down to where I get into more details below.

Some of what I talk about is the same for other boards so I think there is still broad value in what I'll write. So the first thing is to find the

DRV8825 Stepper driver board
Stepper drivers from Pololu will either be 4988 or 8825. Both have a current limit variable resistor (aka pot or potentiometer) that you will need to calibrate before you go much further. This is a fiddly procedure and having a helper with good eyes and a steady hand will help, though I did it by myself. Here is a good write up of the process (http://www.indigent-networks.com/pololu-drivers-current-limit-configuration/).

The simplest endstop is a mechanical switch. Some people like to jazz it up and add a LED or use opto interrupters or seems like hall effect sensors and magnets are in vogue...I say KISS (keep it simple) and use a bare microswitch with or without a lever it doesn't matter. Connect one wire to the NO (normally open) lead and one wire to the C (common) lead and connect the wires (doesn't matter which to which pin) to the S (signal) and -(read as minus or negative which is the same as Ground) pins on the RAMPS endstop header. Do not connect to + and - or you will short 5V to ground whenever your endstop is triggered (not good). Because we connected the endstop to NO, then the signal on the input will use the internal pull up to read greater than than 3.5V  or logic 1. When the switch is tripped, the signal is grounded to 0V or logic 0. I think it's important you know why we did it this way and what to expect. Of course you can also use the NC (normally closed) and C (common) instead. This time the voltage will be 5V when not triggered (logic 1), so you would need to invert the logic in your configuration.h. The mini Kossel instructions call for it to be this way...but it doesn't matter since the logic can be flipped in firmware.

Arduino 
Now we need to get into Arduino. Some sellers pre-load firmware on the board, but there is no guarantee it'll match your configuration and may not be the latest version. In any event, you need to know how to load firmware. With the Arduino Mega/RAMPS is simple, I can't speak for other controller options. Since this is the basics, we'll start from scratch and download the Arduino software. And run through the Getting Started to understand the flow. On Windows the hardest thing is getting the USB driver installed, hopefully you have administrative rights ;) If you can upload blink then you can upload reprap firmware. If not, keep trying until you can. On, now we need the firmware. I prefer the main branch of Marlin. Most reprap project use github to distribute and track changes in their software. It also allows other to contribute and fork (make their customized versions) of the software. In this case Johann forked marlin, added his delta code to it, and the author Erik Zalm pulled Johann's code into the main branch. You can see how active development is on Marlin is by looking at the network graph. A lot of people have contributed.

Firmware
Github download button
For now we just want to download the main branch. Look in the lower right corner of the page and find the Download ZIP button.
This will save a zipped copy of the project to your computer. Personally I create a sub-directory under where I installed my Arduino software called reprap firmwares and unzip the contents into there. That way I can keep older copies of known working configurations. Wherever you unzip the files to, you should have a folder/directory structure like this:
  • Marlin   - this is the main/parent directory
    • example_configurations
      • delta
There are two files in delta that we need to copy to the Marlin parent directory. Go ahead and overwrite the existing configuration.h and configuration_adv.h files, they are for non-deltas. If you are using these as a guide for non delta, then skip this step :) So the first item of business is to specify your controller. Open up Marlin.pde (or .ino) in the Arduino software. This will open up all the project files too. Find the Configuration.h file and let's begin.

Configuration.h

  1. You need to specify your MOTHERBOARD. This is another name for your controller and since we are using a RAMPs v1.4 we would set #define MOTHERBOARD 33. This lets the software know what pins on the AVR Mega (the microcontroller at the heart of our Arduino mega board) are mapped to what peripheral (endstops, step and direction pins on the stepper drivers, MOSFET outputs for the heater and fan, etc. Just a note, if you see a double slash like this // on a line, it means that line of code it commented out. 
  2. Now you need some physical measurements from your machine. Values are for my machine, yours will vary I'm sure. Also, I won't even try to explain what all of these mean or do, I honestly don't care and if you do, this is way too basic a place to put that level of discussion in play.
    • #define DELTA_DIAGONAL_ROD 215.0 // Center-to-center distance of the holes in the diagonal push rods. If you bought yours it's reasonable to assume they are all the same length that you ordered. If you assembled them yourself, and you used a jig you can assume the same thing. However if even with careful planning and execution you ended up cutting on the wrong line...well then make sure to measure.
    • #define DELTA_SMOOTH_ROD_OFFSET 144.55 // mm Horizontal offset from middle of printer to smooth rod center. This will be the value you will need to adjust during calibration
    • #define DELTA_EFFECTOR_OFFSET 19.9 // Horizontal offset of the universal joints on the end effector. This is the distance from the some reference point (say the face of the 1515 extrusion) to the pivot of the diagonal rod where it connects to the carriage. Why it's19.9mm instead of 19.5mm I'm not sure, because the height of the "Hiwin" rail and truck is 13mm and the half height of the carriage is 13/2 or 6.5mm so 19.5mm
    • #define DELTA_CARRIAGE_OFFSET 19.5 // mm - This one comes from the SCAD file and is the distance from the center of the effector to the diagonal rod pivot point.
The reason I say you can ignore these is because all we really want is the delta radius. The horizontal distance from the center of the effector to the pivot on the carriage. So you'll see the line
#define DELTA_RADIUS (DELTA_SMOOTH_ROD_OFFSET-DELTA_EFFECTOR_OFFSET-DELTA_CARRIAGE_OFFSET). What good is the DELTA_RADIUS you say, well, that is how the firmware will map a Cartesian coordinate pair (X, Y) to a delta coordinate pairs. Here is a sample:

Looking at the delta layout image, imagine yourself looking down from the top of the delta printer with the X and Y towers in the front left and right positions and the Z tower in the middle back. c is the center point and the distance from c to any of the x, y, or z (note the lower case) points is DELTA_RADIUS. In a delta, c is (0,0) with an imaginary horizontal x-axis line passing through c in the positive and negative direction. Similarly there is an imaginary vertical line through c representing the y-axis. 
Delta layout
I know you are asking, why would you use X, Y, and Z for the tower names when x,y are the coordinate names and it's confusing to me when you say the X tower is at (-x,-y)? Well, the best reason I can think of is that reprap started wit Cartesian bots and the axis motors are labeled X, Y, and Z on the RAMPS. I agree it would be better to call them A, B, C or Alpha, Beta, Gamma, or anything else :)

I digress. So looking at the X-Y grid below notice how the x values decrease as you move to the left (negative to the left of the y-axis) and increase as you move to the right (positive to the right of y-axis. Same for the y values decrease as you move down (negative to the below the x-axis which is to the front of your machine) and increase as you move up (positive above the of x-axis which is to the rear of your machine. So at a high level we can say that the point x in the delta layout image is some negative x value and some negative y value (-xi, -yi) or to the left and front of the center point c. For point y it would be (xi,-yi) and for point z (0,y). Zero for x? Yep, it's on the axis line and remember our center is (0,0).

Now how do we calculate the x and y coordinates of these three points? Trigonometry, or triangular math. If you don't want to know or don't care, skip this step, it's going to use sine and cosine and some multiplication. There is a working radius where your effector can travel in a complete circle without hitting anything we'll call this radius R and for the mini we'll use 80mm. This means that the diameter of our circle is 160mm (you can use 85 and get 170 if you like too) and or x and y max values are -80 to 80 on the x and y axis, but not on the diagonals for the X (alpha) or Y(beta) towers. You know there are 360 degrees in a circle. If we take some point on the x-axis and rotate it counter clockwise 90 degrees that point would now be on the y-axis. It we rotate it another 90 (180 total) it would be on the x-axis but on the negative or left side of the y-axis. Another 90 (270 degrees total) and we are on the y-axis in the negative region. And one more 90 (360 degrees) and we back where we started (full circle). Deltas are equidistant from one another or 360/3 = 120 degrees apart. Since the Z(gamma) tower is on the y-axis it's at 90 degrees...with me so far? So now if I add 120 degrees to 90 then we are at 210 degrees for the X(alpha) tower and 310 for the Y(beta) tower.

So now let's convert polar coordinates Ri at angle theta to Cartesian (x,y). For X tower we have Ri = DETLA_RADIUS and for point x in front (with the notion that the towers face inward to the center point c) of tower X(alpha) being 80mm and it's angle theta =210 degrees, (x=cos(theta)*Ri, y=sin(theta)*Ri). So we get point x coordinates= (-69.282, -40). Similarly for Y(beta) tower where theta is 310 we have (69.282, -40). Finally for tower Z(gamma) we have (0, 80).

Um ok, but what does this have to do with the editing of the configuration.h editing we were doing? 
Yeah you caught me, I dove into the details a bit so getting back on track you'll need to find and set:
 // Travel limits after homing
 #define X_MAX_POS 90    // note how 90 is the default. You can make this 80 or leave it 90 for the mini, this is a "soft limit" and the firmware will not let you go to (110,110) if you set the max to 90 for both.
 #define X_MIN_POS -90
 #define Y_MAX_POS 90
 #define Y_MIN_POS -90
 #define Z_MAX_POS MANUAL_Z_HOME_POS // This one is important and you need to find the #define for MANUAL_Z_HOME_POS further down
 #define Z_MIN_POS 0

 #define MANUAL_HOME_POSITIONS  // MANUAL_*_HOME_POS below will be used
 // For deltabots this means top and center of the cartesian print volume.
 #define MANUAL_X_HOME_POS 0
 #define MANUAL_Y_HOME_POS 0
 #define MANUAL_Z_HOME_POS 250 // For delta: Distance between nozzle and print surface after homing.  This is a measured value, and can change depending on your hot end length, your vertical extrusion lengths, and where your end stops are mounted.

Finally enable the EEPROM by ensuring the following two lines are uncommented
#define EEPROM_SETTINGS
#define EEPROM_CHITCHAT

Temperature sensors
You have to define TEMP_SENSOR_0 no if's, and's or but's. If you don't, the firmware will throw an error when you connect with your host software. the same thing will happen if you do not connect or have an open circuit to your actual thermistor, it's a safety feature. Use the chart of known thermistors and pick the one that matches. I don't use a heated bed, but if you do, then define the TEMP_SENSOR_BED too.

End stops
Micro switch
If you are using mechanical end stops like me, then you are going to wire them normally closed (NC). This means the switch connects the NC terminal to the C (common) terminal until the switch plunger is depressed. The two wires go back to the RAMPS and connect to the end stop headers. One wire connects to - (aka minus, negative, GND or Ground) and the other to S (signal). S then connects to a physical pin on a AVR microcontroller pin. If look at the digital logic that this pin sees based on the voltage present on this pin, it would be 0V when the switch is not depressed (not homed) because it's connected to ground, and not connected to anything (open) when it is depressed. If the circuit is open the voltage on the MCU pin will float unless we pull it up to a high voltage (5V). To do this we need to to ensure #define ENDSTOPPULLUPS is uncommented. #define _MAX_ENDSTOP_INVERTING are set to false.
End stop header on RAMPS
Note: X+ is to the right of X- some for Y and Z

This tells the AVR to connect all of the end stop pins internally to Vcc (5V) via an internal resistor to limit current. If you are using a different endstop (opto, hall, etc..) then you may not need this internal pullup resistor. Using typical digital logic, 0 volts equals a logic 0 (aka false) and 5V (Vcc) = a logic 1 (aka true). So right now, if we do nothing else, then we would see false when the switch is not depressed and true when it is. So we don't need to invert the logic. You will need to make sure all of the [x,y,z,min,max]_ENDSTOP_INVERTING = false in your configuration.h.

Steps per unit
You need to tell the firmware how many steps it needs to send tot he stepper driver to move the carriage 1 mm. There are calculators that you can use to get this,= but if you are using 1/16th microstepping drivers, GT2 belts, and 16 tooth pulleys you would enter 100 for the X, Y, and Z motors. If you have 1/32 microstepping then you would use 200.
 #define DEFAULT_AXIS_STEPS_PER_UNIT   {100,100,100,506}
The last number is specific to your extruder and in my opinion should be directly measured by following this calibration guide.

See my new post on Wiring and soon First Test and calibration