Saturday, 19 November 2011

Look Ma - no wires!

I have managed to get my RepRap working completely wirelessly, so I can initiate prints and monitor progress from my laptop, working in a different room in the house, remote from my printer. Hardware requirements are:

  • SD-RAMPS http://reprap.org/wiki/Sdramps to enable models to be printed without having to send large amounts of data over a wireless link which might be a bit flaky if the computer moves too far from the printer, or is turned off - see my separate posting http://julianh72.blogspot.com/2011/11/printing-without-computer-well-sort-of.html about getting SD-RAMPS working
  • XBee wireless communications - you need two XBee modules, a "shield" to connect one to the Arduino on the RepRap, and the "Explorer" dongle to connect the other to your PC, plus miscellaneous jumper wires etc. You can buy the components separately, but I already had all the bits I needed from my Sparkfun "XBee Wireless Kit" which I bought from Little Bird http://littlebirdelectronics.com/products/xbee-wireless-kit-retail for some other projects I have been working on. (But this is definitely my best XBee project yet!)
First step was to find out how fast the XBees could communicate reliably over the sort of distances I want to use them. (My XBees came set up for 9600 baud by default; I wanted to go a lot faster if possible.) I loaded a simple XBee comms sketch (which I got from the excellent Tronixstuff tutorials http://tronixstuff.wordpress.com/2010/08/06/moving-forward-with-arduino-%e2%80%93-chapter-14-xbee-introduction/ ) , verified it was working properly over USB cable, then removed the USB cable, plugged in the XBee Explorer, and Bingo! - wireless comms! (Yes, it really is as easy as that to get rid of the USB umbilical chord between an Arduino and your PC.)

Using a terminal program of your choice (I use X-CTU), you can monitor the comms, and flash the baud rate to different speeds, etc. Note that you have to flash BOTH XBees independently to change their default baud rate; there is probably some way of doing this in software, but I wanted a "permanent" higher speed connection be default, so I flashed the firmware of both XBees to the same default baud rate.)

I found that I can get a nice reliable connection over a distance of 20 metres or so (through walls etc) at 38,400 baud, so that is how I have left my XBees set-up.

Next step was to modify the firmware (Sprinter in my case) to the new default serial comms speed. This is very easy for Sprinter; you just need to edit line 45 of "Configuration.h" and reload onto the Arduino:

// This determines the communication speed of the printer; 115200 is OK for USB cable; drop to 38400 for XBee JAH 19 November 2011
#define BAUDRATE 38400


Next comes the physical hook-up of the XBee shield to the RAMPS / Arduino. The connections you need to make are 4 pins on the AUX-1 area of the RAMPS board, so I soldered in some header pins to make it easier to connect jumper wires.



I can't attach the XBee shield in the usual way (i.e. stacking shields on top of each other) because it is only a standard sized shield, not a Mega shield, so I can't put it between the Arduino and the RAMPS, and it won't piggy-back onto the back of the RAMPS.

Instead, I have temporaraily attached the XBee shield to the RAMPS board by using 4 jumper wires to attach just 4 pins on the AUX-1 connector of the RAMPS board (namely, 5V, Gnd, D1 and D0) to the 5V, Gnd, Rx and Tx pins on the XBee Shield.

This is just a temporary arrangement for testing; now that i know that it woks, I will rig a better permanent solution soon.

Don't forget to attach the other XBee to the PC using the "Explorer" module:



Now, fire up the printer with no USB cable connection to the computer, and launch Pronterface on the host computer. Look for the appropriate COM port (it may have a new COM number from the default USB  cable connection), and change the baud rate in Pronterface to match the baud rate being used by the XBees. Try to connect to the printer - with any luck it will make the connection, and you will have full control, just as if the USB cable was in place.

Here's the video proof:



If you have trouble making the wireless connection:
  • Make sure the 2-way switch on the XBee Shield is set to UART not DLINE. (DOH! http://forums.reprap.org/read.php?219,105307 )
  • Double-check that both XBees, your firmware (e.g. Sprinter), and your host software (e.g. Pronterface) are all set for the same default baud ate.
  • Check the connections to Tx and Rx on the Xbee shield - try swapping these two wires around, in case you have connected Tx to Rx, etc.
Enjoy your new-found wireless freedom!

3 comments:

  1. Nice hack, very well done!

    Have any other reprappers gone wireless in the same way?

    ReplyDelete
  2. David,
    I wasn't able to find anyone who has done this exactly. The nearest I came across was a response to a question I asked on the forums http://forums.reprap.org/read.php?219,105307 which is where someone describes doing something similar using BlueTooth: http://reprap.org/wiki/Bluetooth_Wireless_Communication
    The wiki link helped me along, but didn't spell out the wiring details etc.

    ReplyDelete
  3. Also, check out Miguel Sanchez' nice job of setting up Bluetooth wireless comms for his RepRap: http://fightpc.blogspot.com.au/2012/03/wireless-3d-printing.html

    ReplyDelete