Jet 2 Wheelchair with DL5.2i Hackin: Part 2

Sponsored by GunGeek on 27 October, 2014 Micro Controllers 465 Views
Jet 2 Wheelchair with DL5.2i Hackin: Part 2

This is Part 2 of my wheelchair hacking project. Part 1 can be found here.

After reading my last post I realized that I forgot to put specs on the RC circuit (not radio control). The resistors are 1/2 watt 4.7k ohm resistors and the capacitors are 50v 1uf capacitors. Just in case you missed it the RC circuit is required for the arduino to talk or control the chair with out the chair controller dumping.

 

I got tired of taking the chair controller apart every time that I wanted to play work with it. So I decided to make a bit of a change here. I got some shielded cat 5e cable laying around so I took some of that, a terminal block and a few DB9 connectors and ran that out of the chair controller so that I can just plug stuff in. I took the two pairs of wires from the joy stick previously mentioned to a terminal block, on the other side I put two pair of the cat5 e to pins 1 through 4 on a db9 connector. Then I went from the chair controller to the other pair of cat5e cable to pins 6 to 9 on the db 9. I also took a bare db9 connector and soldered a bridge between pins 1/6, 2/7, 3/8 and 4/9. This allows me to run the wheelchair just as you normally would with the joy stick. I may take that 5v DC power down to the Arduino to power it as well so that I dont have as many cables going from my enclosure but cat 5 only has 8 wires. I will have to hack a serial cable for that.

Here is an updated picture of the current set up for the arduino and RC circuit.

You might notice another change in the RC circuit, I added some diodes. I still have a few more diodes to add onto the db9 from the Arduino but remember that my purpose here is to have multiple methods of control. The diodes are for later to prevent any voltage from going to my output pins from the arduino. I still want to pass the joystick signal to the analog input pins of the Arduino and output that data back to the chair controller. I am thinking that I will use interrupts to stop the normal console/web interface to allow the joystick to be used. Why? because if I am controlling the chair with my daughter in it (yes she thinks its hilarious) if she is about to hit something she can hit the joystick to control it herself, get us out of trouble then continue on. Unfortunately I am having issues with this and the chair controller dumping. Still more work to do there.

Oh yeah on that note I upgraded my Arduino UNO to the Arduino yun so that I can control it over wifi from the console and later have a web interface to control it as well. Yes I could have just got a wifi shield but I wanted the YUN.

As of right now I can successfully control the Arduino and chair from the console most of the time, on occasion we still get the chair controller dumping. I am looking into that and trying to find a resolution. I think it has something to do with the delay BUT I don't want to increase the delay too much. Decreasing it causes an instant dump. A quick reset of the power on the wheelchair fixes the problem as long as I make sure to set the Arduino to idle in the console.

Quick and simple here is the sketch to upload to the Arduino.

#include <Console.h>

const int ledPin = 13; // the pin that the LED is attached to
int incomingByte;      // a variable to read incoming serial data into

 #define whiteInPin A0 // define one of the left right pins
 #define blueInPin A1 // define the other left right pin
 #define brownInPin A2 // define front back pin
 #define yellowInPin A3 //define other front back pin
 
 #define whiteOutPin 3
 #define blueOutPin 5
 #define brownOutPin 6
 #define yellowOutPin 9
 

 
void setup() {
  // initialize serial communication:
  Bridge.begin();
  Console.begin();
  pinMode(whiteInPin, INPUT);
  pinMode(blueInPin, INPUT);
  pinMode(brownInPin, INPUT);
  pinMode(yellowInPin, INPUT);
  pinMode(whiteOutPin, OUTPUT); 
  pinMode(blueOutPin, OUTPUT); 
  pinMode(brownOutPin, OUTPUT);
  pinMode(yellowOutPin, OUTPUT);
  funcStop();
  while (!Console){
    ; // wait for Console port to connect.
  }
  Console.println("You're connected to the Console!!!!");
  Console.println("Yun YODA WheelChair TEST");
  // initialize the LED pin as an output:
  pinMode(ledPin, OUTPUT);
}

void loop() {
  // see if there's incoming serial data:
  if (Console.available() > 0) {
    // read the oldest byte in the serial buffer:
    incomingByte = Console.read();
    // if it's a 0 stop
    if (incomingByte == '0') {
      digitalWrite(ledPin, LOW);
      funcStop();
      Console.println("We Are Stopped");
    }
    // 1 is go forward
    if (incomingByte == '1') {
      digitalWrite(ledPin, HIGH);
      funcStraight(54,217);
      Console.println("We are moving full forward");
    }
    //2 is to rotate right
    if (incomingByte == '2') {
      digitalWrite(ledPin, HIGH);
      funcRotate(54,217);
      Console.println("We are rotating right");
    }
    // 3 is rotate left
    if (incomingByte == '3') {
      digitalWrite(ledPin, HIGH);
      funcRotate(217,54);
      Console.println("We are rotating left");
    }
    // 4 is back up
    if (incomingByte == '4') {
      digitalWrite(ledPin, HIGH);
      funcStraight(217,54);
      Console.println("We should be backing up");
    }

  }

  delay(10);
}

void funcRotate(/*unsigned int delayms,*/ unsigned int powerWhite, unsigned int powerBlue){
  analogWrite(whiteOutPin, powerWhite);
  analogWrite(blueOutPin, powerBlue);
  analogWrite(brownOutPin, 133);
  analogWrite(yellowOutPin, 133);
  //delay(delayms);
  //analogWrite(whiteOutPin, 133);
 // analogWrite(blueOutPin, 133);
  //analogWrite(brownOutPin, 133);
  //analogWrite(yellowOutPin, 133);  
}

void funcStraight(/*unsigned int delayms,*/ unsigned int powerBrown, unsigned int powerYellow){
  analogWrite(whiteOutPin, 133);
  analogWrite(blueOutPin, 133);
  analogWrite(brownOutPin, powerBrown);
  analogWrite(yellowOutPin, powerYellow);
  //delay(delayms);
  //analogWrite(whiteOutPin, 133);
  //analogWrite(blueOutPin, 133);
  //analogWrite(brownOutPin, 133);
  //analogWrite(yellowOutPin, 133); 
}

void funcTurn(unsigned int delayms, unsigned int powerWhite, unsigned int powerBlue, unsigned int powerBrown, unsigned int powerYellow){
  analogWrite(whiteOutPin, powerWhite);
  analogWrite(blueOutPin, powerBlue);
  analogWrite(brownOutPin, powerBrown);
  analogWrite(yellowOutPin, powerYellow);
//  delay(delayms);
 // analogWrite(whiteOutPin, 133);
 /// analogWrite(blueOutPin, 133); 
 // analogWrite(brownOutPin, 133);
  //analogWrite(yellowOutPin, 133);
}

void funcStop(){
  analogWrite(whiteOutPin, 133);
  analogWrite(blueOutPin, 133); 
  analogWrite(brownOutPin, 133);
  analogWrite(yellowOutPin, 133);
}

void funcOff (){
  analogWrite(whiteOutPin, 0);
  analogWrite(blueOutPin, 0); 
  analogWrite(brownOutPin, 0);
  analogWrite(yellowOutPin, 0);
}

My next steps are to get try to get the joystick to work using interrupts to detect any change in voltage on the input pins. There will be more on that in the next post.

Comments

Comments for unregistered members are disabled

Author

GunGeek

GunGeek

Most Recent Articles