User Tools

Site Tools


make-your-bukobot-wireless

Link to this comparison view

make-your-bukobot-wireless [2012/11/26 03:46]
buildrob
make-your-bukobot-wireless [2013/01/02 03:05] (current)
buildrob
Line 10: 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., https://​www.sparkfun.com/​products/​9429 or 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 90: 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 101: 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 113: 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.
  
 ==== What about an Azteeg X1 controller? ==== ==== What about an Azteeg X1 controller? ====
Line 181: 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.
  
Line 194: 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 ​J11 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.+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 ====
make-your-bukobot-wireless.1353923196.txt.gz · Last modified: 2012/11/26 03:46 by buildrob