Wireless 3D Printing with Bluetooth, Marlin, and RAMPS 1.4

September 14, 2012

The initial modifications to the Reprap 3D Printer firmware called Marlin are ready for public testing. I’m using it now to control the printer wirelessly and run jobs from its SD card. The code is at https://bitbucket.org/terawattindustries/marlin-bt (master branch). Communication speed between Arduino and BT is @ 115.2kbps. UPDATE: default speed is now 500K in firmware means set your BT module accordingly.

Hardware

I’m using the Bluetooth module discussed in a previous post. The Bluetooth setup costs about $25. Terawatt Industries is manufacturing a PCB design so this attaches directly onto RAMPS and will work with RepRap power sources without an adapter board as shown.

  • I’m using the BT module I blogged about at https://tenacious33.wordpress.com/2012/07/21/5v-tolerant-bluetooth-module/. It’s reliable and inexpensive. It’s class 2 but that seems perfect here.
  • Speed is 115.2kbps. 250k (Marlin max) should work with the firmware also, but this BT module is programmed for 115.2k. UPDATE: I’ve confirmed Marlin go handle the MEGA’s max USART speed of 1M bps. This module goes a little faster so I’m experimenting with 921.6k bps and will know more soon.

Software

The new features are:

  • Installs just like Marlin – use the Arduino IDE.
  • Enabled with a #define in Configuration.h.
  • Backwards compatible with USB connections, whether or not #define’d.
  • USB and Bluetooth connections live side-by-side. In testing we can have one machine connected to the printer via USB, then connect to the printer from another machine using Bluetooth and issue GCODE commands, like SD print. The machine that’s connected via USB echoes all of this on its console (Pronterface) and we can even disconnect and re-connect the BT module to eavesdrop without affecting the print.
  • USART2 is used for Bluetooth communication in the firmware and USART0′s behavior is mostly intact. Actually, when BT support is enabled everything on USART0 gets multiplexed to USART2.
  • USB and Bluetooth commands shouldn’t collide. This isn’t well tested – it’s an unusual scenario – but the firmware should only read one command from each port and block the other until the end of command is reached. There are some interesting implications. Let’s move along…

Instructions

These instructions apply to the pictured BT module. The module must be wired as 5V tolerant as mentioned in my blog post.

RAMPS Setup

    1. Download the Bluetooth-enabled version of Marlin from the Terawatt Industries Bitbucket Repository.
    2. Install the firmware on your (RAMPS/Arduino MEGA) control board. The reprap wiki has instructions for this if you need help.
    3. Connect the BT module’s 3v3 pin to a 3.3 volt power source. The Terawatt ATX PSU Adapter Board and the ATX PSU Dev Board from Ultimachine are awesome for this. They’re perfect for powering 3D printers too.
    4. Connect the BT module’s GND pin to a ground source.
    5. Connect the TX pin from the BT module to pin 17 on RAMPS 1.4.
    6. Connect the RX pin from the BT module — through the 5v tolerant circuit — to pin 16 on RAMPS. If you skip the 5v tolerant circuitry you’ll fry this BT module as stated in the datasheet.

    Printing via Bluetooth

    These instructions assume you’ve already installed the Bluetooth-capable Marlin firmware on your RAMPS 1.4 Control Board and attached a working Bluetooth module to it.

    1. Pair your computer to the BT module. Doing this depends on your OS, whether you run Windows, OS X, Linux, or otherwise. For this module the name contains the word “linvor”. The Linvor BT module has a pin of 1234.
    2. Open Pronterface.
    3. Set connection speed to 115200
    4. Choose the port listed with the name of your Bluetooth module
    5. Click Connect
    6. Tell Pronterface to print all the neat things stored on its SD Card. You can print via bluetooth – just make sure your computer stays in-range for the duration of the print.

    Addendum

    If you’re using the “screen” app or a terminal to drive the Bluetooth connection the following GCODE commands can be useful:

    M119
    M104 S190
    M140 S60
    M20
    M23 myfile.gco
    M24
    M27

Too Much Glory for Arduino

September 3, 2012

Arduino is so simple and elegant to use; yes, I understand. However the Arduino IDE shouldn’t get more glory than it deserves. For the record beginners would be better served by using a Wordpad or Dashcode editor and dragging/dropping the files into a processor that compiled and uploaded HEXes. Not only would users be more efficient and benefit, the dev team would be more efficient building that product. Instead, the Arduino dev team wastes effort by adding features and fixing bugs in the Arduino IDE — all of which have already been raised and addressed in a myriad of other editors and IDEs. Users have to struggle with those bugs and lacking features, yet so many praise the IDE and its low barrier-to-entry. The IDE kinda blows. Its multithreading model is broken @ v1.0 and the development team lets simple editor bugs hang around for years without a fix – like Ctrl-Z undo not moving the cursor. The worship of it should cease. Over and out…

Android + Amarino Embed

August 26, 2012

Here’s a presentation I gave in 2011 on Amarino-Embed. It wasn’t a very good presentation, it was complicated and there were multiple circuits and hardware management challenges. Maybe some will find it useful anyway.

Amarino Embed Presentation on Google Docs

Arduino Sketch and Schematics

Android Sources

5V Tolerant CSR Bluetooth Module

July 21, 2012

Here’s a 5V tolerant version of the Bluetooth Module covered in the post about the generic 3.3v Bluetooth Module. The module is known by a few names such as “the eBay bluetooth module”, “the dealextreme bluetooth module”, but it’s official name is the Cambridge Silicon Radio EGBT-04 module. This module is very affordable and seems robust. This circuit follows the recommended application note in the datasheet as follows:

  • The connection from the MCU’s TX line to the Bluetooth’s RX line uses a cheap 1N914 diode and 10K pull-up instead of 3.3K. The weaker pull-up has worked better with the Arduino configurations tested so far.
  • The connection from the Bluetooth’s TX line to the MCU’s RX line is straight-thru. Most MCUs will tolerate this. I haven’t memorized the module’s output current specification but it’s low and the datasheet is posted on this site.
  • The MCU is an Arduino MEGA.
  • The blue LED is connected to the Bluetooth module PIO for connection status. This is an active-high PIO.
  • The purple LED is wired to the module’s RX line so this this fixture can monitor the signal from the MCU. It blinks off when transmission occurs. At 115.2kbps the blink is too fast to see with short byte sequences but at 57.6k they’re noticeable. The firmware on this module has no PIOs for RX/TX (yet).
  • With Arduino IDE 1.0+ SoftwareSerial library the module can talk to Arduino at speeds up to 57.6k on a 16MHz Arduino (Pro Mini, Uno, etc). With the Arduino MEGA using a library for built-in USART the module can talk to Arduino at speeds up to 115.2k – perhaps higher but untested.

    Robustness:
    I’m not sure if the jury is out yet. I have no quantitative way to measure connection strength in the field yet but it seems acceptable. OS X has worked smoothly with this module so far. Android has been quirky with issues both at the SDK level and when fatal APK crashes cause disconnection. Google’s Bluetooth Chat won’t connect but Amarino and Amarino-Embed work. When an app crashes while connected to the module it has to be reset. Whitebox testing on Android hasn’t turned up any other surprises so far. I’d have to say the other modules I’ve worked with have their own quirks with Android. Eventually I’ll be able to make more quantitative statements about this topic.

    The module has performed well in my field-tests involving some real-world scenarios such as connection distance and robustness through walls. The firmware lacks features found in modules from Roving Networks and BlueGiga. In general, I’d say the firmware running on this module doesn’t offer anywhere near the amount of features offered in firmware running on Roving Networks and BlueGiga modules. But I rarely use the full feature set on those modules and there’s a well-featured firmware available and programmable for this one. Another thing is: even the pricey modules provide what’s called “single-mode” Bluetooth profile support. That means, if the firmware is written to support the SPP or HID profile, then that’s all it supports. To support a different profile it has to be re-programmed analogous to this module. All-in-all, I’d say this module measures well. I haven’t found multi-mode support for an affordable price yet, but that’s likely to change.

XBot – All Grown Up

July 19, 2012

It’s autonomous now — no more tethering to your PC for power, except to recharge. This robot reacts to light with a dancing head and a micro light show. You control it by waving your hand around it. Since it runs on an Arduino Pro Mini it’s fully hackable. Source code and DIY instructions are on the way. The build is solderless: wire-wrap and hot-glue take care of everything in this low-powered bot.

Three states are shown in the above photos. On (orange/red); Stand-By (blue); Dancing (shown as purple, but is multicolored).

MS-DOS FAT16 Formatting on OS X

July 4, 2012

It took a second to figure out how to format an SDCard with a MS-DOS FAT16 partition, so I wanted to share with everybody. This applies to any type of external disk drive.

There are some links to be found…such as http://www.bergek.com/2008/10/27/partition-usb-disk-with-fat16-on-mac-os-x/ and another one that’s almost identical.

First of all, the second set of instructions result in a “/Volumes/SDCARD/ does not appear to be a whole disk” error in OSX Lion. The drives listed in /Volumes by OS X are the mounted logical drives, and partitioning needs to occur on a physical disk, so I think using “/Volumes/”-anything would not work, but maybe it did in an older version of diskutil.

Regardless, both sets of instructions are approximately the same. When entering this command:
diskutil partitiondisk /dev/disk2 1 MBRFormat "MS-DOS FAT16" "XYZ" 1024M
in OS X Lion I kept getting this error message:
XYZ does not appear to be a valid volume name for its file system

I’m not sure why that isn’t a valid partition name. From what I recall MS-DOS FAT16 partitions support an 11-byte ASCII name. Rather than digging into that I tried this command:
diskutil partitiondisk /dev/disk2 1 MBRFormat "MS-DOS FAT16" "" 1024M
and got the error:
The size (1024M) must not be greater than the size of the whole disk

My SDCard is 1G = 1024M, so I’m not sure why that doesn’t work either. Rather than dig into that hole I used this command:
diskutil partitiondisk /dev/disk2 1 MBRFormat "MS-DOS FAT16" "" 1G

And my SDCard is now formatted. Hope this helps!

UPDATE 8/23/2012: The above worked for a 1GB micro SD card that was used and had been partitioned for an Android G1 previously. On another, brand new SDCard, the steps work but OS X complains that it can’t read the card. Trying to format an SDCard > 1GB is likely the problem – if I find a workaround I’ll post.

ATMega32u4 + WS2801 Demo Jig

June 7, 2012

I posted some firmware for an ATMega32u4 + WS2801 combo that works for demonstration or testing. This code is based on Sparkfun’s but has been modified to run on an ATMega32u4 with LUFA firmware support and compiles with avr-gcc. The LUFA usage is just there for show but with a little effort can be extended.

Pictured above is the firmware running with a WS2801 strip. I’m finding the random generator produces some washed-out colors, but in general they move properly down the strip.

IMPORTANT! Trying to drive the whole strip from USB/5V on the 32u4 will kill the MCU with overcurrent draw. Don’t do this! The default set in Main.c is 1. The MAX number is somewhere around 8.

Pinouts are described in firmware/main.c.

Solid State Depot Pendants

May 27, 2012

Here’s a photo gallery of the Solid State Depot pendants I designed and made on a laser cutter. They’re also posted on Ponoko’s site at:

100% of proceeds from the sale of these goes to Solid State Depot.

Generic 3.3v BT Module BoB

May 21, 2012

Just in are a stack of breakout boards I designed for a cheap BT module sold on eBay. UPDATE: it’s taken a very long time to determine that this is either the EGBT-045MS or EGBT-046S from Cambridge Silicon Radio. The breakout is simple, breadboard-friendly, and exposes all 34 pins on the module. The bluetooth module runs on 3.3v and comes with SPP-compatible firmware — which basically means it’s compatible with Arduino and most MCUs. It’s not 5v tolerant and needs level-shifters for 5v systems. A 5v version with built-in shifters is in the works. The bluetooth module ships with a default baud rate of 9600.

For now I’m just posting resources to this page for this module:

  • Board Layout: bob_ebay_bt_module
  • Datasheet: egbt-045ms-046s Datsheet
  • Pseudo-datasheet (found in a few places online): Bluetooth Module_BC4_Blue V2.0
  • Master to Slave Connection Howto
  • AT command set: AT Commands for Bluetooth Module. Also, refer to datasheet for complete command set. Note, for this firmware you have to not send LF/CR (enter key) at the end of your AT command. AT programming mode is up when your board is not paired by bluetooth devices. You must copy/paste the AT command since timing is important. You can send about one command per second.
  • Example Application Schematic (see note):
    . Note: this schematic refers to an older module. Refer to the http://tenacious33.files.wordpress.com/2012/05/egbt-045ms-046s datasheet for the proper information on this module and proper application notes.
  • Application Example using this breakout board: .
    This circuit design is based on the manufacturer’s application note above, but the expected PIO pins didn’t provide any feedback for me. UPDATE: this design was built before the discovery of the true datasheet with proper application notes – but it’s still valid. It took a few minutes to find PIO for connection status on pin 24, not 31 (32?) as indicated. Also I can’t find a PIO for RX/TX status; but a LED + resistor in parallel on either/both RX and TX lines can help with that (not pictured here). Some things to note from the design include:
    • Connection status PIO pin is connected to the blue LED. Connection status LED blinks fast when not connected (command mode), solid when connected (serial mode).
    • This design uses a CP2102 USB breakout board to power everything and talk to the BT module. The breakout is available at Sparkfun. You don’t need the CP2102 to use the bluetooth module – 3.3v Arduino boards are particularly well suited, as is any MCU or other circuit that uses 3.3v. I have a 5v version in the works.
    • The RX/TX lines on the CP2102 and BT module are cross-connected – such as rx -> tx; tx -> rx.
    • Getting this setup working takes a few steps to verify:
      1. Connect to CP2102 using unix’s Screen command or other RS232/TTY application at baud rate of 38400. On OS X ZTERM is a popular RS232 application. On Windows I’ve heard the “sscom32″ is recommended since the command’s timing is important. You need a terminal emulator that supports 38400,N,8,1.
      2. First, test the AT commands. Type AT+VERSION, you should see something like “linvor1.5″. There is no need to exit command mode. You may want to issue additional commands but be careful when you do, and finishing this checklist first is the recommended approach.
      3. Connect to BT module using a smartphone app that permits arbitrary messages to be sent via bluetooth — such as Amarino2 APK.
      4. Verify that the characters sent from phone appear on the PC.
      5. You should also be able to see characters typed from screen/tty-application to your phone. In Amarino2 you can use the “Serial Monitor” for sending and receiving bytes.
    • Porting the setup to other 3v3 Arduino or MCU is straightforward (explanation needed).
    • When using a phone or PC to connect to this Bluetooth module you should see it listed with names that start with “Linvor”. The connectivity on this module appears to be quite robust for the price point.
    • DO NOT connect anything higher than 3.3 volts to any input pin or power pin on this module. You will surely burnout that pin!

Sun, Moon, Earth

May 21, 2012

Sunset over the Front Range of the Rocky Mountains in Colorado only lasted a few minutes today and was perhaps the best scene of the solar eclipse on this cloudy day. I’ve seen a few (annual) solar eclipses, several lunar eclipses, a blue-moon lunar eclipse, and moonset during a lunar eclipse; but this was my first time seeing a solar eclipse at sunset. It was unforgettable. The photo shows the unmistakable perspective of Sun, Moon, and Earth.

For this photo I used my Meade 90mm Maksutov/Cassegrain and taped a few pieces of printer paper to a magazine. For viewing it was great – I don’t mind laying on the ground to see something like this. But for photos I had to hold everything up by myself so it was difficult to get everything focused properly. When sunset started images like this started appearing on the projection matte. There was no time to improve my setup — rim-to-rim of sunset was only about 120 seconds.

This comes with the usual disclaimer: viewing the sun with naked eyes can be damaging, and viewing the sun with magnification can be instantly blinding. Viewing the sun with magnification should only be performed with qualified scientific solar filters or by using a safe method of projecting the image onto a matte (non-glossy) surface.


Follow

Get every new post delivered to your Inbox.