DIY Remote Controller for Hexdrake
DIY Remote Controller for Hexdrake
DIY Remote Controller for Hexdrake
DIY Remote Controller for Hexdrake
DIY Remote Controller for Hexdrake
DIY Remote Controller for Hexdrake
DIY Remote Controller for Hexdrake
DIY Remote Controller for Hexdrake
Show All 8 Items

Hello, I'm David and this is my second instructable :) .

It is a continuation of my first instructable, where I shown you how I constructed my little hexapod, Hexdrake:

http://www.instructables.com/id/DIY-handmade-Hexap...

In this new instructable I'll show you how I made this protoype controller for Hexdrake with 2 joysticks, a slider pot, and an accelerometer to control completly the hexapod.

So there we go.

Step 1: Parts needed:

DIY Remote Controller for Hexdrake
DIY Remote Controller for Hexdrake
DIY Remote Controller for Hexdrake
DIY Remote Controller for Hexdrake
DIY Remote Controller for Hexdrake
DIY Remote Controller for Hexdrake
  • Electronics
  • Copper PCB: http://www.ebay.es/itm/10-15cm-10cmx15cm-Single-PC...

  • 2 PS2 Joysticks: http://www.ebay.es/itm/Brand-New-Analog-Joystick-C...

  • Screw terminal blocks: http://www.ebay.es/itm/3-x-DG301-Screw-Terminal-Bl...

  • 10K ohm resistors: http://www.ebay.es/itm/100pcs-1-4w-Watt-10K-ohm-1...

  • Bread board(Y use one with 700 points): http://www.ebay.es/itm/Mini-PCB-Breadboard-700-Poi...

  • 50Kohm slide pot: http://www.ebay.com/itm/2pcs-50K-ohm-Potentiometer...

  • Arduino nano V3.0: http://www.ebay.es/itm/UNO-R3-Mega-2560-Pro-Mini-N...

  • Another arduino to be the receiver. I use an arduino UNO: http://www.ebay.es/itm/UNO-R3-Mega-2560-Pro-Mini-N...

  • MMA7361 3 axis accelerometer: http://www.ebay.es/itm/New-MMA7361-Angle-Sensor-Ac...

  • NRF24L01 2,4 GHz Transceiver module: http://www.ebay.es/itm/2x-NRF24L01-2-4GHz-Antenna-...

  • A lot of cables: http://www.ebay.es/itm/65Pcs-Male-to-Male-Solderle...

  • Software:
  • Arduino IDE
  • Tools:
  • Saw.

  • Lime.

  • Drill (Dremel).

  • Screwdriver.

    Step 2: Making the Joysticks boards:

    DIY Remote Controller for Hexdrake
    DIY Remote Controller for Hexdrake
    DIY Remote Controller for Hexdrake
    DIY Remote Controller for Hexdrake
    DIY Remote Controller for Hexdrake
    DIY Remote Controller for Hexdrake

    Tools for this step:

    Saw, lime. drill.

    I designed these boards using Inkscape. These boards have the appropriate size for the original joysticks of the PS2 controllers. The main reason I designed these small boards is to simplify the connections between terminals of the potentiometers and the button incorporated with the arduino boards. The board includes a 10k ohm resistor, making the connection between the button and the arduino only needs a cable.

    The first step is cut a piece of copper pcb the size of the design. Later cut the drilling template and place it in the copper pcb. This template marks the place where you have to make the holes for the components.

    Now it's time to draw the tracks. I used a a sticker to mark the tracks. The next step is put the PCB in the acid and when done thoroughly clean the PCB. And the final step is solder the joystick and the resistor and put the decorative stickers.

    The screw terminal blocks conections are:

    GND ---> GND of arduino

    Vin ------> 5V of arduino

    X ------> The x-axis potentiometer to an analog pin of arduino(for example A0)

    Y ------> The y-axis potentiometer to an analog pin of arduino(for example A1)

    B ------> Connect the button to a digital pin of arduino.(For example D8)

    Step 3: How to use the 2.4GHz modules?:

    DIY Remote Controller for Hexdrake
    DIY Remote Controller for Hexdrake
    DIY Remote Controller for Hexdrake
    DIY Remote Controller for Hexdrake
    DIY Remote Controller for Hexdrake
    DIY Remote Controller for Hexdrake
    DIY Remote Controller for Hexdrake
    Show All 7 Items

    I use two nRF24L01 2.4GHz Radio/Wireless Transceivers to comunicate the two arduinos. The range of this modules are from 50 feet to 2000 feet distances. These 2.4 GHz Radio modules are based on the Nordic Semiconductor nRF24L01+ chip. The Nordic nRF24L01+ integrates a complete 2.4GHz RF transceiver, RF synthesizer, and baseband logic including the Enhanced ShockBurst hardware protocol accelerator supporting a high-speed SPI interface. These low-power short-range modude have a built-in Antenna.

    These transcevers use the 2.4 GHz unlicensed band like many WiFi routers, some cordless phones etc.These module send and receive data in 'packets' of several bytes at a time. There is built-in error correction and resending, and it is possible to have one unit communicate with up to 6 other similar units at the same time. The pinout as shown in diagram tha you can see in the photos and a table with the coneections to diferent models of arduinos.

    *IMPORTANT* :These modules VCC connection must go to 3.3V not 5.0V


    I will show an example of transmit and receive software below for one joystick:

    Transmiter:

    /*
    - WHAT IT DOES: Reads Analog values on A0, A1 and transmits them over a nRF24L01 Radio Link to another transceiver. 1 - GND 2 - VCC 3.3V !!! NOT 5V 3 - CE to Arduino pin 9 4 - CSN to Arduino pin 10 5 - SCK to Arduino pin 13 6 - MOSI to Arduino pin 11 7 - MISO to Arduino pin 12 8 - UNUSED - Analog Joystick: GND to Arduino GND VCC to Arduino +5V X Pot to Arduino A0 Y Pot to Arduino A1 */ /*-----( Import needed libraries )-----*/

    #include
    #include

    #include

    /*-----( Declare Constants and Pin Numbers )-----*/
    #define CE_PIN 9 #define CSN_PIN 10 #define JOYSTICK_X A0 #define JOYSTICK_Y A1

    // NOTE: the "LL" at the end of the constant is "LongLong" type const uint64_t pipe = 0xE8E8F0F0E1LL; // Define the transmit pipe

    /*-----( Declare objects )-----*/ RF24 radio(CE_PIN, CSN_PIN); // Create a Radio /*-----( Declare Variables )-----*/ int joystick[2]; // 2 element array holding Joystick readings

    void setup() /****** SETUP: RUNS ONCE ******/ { Serial.begin(9600); radio.begin(); radio.openWritingPipe(pipe); }//--(end setup )--- void loop() /****** LOOP: RUNS CONSTANTLY ******/ { joystick[0] = analogRead(JOYSTICK_X); joystick[1] = analogRead(JOYSTICK_Y); radio.write( joystick, sizeof(joystick) ); }//--(end main loop )--


    Receiver:

    /*
    - WHAT IT DOES: Receives data from another transceiver with 2 Analog values from a Joystick Displays received values on Serial Monitor 1 - GND 2 - VCC 3.3V !!! NOT 5V 3 - CE to Arduino pin 9 4 - CSN to Arduino pin 10 5 - SCK to Arduino pin 13 6 - MOSI to Arduino pin 11 7 - MISO to Arduino pin 12 8 - UNUSED

    /*-----( Import needed libraries )-----*/

    #include

    #include

    #include

    /*-----( Declare Constants and Pin Numbers )-----*/
    #define CE_PIN 9 #define CSN_PIN 10

    // NOTE: the "LL" at the end of the constant is "LongLong" type const uint64_t pipe = 0xE8E8F0F0E1LL; // Define the transmit pipe

    /*-----( Declare objects )-----*/ RF24 radio(CE_PIN, CSN_PIN); // Create a Radio

    /*-----( Declare Variables )-----*/ int joystick[2]; // 2 element array holding Joystick readings

    void setup() /****** SETUP: RUNS ONCE ******/ { Serial.begin(9600); delay(1000); Serial.println("Nrf24L01 Receiver Starting"); radio.begin(); radio.openReadingPipe(1,pipe); radio.startListening();; }//--(end setup )---

    void loop() /****** LOOP: RUNS CONSTANTLY ******/ { if ( radio.available() ) { // Read the data payload until we've received everything bool done = false; while (!done) { // Fetch the data payload done = radio.read( joystick, sizeof(joystick) ); Serial.print("X = "); Serial.print(joystick[0]); Serial.print(" Y = "); Serial.println(joystick[1]); } } else { Serial.println("No radio available"); } }//--(end main loop )---

    DIY Remote Controller for Hexdrake
    nRF24L01P_Product_Specification_1_0.pdf1 MB
    DIY Remote Controller for Hexdrake
    RF24-master.zip203 KB

    Step 4: Connecting the joystick and the linear potentiometer:

    DIY Remote Controller for Hexdrake
    DIY Remote Controller for Hexdrake
    DIY Remote Controller for Hexdrake
    DIY Remote Controller for Hexdrake
    DIY Remote Controller for Hexdrake
    DIY Remote Controller for Hexdrake
    DIY Remote Controller for Hexdrake
    DIY Remote Controller for Hexdrake
    DIY Remote Controller for Hexdrake
    DIY Remote Controller for Hexdrake
    Show All 10 Items

    To make the prototype of the controller I use a breadboard to connect everything. I have attached the boards of the joysticks and the linear potentiometer elastic bands jaja. I first thought of making a prototype with all elements before modifying a PS2 controller adding them the accelerometer, linear potentiometer, etc..

    Simply connect the x,y GND and Vin terminals of both joystick to de 5v, GND, A0 and A1 pins of arduino. And the linear pot in the same way.

    Step 5: How to use the MMA7361 accelerometer?:

    DIY Remote Controller for Hexdrake
    DIY Remote Controller for Hexdrake
    DIY Remote Controller for Hexdrake
    DIY Remote Controller for Hexdrake
    DIY Remote Controller for Hexdrake
    DIY Remote Controller for Hexdrake
    DIY Remote Controller for Hexdrake
    DIY Remote Controller for Hexdrake
    DIY Remote Controller for Hexdrake
    Show All 9 Items

    It's a breakout board for Freescale’s MMA7361L three-axis analog MEMS accelerometer. The sensor requires a very low amount of power and has a g-select input which switches the accelerometer between ±1.5g and ±6g measurement ranges. Other features include a sleep mode, signal conditioning, a 1-pole low pass filter, temperature compensation, self test, and 0g-detect which detects linear freefall. Zero-g offset and sensitivity are factory set and require no external devices.

    It's specifications are:

  • Supports 2.2V ~ 3.6V or 5V voltage input.
  • Two selectable measuring ranges (±1.5g, ±6g)
  • Breadboard friendly - 0.1" pitch header
  • Low current consumption: 400 µA
  • Sleep mode: 3 µA
  • Low voltage operation: 2.2 V - 3.6 V
  • High sensitivity (800 mV/g at 1.5g)
  • Fast turn on time (0.5 ms enable response time)
  • Self test for freefall detect diagnosis
  • 0g-Detect for freefall protection
  • Signal conditioning with low pass filter
  • Robust design, high shocks survivability

    With the AcceleroMMA7361 library it's so easy to use this tiny module. The commands you can use with this library are:

  • void begin ()
  • void begin (int sleepPin, int selfTestPin, int zeroGPin, int gSelectPin, int xPin, int yPin, int zPin)
  • int getXRaw ()
  • getXRaw(): Returns the raw data from the X-axis analog I/O port of the Arduino as an integer
  • int getYRaw ()
  • getYRaw(): Returns the raw data from the Y-axis analog I/O port of the Arduino as an integer
  • int getZRaw ()
  • getZRaw(): Returns the raw data from the Z-axis analog I/O port of the Arduino as an integer
  • int getXVolt ()
  • getXVolt(): Returns the voltage in mV from the X-axis analog I/O port of the Arduino as a integer
  • int getYVolt ()
  • getYVolt(): Returns the voltage in mV from the Y-axis analog I/O port of the Arduino as a integer
  • int getZVolt ()
  • getZVolt(): Returns the voltage in mV from the Z-axis analog I/O port of the Arduino as a integer
  • int getXAccel ()
  • getXAccel(): Returns the acceleration of the X-axis as a int (1 G = 100.00)
  • int getYAccel ()
  • getYAccel(): Returns the acceleration of the Y-axis as a int (1 G = 100.00)
  • int getZAccel ()
  • getZAccel(): Returns the acceleration of the Z-axis as a int (1 G = 100.00)
  • void getAccelXYZ (int _XAxis, int _YAxis, int _ZAxis)
  • getAccelXYZ(int _XAxis, int _YAxis, int _ZAxis) returns all axis at once as pointers
  • int getTotalVector ()
  • getTotalVector returns the magnitude of the total acceleration vector as an integer
  • void setOffSets (int xOffSet, int yOffSet, int zOffSet)
  • void calibrate ()
  • void setARefVoltage (double _refV)
  • void setAveraging (int avg)
  • setAveraging(int avg): Sets how many samples have to be averaged in getAccel default is 10.
  • int getOrientation ()
  • void setSensitivity (boolean sensi)
  • setSensitivity sets the sensitivity to +/-1.5 G (HIGH) or +/-6 G (LOW) using a boolean HIGH (1.5 G) or LOW (6 G)
  • void sleep ()
  • sleep lets the device sleep (when device is sleeping already this does nothing)
  • void wake ()
  • wake enables the device after sleep (when device is not sleeping this does nothing) there is a 2 ms delay, due to enable response time (datasheet: typ 0.5 ms, max 2 ms)

    The library have 3 simple examples. One gets the accelerations in each axis, the second gets the angle and the third the voltage. I used the "RawData" to get the angle of each axis othe controller to control the inclination:

    #include

    AcceleroMMA7361 accelero; int x; int y; int z; void setup() { Serial.begin(9600); accelero.begin(8, 7, 6, 5, A5, A6, A7); accelero.setSensitivity(HIGH);//sets the sensitivity to +/-6G accelero.calibrate(); }

    void loop() { x = accelero.getXRaw(); y = accelero.getYRaw(); z = accelero.getZRaw(); Serial.print("\nx: "); Serial.print(x); Serial.print("\ty: "); Serial.print(y); Serial.print("\tz: "); Serial.print(z); delay(500); //(make it readable) }

    DIY Remote Controller for Hexdrake
    AcceleroMMA7361_v0.8b.zip92 KB
    DIY Remote Controller for Hexdrake
    refman.pdf82 KB

    Step 6: Put all together:

    DIY Remote Controller for Hexdrake
    DIY Remote Controller for Hexdrake
    DIY Remote Controller for Hexdrake
    DIY Remote Controller for Hexdrake
    DIY Remote Controller for Hexdrake
    DIY Remote Controller for Hexdrake
    DIY Remote Controller for Hexdrake
    Show All 7 Items

    All that remains is to place the accelerometer on the remote controller and connect it to the arduino nano as in the previous step.

    Now it's time to program!!!

    Step 7: Programming the remote controller:

    DIY Remote Controller for Hexdrake
    DIY Remote Controller for Hexdrake
    DIY Remote Controller for Hexdrake
    DIY Remote Controller for Hexdrake
    DIY Remote Controller for Hexdrake
    DIY Remote Controller for Hexdrake

    Using all prior learning of each module only need to adapt the programs to the characteristics of the remote control by linking in two programs: one for the arduino remote control works as a transmitter and another program for arduino hexapod operates as a receiver.

    According to the motion limits of the servos, that I got from my previous instructable, you must use the map command arduino to convert the values of the potentiometers and the accelerometer within the minimum limit range values of motion of the servos. Being as follows:

    values[0] = map(values[0], 23, 1000, 900, 1500); //Value from slider pot

    values[1] = map(values[1], 23, 1000, 2100, 1540); //Value from slider pot
    values[3] = map(values[3], 1, 1033, -295, 295); //Value from y-axis of right joystick values[4] = map(values[4], 1, 1023, -295, 295); //Value from y-axis of left joystick values[5] = map(values[5], 1, 1023, -360, 360); //Value from x-axis of left joystick values[6] = map(values[6], 170, 500, -360, 360); //Value from x-axis of the accelerometer values[7] = map(values[7], 170, 510, -360, 360); //Value from y-axis of the accelerometer

    Using one of the buttons on one of the joysticks I wanted to use the example shown on arduino page that consists in counting the number of times that a button is pressed to create various modes in which the hexapod will move.

    http://arduino.cc/en/Tutorial/ButtonStateChange

    /* State change detection (edge detection)
    This example shows how to detect when a button or button changes from off to on and on to off. */ // this constant won't change: const int buttonPin = 2; // the pin that the pushbutton is attached to const int ledPin = 13; // the pin that the LED is attached to // Variables will change: int buttonPushCounter = 0; // counter for the number of button presses int buttonState = 0; // current state of the button int lastButtonState = 0; // previous state of the button void setup() { // initialize the button pin as a input: pinMode(buttonPin, INPUT); // initialize the LED as an output: pinMode(ledPin, OUTPUT); // initialize serial communication: Serial.begin(9600); } void loop() { // read the pushbutton input pin: buttonState = digitalRead(buttonPin); // compare the buttonState to its previous state if (buttonState != lastButtonState) { // if the state has changed, increment the counter if (buttonState == HIGH) { // if the current state is HIGH then the button // wend from off to on: buttonPushCounter++; Serial.println("on"); Serial.print("number of button pushes: "); Serial.println(buttonPushCounter); } else { // if the current state is LOW then the button // wend from on to off: Serial.println("off"); } } // save the current state as the last state, //for next time through the loop lastButtonState = buttonState; // turns on the LED every four button pushes by // checking the modulo of the button push counter. // the modulo function gives you the remainder of // the division of two numbers: if (buttonPushCounter % 4 == 0) { digitalWrite(ledPin, HIGH); } else { digitalWrite(ledPin, LOW); } }

    I convert this example and adapt to my sketchs of the remote controller and to the receptor. So

    So I create three modes of movements:

  • The first one allows the linear potentiometer and joysticks move the hexapod
  • The second allows joysticks, the potentiometer and accelerometer move the hexapod
  • And the last mode let move hte hexapod walk, walk backwards,etc moving the two joystick simultaneously

  •  
     

    Tag cloud

    make build easy simple arduino making homemade solar laser printed portable cheap mini building custom cardboard wooden create super lego turn paracord chocolate your paper light intel