User Tools

Site Tools


make-your-bukobot-wireless

Link to this comparison view

make-your-bukobot-wireless [2012/11/21 08:04]
buildrob [Connecting to the WiFly device]
make-your-bukobot-wireless [2013/01/02 03:05] (current)
buildrob
Line 1: Line 1:
 +(Up to [[user-created-add-ons]])
 +
 ====== Adding wireless capability to your Bukobot ====== ====== Adding wireless capability to your Bukobot ======
  
Line 8: Line 10:
  
 ==== Instructions for adding Bluetooth wireless to your Azteeg X3 controller ===== ==== Instructions for adding Bluetooth wireless to your Azteeg X3 controller =====
-If you solder a 2.54mm 4 pin right angle female header onto the J11 connector of the X3 board on the //BOTTOM// of the PCB, then the JY-MCU module plugs directly into this connector! [If you can't find a 4 pin right-angle female header then you can just use one with more pins and use side cutter pliers to cut off the extra ones (e.g., http://​www.ebay.com/​itm/​40-pin-2-54mm-PCB-Right-Angle-Female-Header-with-4PCs-/​120788508343).]+If you solder a 2.54mm 4 pin right angle female header onto the J2 connector of the X3 board on the //BOTTOM// of the PCB (which is Serial Port 0), then the JY-MCU module plugs directly into this connector! [If you can't find a 4 pin right-angle female header then you can just use one with more pins and use side cutter pliers to cut off the extra ones (e.g., ​https://​www.sparkfun.com/​products/​9429 or http://​www.ebay.com/​itm/​40-pin-2-54mm-PCB-Right-Angle-Female-Header-with-4PCs-/​120788508343).]
  
 {{:​jy-mcu_on_x3.jpg?​800}} {{:​jy-mcu_on_x3.jpg?​800}}
 +
 +[Don't worry if you don't have an X3, there are other pins you can use to connect the module as described below. The X3 was designed to be pin compatible with a RAMPS Arduino board but it has some extra connectors as well (like J2).]
  
 You will also need a Bluetooth adapter on your PC/laptop if it doesn'​t already have one. Most of them are Class 2 strength, If you can get a Class 1 adapter then that will have slightly greater range (this should still be true even if you are using it with the Class 2 JY-MCU although obviously you won't get the full Class 1 100m range). You will also need a Bluetooth adapter on your PC/laptop if it doesn'​t already have one. Most of them are Class 2 strength, If you can get a Class 1 adapter then that will have slightly greater range (this should still be true even if you are using it with the Class 2 JY-MCU although obviously you won't get the full Class 1 100m range).
  
-**Warnings:​** ​Don't connect the USB and BlueTooth module at the same time (otherwise they'​ll both be trying to drive the same output line). ​Don't connect the module backwards.+**Warnings:​** Don't connect the module backwards.
  
 === Configuring the JY-MCU module === === Configuring the JY-MCU module ===
Line 88: Line 92:
  
 [Aside: the unused "​Key"​ and "​State"​ pins are only for the Bluetooth Host version of this board (i.e. not used by JY-MCU).] [Aside: the unused "​Key"​ and "​State"​ pins are only for the Bluetooth Host version of this board (i.e. not used by JY-MCU).]
 +
 +=== Alternate script for configuring the JY-MCU module (without soldering on the EXP1 and EXP3 headers) ===
 +
 +This script is a bit more automated, and allows you to configure the module by plugging it into the same UART used for USB. This is ONLY for boards that connect to the USB->​UART chip through 1K or greater resistors (Azteeg X3 and official Arduino boards do, others may not).
 +
 +On these boards, if you connect the USB and BlueTooth module (to J2) at the same time, then the BlueTooth'​s TX signal will override the USB's because the USB chip connects through a 10K resistor; however //both// the USB and the BlueTooth module will read any data transmitted on the ATMega'​s TX line. [On boards without a resistor then both modules will be trying to drive against each other and may result in driver damage.]
 +
 +This arrangement allows the following script to echo configuration status or error information to the Arduino IDE Serial Monitor as it is performs each configuration of the JY-MCU module.
 +
 +<​code>​
 +/* Utility to automatically configure a JY-MCU bluetooth module
 +  to replace the USB serial link on arduino-compatible boards.
 +
 +Requires an arduino with at least one UART connected to USB->​UART
 +  chip through resistors so that the module can take precidence.
 +
 +Usage:
 +  Set the defines in the first section.
 +    (the first 3 can be commented-out to leave those values alone)
 +  Upload the sketch with the bluetooth module unplugged
 +  Open serial monitor and set it to the OLD_BAUDRATE
 +  Plug in the module and press the reset button
 +  Watch the serial monitor to make sure each AT command is followed
 +    by a corresponding OK command.
 +
 +To do:
 +  Add success/​error signaling
 +  Add target baudrate autodetection (the module will respond to
 +    "​AT"​ with "​OK"​ if the correct baudrate is chosen).
 +*/
 +
 +#define BTPIN "​0000"​ //4 digit numeric pin for pairing (string)
 +#define NAME "​Bukobot"​ //unique alphanumeric name, 20 characters max (string)
 +#define BAUDRATE 115200 //serial baud rate (integer). 115200 recommended for best compatibility
 +/* Only the following baud rates are allowed:
 +1200 2400 4800 9600 19200 38400 57600 115200 230400 460800 921600 1382400 */
 +#define OLD_BAUDRATE 9600 //9600 by default. If you changed the rate for this module, use that value
 +#define OK_PIN 0
 +#define ERR_PIN 1
 +
 +
 +
 +#if BAUDRATE==1200
 +  #define BAUDHEX "​1"​
 +#endif
 +#if BAUDRATE==2400
 +  #define BAUDHEX "​2"​
 +#endif
 +#if BAUDRATE==4800
 +  #define BAUDHEX "​3"​
 +#endif
 +#if BAUDRATE==9600
 +  #define BAUDHEX "​4"​
 +#endif
 +#if BAUDRATE==19200
 +  #define BAUDHEX "​5"​
 +#endif
 +#if BAUDRATE==38400
 +  #define BAUDHEX "​6"​
 +#endif
 +#if BAUDRATE==57600
 +  #define BAUDHEX "​7"​
 +#endif
 +#if BAUDRATE==115200
 +  #define BAUDHEX "​8"​
 +#endif
 +#if BAUDRATE==230400
 +  #define BAUDHEX "​9"​
 +#endif
 +#if BAUDRATE==460800
 +  #define BAUDHEX "​A"​
 +#endif
 +#if BAUDRATE==921600
 +  #define BAUDHEX "​B"​
 +#endif
 +#if BAUDRATE==1382400
 +  #define BAUDHEX "​C"​
 +#endif
 +#ifdef BAUDRATE
 +  #ifndef BAUDHEX
 +    #error Only the following baud rates are allowed: 1200 2400 4800 9600 19200 38400 57600 115200 230400 460800 921600 1382400
 +  #endif
 +#endif
 +
 +long baudrates[] = {1200, 2400, 4800, 9600, 19200, 38400, 57600, 115200, 230400, 460800, 921600, 1382400};
 +int 
 +
 +void setup() {
 +  Serial.begin(OLD_BAUDRATE);​
 +  delay(1200);​
 +  ​
 +  #ifdef BTPIN
 +  Serial.write("​AT+PIN"​ BTPIN);
 +  delay(1200);​
 +  Serial.write("​\n"​);​
 +  while(Serial.available()) Serial.write(Serial.read());​
 +  Serial.write("​\n"​);​
 +  delay(1200);​
 +  #endif
 +  ​
 +  #ifdef NAME
 +  Serial.write("​AT+NAME"​ NAME);
 +  delay(1200);​
 +  Serial.write("​\n"​);​
 +  while(Serial.available()) Serial.write(Serial.read());​
 +  Serial.write("​\n"​);​
 +  delay(1200);​
 +  #endif
 +  ​
 +  #ifdef BAUDHEX
 +  Serial.write("​AT+BAUD"​ BAUDHEX);
 +  delay(1200);​
 +  Serial.write("​\n"​);​
 +  while(Serial.available()) Serial.write(Serial.read());​
 +  Serial.write("​\n"​);​
 +  delay(1200);​
 +  #endif
 +  ​
 +  //​Serial.end();​
 +}
 +
 +void loop() {
 +  Serial.write("​AT"​);​
 +  delay(1200);​
 +  Serial.write("​\n"​);​
 +  while(Serial.available()) Serial.write(Serial.read());​
 +  Serial.write("​\n"​);​
 +  delay(1200);​
 +  //​blinkpin(OK_PIN);​
 +}
 +
 +
 +int blinkpin(int pin) {
 +  while(true) {
 +    digitalWrite(pin,​ HIGH); ​  // set the LED on
 +    delay(1000); ​             // wait for a second
 +    digitalWrite(pin,​ LOW);    // set the LED off
 +    delay(1000); ​             // wait for a second
 +  }
 +}
 +</​code>​
  
 === Testing the JY-MCU module === === Testing the JY-MCU module ===
Line 99: Line 244:
  
 Test that you can enter data in the terminal program have it appear in the Arduino Serial Monitor and vice versa. Test that you can enter data in the terminal program have it appear in the Arduino Serial Monitor and vice versa.
 +
 +If you connected the JY-MCU to J2 then you should change the program to simply echo data back on the main serial port. You should then see any text you send from the terminal program echoed back by the Arduino. You won't be able to send text from the Arduino Serial Monitor in this configuration.
  
 === Recompiling the Bukobot firmware === === Recompiling the Bukobot firmware ===
-Now you will need to recompile the Bukobot Marlin firmware to use the new baud rate. Follow the firmware recompilation instructions here: //(to be completed)//​. Change the BAUDRATE value to match your module in Configuration.h. Compile and upload to the X3.+Now you will need to recompile the Bukobot Marlin firmware to use the new baud rate. Follow the firmware recompilation instructions here: [[software-to-install#​printer-firmware]]. Change the BAUDRATE value to match your module in Configuration.h. Compile and upload to the X3.
  
-Then change your USB serial port speed to match the new firmware speed and make sure that you can run the new firmware over USB (e.g., from Repetier Host) before trying with the wireless module. Once you have confirmed that the new firmware works, then disconnect the USB and connect the Bluetooth module to J11.+Then change your USB serial port speed to match the new firmware speed and make sure that you can run the new firmware over USB (e.g., from Repetier Host) before trying with the wireless module. Once you have confirmed that the new firmware works, then disconnect the USB and connect the Bluetooth module to J2.
  
-[Alternatively,​ the latest version of Marlin firmware now has a //​SERIAL_PORT//​ value in Configuration.h and so you can change this to 2 if want to keep the Bluetooth Module connected to the expansion pins.]+[Alternatively,​ the latest version of Marlin firmware now has a //​SERIAL_PORT//​ value in Configuration.h and so you can change this to 2 if want to keep the Bluetooth Module connected to the expansion pins. This is also what you'll want to do if you are using another RAMPS based controller board which doesn'​t have a J2/Serial Port 0 header. The current Bukobot firmware is based on an older version and so you'll need to replace MarlinSerial.h and MarlinSerial.cpp in the current firmware source with the newer files from the main Marlin github head and then #define a SERIAL_PORT value.]
  
 === Possible problems === === Possible problems ===
Line 111: Line 258:
 Repetier-Host seems to work fine.  Repetier-Host seems to work fine. 
  
-It is normal that the TX/RX LEDs on the X3 shield don't work when J11 is being used to communicate to the Arduino+It is normal that the TX/RX LEDs on the X3 shield don't work when J2 is being used to communicate to the Arduino.
- +
-The 230400 baud rate is not a even multiple of the 16MHz Arduino AtMega clock speed (unlike 250000 baud - which is the reason that they use this non-standard rate in case you've wondered). As there is a slight sampling error at this baud rate (3.5%), it may very slightly increase the error rate with longer serial cables. However, this shouldn'​t have any impact on printing as pretty much all Host software uses checksums these days to ensure that any corrupted commands are retransmitted.+
  
 ==== What about an Azteeg X1 controller? ==== ==== What about an Azteeg X1 controller? ====
Line 137: Line 282:
 The RN-XV module ​ (https://​www.sparkfun.com/​products/​10822) is based on Roving Network'​s RN-171 WiFly module and emulates an XBee module in terms of pin out; in other words, it provides a UART based serial interface. Unfortunately the RN-XV device operates at 3.3V and so requires an XBee Shield to connect it to the 5V Arduino board. I used the following shield: http://​www.seeedstudio.com/​wiki/​index.php?​title=XBee%C2%AE_Shield because it was both cheaper and smaller than the Sparkfun one (https://​www.sparkfun.com/​products/​9976). The RN-XV module ​ (https://​www.sparkfun.com/​products/​10822) is based on Roving Network'​s RN-171 WiFly module and emulates an XBee module in terms of pin out; in other words, it provides a UART based serial interface. Unfortunately the RN-XV device operates at 3.3V and so requires an XBee Shield to connect it to the 5V Arduino board. I used the following shield: http://​www.seeedstudio.com/​wiki/​index.php?​title=XBee%C2%AE_Shield because it was both cheaper and smaller than the Sparkfun one (https://​www.sparkfun.com/​products/​9976).
  
-The RN-XV module even supports the native Marlin baud rate of 250000. You can get RN-XV modules which allow the connection of a high gain Wifi antenna but I just went for the simple wire antenna version (comes presoldered).+The RN-XV module even supports the native Marlin baud rate of 250000 ​(which is an exact multiple of the ATMega'​s 16MHz clock speed and therefore has more accurate sampling). You can get RN-XV modules which allow the connection of a high gain Wifi antenna but I just went for the simple wire antenna version (comes presoldered).
  
 ==== Connecting the WiFly module to the printer controller ==== ==== Connecting the WiFly module to the printer controller ====
Line 169: Line 314:
 set comm idle 300                      # set a 5min idle timeout to disconnect set comm idle 300                      # set a 5min idle timeout to disconnect
 set comm match 10                      # flush TCP frame buffer on new line set comm match 10                      # flush TCP frame buffer on new line
-set comm size 96                       # set TCP frame flush size to Marlin max line length 
 set opt deviceid Bukobot ​              # set wifi device name (to anything you like) set opt deviceid Bukobot ​              # set wifi device name (to anything you like)
 set sys printlvl 0                     # turn off debug sent to Arduino when not connected set sys printlvl 0                     # turn off debug sent to Arduino when not connected
Line 182: Line 326:
   > Note: if your Wifi SSID or password contains spaces then replace the spaces with $ symbols.   > Note: if your Wifi SSID or password contains spaces then replace the spaces with $ symbols.
   ​   ​
 +After changing the baud rate of the Wifi module you will need to update and reload the configuration program to match.
 +
 By default the WiFly module will attempt to auto-connect with the Access Point advertising the configured SSID and use the configured WiFi password. It will then automatically use DHCP to obtain its network settings and then start listening on port 2000 for inbound connections. All this behavior can be changed by additional commands if desired. By default the WiFly module will attempt to auto-connect with the Access Point advertising the configured SSID and use the configured WiFi password. It will then automatically use DHCP to obtain its network settings and then start listening on port 2000 for inbound connections. All this behavior can be changed by additional commands if desired.
  
 ==== Connecting to the WiFly device ==== ==== Connecting to the WiFly device ====
-You now need to install a virtual COM port provider on your computer. This software will look like a normal serial port to your host software (such as Repetier) and open a TCP connection to the printer to send/​receive the resulting data.+You now need to install a virtual COM port provider on your computer. This software will look like a normal serial port to your host software (such as Repetier) and open a TCP connection to the printer to send/​receive the resulting data. The software will transparently reconnect if it needs to.
  
 On Windows I used //HW Virtual Serial Port 3// (http://​www.hw-group.com/​products/​hw_vsp/​index_en.html) which is free for private use. You simply select a new COM port, enter the WiFi module'​s IP address and TCP port (2000 by default), deselect "NVT enabled",​ select "Purge buffers when port is opened"​ and click Create COM port. You then simply configure Repetier Host to use this new COM port. On Windows I used //HW Virtual Serial Port 3// (http://​www.hw-group.com/​products/​hw_vsp/​index_en.html) which is free for private use. You simply select a new COM port, enter the WiFi module'​s IP address and TCP port (2000 by default), deselect "NVT enabled",​ select "Purge buffers when port is opened"​ and click Create COM port. You then simply configure Repetier Host to use this new COM port.
Line 195: Line 341:
  
 ==== Recompile Firmware ==== ==== Recompile Firmware ====
-As with the JY-MCU module, if you are not connecting your WiFly module to J11 on the X3 controller then you will need to recompile your Marlin printer firmware to use the correct serial port for communication. [Although you can leave the baud rate at the default 250000.]+As with the JY-MCU module, if you are not connecting your WiFly module to J2 on the X3 controller then you will need to recompile your Marlin printer firmware to use the correct serial port for communication. [Although you can leave the baud rate at the default 250000.] 
 + 
 +You can also easily connect the shield to the X3's J2 connector (Serial Port 0) by soldering on a 4-pin right-angle male header onto the bottom of the board (such as https://​www.sparkfun.com/​products/​553). You can use the Bukobot firmware unchanged if you do this.
  
 ==== Tips ==== ==== Tips ====
   - You can test your end-to-end serial connection using TeraTerm (or similar) just as described for the JY-MCU module.   - You can test your end-to-end serial connection using TeraTerm (or similar) just as described for the JY-MCU module.
   - You can also enter command mode from the WiFi side (type $$$ in rapid succession without a carriage return).   - You can also enter command mode from the WiFi side (type $$$ in rapid succession without a carriage return).
-  - You can usually configure your router/​broadband modem to always allocate the same nominated IP address to a particular wireless MAC address. Doing this means that you won't need to update your virtual COM port software with a new IP address every time the router changes its address allocation. You can use the //get mac// command on the WiFly module to display its MAC address if you can't work it out from the router.+  - You can usually configure your router/​broadband modem to always allocate the same nominated IP address to a particular wireless MAC address. Doing this means that you won't need to update your virtual COM port software with a new IP address every time the router changes its DHCP address allocation. You can use the //get mac// command on the WiFly module to display its MAC address if you can't work it out from the router.
make-your-bukobot-wireless.1353506691.txt.gz · Last modified: 2012/11/21 08:04 by buildrob