Initial Setup: CRAMPS BeagleBone cape with MachineKit

tl;dr:

CRAMPS works, and the tips here might save you some time getting yours set up.

Why make and use a CRAMPS board?

I had some good luck at the end of 2013 using Charles Steinkuhler’s MachineKit SD images on a BeBoPr board with BeagleBoneBlack to control a Kossel delta printer to print parts for a GUS Simpson.  At the time, it was developer-level software on a developer-level board with a developer-level printer, making a completely-out-there experimental 3D printer design.  Bleeding-edge fun.  I posted a YouTube video of it and got a few hits:

The BeBoPr is great, but it’s expensive, has limited availability, and is closed-source, so it can be a bit harder to debug stuff.  Recently, Charles designed a simple, low-cost, hand-solderable board similar to the BeBoPr, but open-source.   It’s like the RAMPS board used with Arduinos, but as a BeagleBone cape, and designed for 3.3v logic.  Here’s mine:

IMG_20140608_161316

These are available on Charles’ web store for a reasonable kit price of $60 or board as $10.  Add a $45 BeagleBone Black and 4x Pololu-style stepper drivers(~$50) and you’re within spitting distance of a PrintrBoard in price, but with vastly more power (32 bit, 1 Ghz + 2x200MHz microcontrollers vs 16 Mhz, 8-bit, no floating point) and a much more flexible dev environment (Python, C++, shell scripting on an OS etc vs embedded C).

Cell-phone ARM processors are the future of RepRap control, especially for printer types that require coordinate transformation, like deltabots, although the software options are not currently as feature-complete or printer-specific as many Arduino-based options.  Add MachineKit, which does machine path and motor control in a real-time way (so that nothing else running on the CPU can interrupt your machine’s motion) and you’ve got professional-level open-source printer control.

Anyway, enough high-level view.  Presumably you’re here to set up your CRAMPS, or at least see what the setup process is, because it really is totally different than Arduino-based boards.  The current docs for this combo stop at the board build, so posts like this will help fill in a documentation gap or hopefully get pulled into official documentation.

These instructions assume minimal familiarity with BeagleBone and MachineKit. I talk about stuff I used on the Mac, but of course an OS will do.

Buy it

I bought mine as a kit, although you can get the boards and parts yourself, and hopefully assembled boards will be available sometime soon.  There are a number of 603-size surface-mount components and some SO-size chips, but they all had enough clearance for me to to easily solder.  Only purchase if you have the right tools, including a temperature-controlled soldering iron, SMT tweezers, and thin solder.

Build it

Start to finish, my build took ~3 hrs.  The graphical instructions on the CRAMPS page are great, and the labeled parts bags really help out.  Just watch out with the Schottky diodes; the thicker line on one side is hard to see because each part outline is so close to other parts similar outlines.  Also, make sure to use the marked tee on the back of each LED to get the polarity right; I found the polarity mark hard to see through the frosted glass.

If you’re going to do larger board quantities, I’ve had good results in the past using a laser-cut mylar stencil from Pololu to apply solder paste from a tube, followed by reflowing in a toaster oven.

Load SD image

BeagleBones either run off the embedded flash or an external microSD card.  If you have the latest BeagleBoneBlack, rev C, it includes a 4GB flash which is just large enough for the MachineKit image and some user data.  However, mine are rev B, which is 2GB, so I had no choice but to run from a card.

More details for this part are on the main MachineKit page.  Go there for the download links now.

I have a Mac, and I used the Unarchiver to extract the .xz image archive, followed by Pi Filler to write the image to the SD card, using the Mac’s internal SD slot.  Unfortunately, Pi Filler gives no indication of progress, and will appear hung for about half an hour.  You can check that it’s still doing stuff by going to Activity Monitor and viewing IO.  You should see continuous writes of a few MB/s.   Perhaps a more expensive SD card would speed this up.

Power it up

Once Pi Filler completes, transfer the microSD card.  You won’t initially need any power besides the 5V barrel jack on the BBB (or the 5V in on the CRAMPS).  However, to use any CRAMPS features, you’ll need a higher-voltage source.  I used an ATX power supply that came with my PrintrBot Jr.

This V+ is connected to motor power, bed power, aux power, and extruder power.  Yes, that means in addition to something like a Molex connector with raw wires, you also need 3 wires to connect up V+ and 3 wires for GND, all at the screw terminal blocks.

Connect

If you have an HDMI display/TV and a USB keyboard and mouse, you can use the BBB as a stand-alone computer.  I’d prefer to have my BBB be more like an embedded web server, so I usually log in via SSH, using an Thunderbolt Ethernet dongle and CAT5 cable.

The MachineKit image runs Avahi, which removes the need to run a DHCP server for the BeagleBone to communicate with any other machine.  The hostname is ‘beaglebone’, and by default Avahi uses the hostname.local convention.  So after the board has booted (~1 min), you should be able to SSH into it via Ethernet:

ssh machinekit@beaglebone.local

Username and password are both ‘machinekit’.

This is a full Linux PC – you can run commands like ‘df’ to see how much free space is available, or really anything.

Optional: Connect Via Serial

Other connection methods include USB, which I haven’t tried lately, or the onboard serial 6-pin serial connector, when coupled with a USB-serial dongle.  I have one of these dongles, from Adafruit IIRC, and it’s useful to see the boot process if things go wrong.  On the Mac, I use screen as a serial terminal.  Find where your serial port comes up:

ls /dev/tty.*

Then connect via ‘screen’:

screen /dev/tty.usbserial-FTG9MZFU 115200

You should be able to hit enter to see a prompt, and after resetting, should see the boot process.  Note that you won’t be able to run graphical MachineKit this way; it’s text only.  Sometimes I neglect this.

Update Software

Development of MachineKit moves fast, and by not having the latest MachineKit build you’ll likely come across bugs that other have solved.  In my case, Charles fixed a thermistor calibration bug after the SD image was created.   To update the software, the easiest way is to provide the BBB with Internet access.   I use Internet Connection Sharing on the Mac, which is easy and fast.

On the Mac, go to System Preferences -> Sharing -> Internet  and share the wireless connection to the Ethernet dongle.  When you reboot, the eth0 interface on the BBB should be assigned a NATed IP via your computer, but to force it, run this command, on the BBB:

sudo dhclient eth0

This will DHCP for an IP address; if you connect your Ethernet port to a regular wired network after booting, this same command will apply, and if you reboot, the DHCP should occur automatically.  Verify outgoing connectivity:

ping www.google.com

Now you should be able to update the code, as shown on the MachineKit page.  Yes, the ‘make’ portion may take a long time – in my case, ~20 mins.  The BBB processor is not laptop-fast, plus there’s a ton of code to build.  Hopefully the MachineKit devs will get nightly builds accessible with packages that can be updated automatically via apt-get, the package manager built into Debian, to largely eliminate this delay.   For now, do this to update the source build:

cd ~/machinekit-dev/src
git pull
make
sudo make setuid

These steps should complete successfully.

Test functionality

OK, you’ve got the latest software; now it’s time to run this thing for real.

To have a graphical environment appear when logging in via SSH, you need to enable X forwarding with the -X option.  This will enable the default MachineKit GUI, called Axis, to appear when you go to run linuxcnc (the name of the executable for MachineKit, and the project from which it forked).

ssh -X machinekit@beaglebone.local

Once in, type this command:

linuxcnc &

Wait for awhile, and the list of configurations will appear.  Select the ARM -> BeagleBone -> CRAMPS -> CRAMPS config.

Click the top-left button red X button to disable E-stop, then the next-leftmost orange square button to enable the machine.  Then click Home All.  Since the endstops are not configured, this will just reset all axis values to zero.  The Active light on the CRAMPS board should light up.  Time to test each part to verify soldering…

Verify axis motion

If you haven’t plugged in a motor and Pololu-style stepper driver, do so now, but always after turning motor power off first.  I plugged in and tested one motor at a time, in case I made a horrible soldering error.

Click plus/minus to move the axis – it should be moving in both directions!  Do this for X, Y, Z, and A (via E0).  You can connect more extruders but they’re not exposed as axes via the config or GUI yet.

Test Endstops

The easiest way is to use the shunts that come with the CRAMPS board, leaving them attached to the plastic backing.  Before plugging one in, verify the disconnected endstop value.

In a terminal connected to the BBB (SSH, serial, or direct), run this command:

halcmd show signal limit-x-min

The signal should show false, like this:

halcmd show signal limit-x-min
Signals:
Type          Value  Name     (linked to)
bit           FALSE  limit-x-min
                         <== bb_gpio.p8.in-08

Put the shunt across S and – on the X min connector and re-run the command; you should see TRUE.

Repeat for min & max for X, Y, and Z.

Verify thermistor readings

Plus a thermistor into the THERM-0.  This is for E0.  The value should appear in the GUI; you can also view it on the command line with:

halcmd show signal e0.temp.meas

Repeat for THERM-1 with the bed thermistor:

halcmd show signal bed.temp.meas

Mine reads ~28C at room temp.

Verify extruder and bed PID loops

Plug in the extruder heater into the E0 screw terminals.  I bent some long header pins at a right angle and screwed them in to make this connection easier to swap with other boards; the heater cable uses female crimp connections.  To set the temp, go to MDI tab and enter this command:

M104 P200

This should cause the heater temp to swiftly rise.  In my case, for a heater cartridge, the PID settings need tuning; mine goes to 211, then down to 199, then up to 204, then settles back down at 200.

To shut off E0:

M104 P0

Repeat for the bed heater, which has bigger terminals of its own.  Start it up:

M140 P50

Once it’s up, shut it off.

M140 P0

Verify low-power FET outputs

The low-power FET outputs are intended for fans and lights.  I’ll definitely be using these, and having individual adjustability without having to buy another fan speed controller is nice.  These signals are not exposed in the default CRAMPS config.  Run these commands:

halcmd net fet5 hal_pru_generic.pwmgen.00.out.04.value
halcmd net fet6 hal_pru_generic.pwmgen.00.out.05.value
halcmd sets fet5   1.0
halcmd sets fet6    1.0

We could do this all in two commands but I prefer to have meaningful names for pins.

Connect up a fan or LEDs and you should be able to dim each by changing the value within the range 0.0-1.0.  For example:

halcmd sets fet5    0.5

That’s it!  You’ve now checked out the most everything needed for typical printer works.

Learning more, and what’s this HAL thing

‘halcmd’ – we kept seeing this.  HAL is Hardware Abstraction Layer.  It’s the layer within LinuxCNC that allow rewiring inputs, outputs, and processing stages together without having to recompile all the code.  Halcmd is a program that runs single HAL commands at a time.   The HAL init file is where all the important signals are named and exposed and any machine-specific logic goes, and in fact, when we loaded the CRAMPS config, this whole file loaded:

https://github.com/machinekit/machinekit/blob/master/configs/ARM/BeagleBone/CRAMPS/CRAMPS.hal

Getting familiar with the HAL file will be useful, so you can grab the right signal names for debug or make changes to the board config. For example, this file is where the FET5/6 signal names come from.  However, it’s not the main place where you’d make machine-specific changes, like steps/mm.  Those go in the CRAMPS.ini file.  Take a look at the directory above this file – these are files to become aware of.

What’s Next?

Expect a blog post to follow with more details on how to port a Marlin config and get this thing running G-code.

Advertisements

13 thoughts on “Initial Setup: CRAMPS BeagleBone cape with MachineKit

  1. Dude this is so awesome. It’s a pity thigh that beagle boards aren’t open source. I am developing large style delta printers and really see the limitations that Arduino mcu have. I’m thinking of testing this set up but don’t have the tools to solder the CRAMPS. I’ll be following closely when there are ready to roll boards available. Using Linux CNC will be so much better too. Thanks for sharing

    • Is there some reason you need the BBB hardware to be open-source or is this more of a philosophical thing? It would be tough for CircuitCo to open source everything and stay profitable against asian board suppliers; at $45 they can’t be making a ton on each board.

    • About CRAMPS, does anybody know if I can use the Meanwell NES-100-12 with the CRAMPS board? I bought it on Amazon expressely to connect it to the motor inputs, but I’m getting scared about over-AMPing it, and there aren’t any published specs on the amp max on the inputs. It puts out 8.5A @ 12V.

      On another note: I thought BBB was open-source? At least they claim to be “Open Hardware Supporters”, but I don’t see the OHS stamp on their board. I mean, just because you can’t build one in your basement, would you need to? Could you beat $55 if you did? They publish just about everything on it, right up to the ARM core of the processor, which is licensed, I’m sure. It’s one of the reasons I chose the BBB.

  2. Very nice writeup!

    Side note on the dd of images, you can install and use ‘pv’ to measure progress/rate of transfer of a dd operation:

    dd if=something-armhf-image.img bs=1000000 | pv –progress -r | dd of=/dev/disk1 bs=1000000

    This will give you a bouncing progress bar and a rate of transfer. Great for knowing whether your dd has hung or not.

  3. Pingback: MachineKit Delta configuration + calibration | Design | Make | Share

  4. Thanks for putting this together. I have my board together and I loaded a machinekit image on my BBB. When I open linuxcnc though the orange box is grayed out even after clicking the red X. I haven’t hooked up any power outside the 5v to the BBB.

    Is there something obvious that I have missed. I see an estop and BBB on led on the cramps board. I would really like to see the active and status lights on.

    • I’d have to boot things up and take a look, but I’m sure you could get a quickly reply from the MachineKit google group. They’ve been fast and helpful for me in the past. Good luck!

  5. Brandon;

    Following your guide, C. Steinkuehler’s instructions and using other help from the machinekit group, I have everything working on a Rostock, and it works beautifully indeed. A couple of things I don’t understand however:

    1- In the ini file, the PLA feed rate for your set-up was SCALE = -514. I have an airtripper direct drive with MK7 gear on it, and the best number I could calculate was around 87 for 1.75mm filament. Does that make sense? It kinda matches the periphery of the MK7 drive.
    2- Using the instructions on this page, I cannot turn on the FET5 or FET6. I strongly suspect it does not have power, and the schematic indicates a VDD_5V. Do you know which power input would that’d be for the FET5 and 6. Or is there another trick to this? Their references are indeed sitting in the .hal file.
    3- To my surprise, I had to change the CF_ROD from 250 to 240 to get the part size right as you have indicated. I have the part size right, but the CF_ROD is now incorrect per trigonometry. Why is this, do you know?

    Thanks BTW for putting this guide together. It made what I did possible… Much appreciated.

  6. Hi, thanks for the tutorial.
    I’m having a bit of trouble updating the source. Git pull works fine, but make asks for uuid-runtime. If I install that, it then asks for libczmq. apt-get can’t find this package :/

    Thanks again 🙂

  7. Pingback: Faster and easier! MachineKit install using packages | Design | Make | Share

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s