Thursday, 16 June 2016

Hacking a power wheelchair

Awhile back I purchased a Quickie Explore electric wheelchair with the intentions of turning it into a large outdoor robot platform to continue my explorations with GPS and mounting such things as a paintball marker to it. An electric wheelchair is the next logical progression in the series of outdoor robots that I have started and never ultimately finished. I keep getting near completion of at least a basic functioning base when something better comes along. Anyways, I think and hope that along with Raven (Which I have made some more progress on, or had anyways until the rear differential stripped out on the savage flux RC car base) this will be the final outdoor robot for a while. I have always dreamed of having an electric wheelchair with which to hack into an outdoor base because they are close to an ideal large outdoor base. Lots of battery life and payload capacity, like LOTS, very good motor controls built in, and very stable. I consider this and Raven to be parallel developments, as while they are both outdoor bots, they have quite different properties, raven being reletively small and very very quick and this one being much larger, slower and longer lasting. Perhaps in the future when I become a better programmer I will be able to make use of Raven's speed, but for now slow and stable are very good traits to have in an outdoor robot. Anyways, I had anticipated using the stock motor controller and joystick assembly, but taking the actual joystick out and emulating it with an arduino and some additional electronics. Before I opened it up, I thought that the joystick would use a couple of potentiometers as most joysticks do, and which I would be able to replace with a couple of Digital Potentiometers that sparkfun sells.
Well when I opened it up that was not the case at all. There was a large circuit board holding a bunch of electronics and an 8 wire ribbon cable attaching to a very scary looking joystick. After doing a bunch of research on the net, I found out that in fact it is a sealed unit that contains not 2 but 4 hall effect sensors which it uses as outputs. Each direction (X and Y) have two hall effect sensors that output similar but not identical signals as a sort of failsafe. The controller looks for the signals to be slightly different within a tollerance but mostly the same and if either signal strays too much from its partner, the controller detects this change and locks out. So in order to emulate the joystick's outputs I need true analogue voltage fed into the control board. I am not sure yet, time and some testing will tell, but I may be able to feed the same voltage into both of the pins that the board expects to see slightly varrying signals from the two hall effect sensors and recalibrate the control board to think that is normal. If I can then I can get away with only needing two analogue signals instead of the 4 the joystick currently feeds the board. Time shall tell. 

Enough of the boring postulating and onto the pictures of what I have got going right now!
Last night I was able to work some on the practical hacking of the joystick assembly. 
I cut the ribbon connector connnecting the joystick to the control board and soldered some 0.1" male pin headers to both the control board and joystick ends so that I can easily attach them to a breadboard and mess around with the connections and listen in with an osciliscope or multimeter to whats going on over the various connections. I was able to actually find a pinout (I think anyways) of the joystick online so I should be able to see whats going with relitive ease. Note hot glue as a very effective strain relief.
That done, I started working on the arduino/emulation electronics. Because a true analogue voltage and not a messy PWM quazi-analogue signal like the arduino's analogueOut function provides is needed to emulate the joystick, I chose the mcp4725 12 bit I2C DAC to provide that. I tried to find a 4 channel digital to analogue converter that I could use with the Arduino to no avail. The mcp4725 is an I2C device, but unfortunately it only comes in assignable to two I2C addresses. (Not entirely true, Adafruit makes a breakout board that has the addresses of 0x62 and 0x63 and sparkfun makes a breakout board that has addresses of 0x60 and 0x61 but I am cheap and impaitent. So I just got some clones of the sparkfun boards from some Chinese vendor on, meaning that I will only end up with two possible assignable addresses). So if it proves that I do need to provide all 4 signals to the control board instead of just two, I will end up having to use two arduinos, each driving two mcp4725s to get all of the signals.
I downloaded Adafruit's mcp4725 library and uploaded the triangle wave demo sketch to the arduino, connected up a mcp4725 and.... Nothing. I had changed the I2C address to 0x60 in the example because the amazon clones of the breakout boards were clones of the sparkfun boards so I foolishly thought that they would have the same addresses as the sparkfun ones. A friend of mine with more paitence than me read a bit of the datasheet and rewrote the program to initialize 6 mcp4725 on all six (apparently the maker of the chip actually allows 6 addresses depending on the version, tho only 4 are commonly availible. Sparkfun's and Adafruit's) availible addresses and give a constant voltage instead of a triangle wave, and this time we had some action! Turns out the clones I have have the adafruit addresses of 0x62 and 0x63!
To change the address on the breakout boards, you have to cut two jumper wires on the underside of the board and change one solder blob on the topside. I did that and wired up the two boards to the arduino, wired the outputs to two multimeters (Thats where those bare wires sticking up go when everything is all connected up) and uploaded this sketch to the arduino:

#include <Wire.h>
#include <Adafruit_MCP4725.h>

Adafruit_MCP4725 dac62;
Adafruit_MCP4725 dac63;

void setup(void)

void loop(void)
      dac62.setVoltage(4095, false);
      dac63.setVoltage(1024, false);

Thats about as simple as it gets. The values are based on a formula you can find in the datasheet, but pretty well 4095 is 100% of the supply voltage and 1024 is about 25%. In this case it spat out 4.96v and 1.24v. Pretty freaking decent. Unfortunately I don't have any pictures or video of that part happening, but it all worked out perfectly. Thats as far as that part has gotten, it will probably stay in about that state on the breadboard until some more testing with the wheelchair is complete.

Speaking of wheelchair testing, before I got too carried away, I wanted to make sure all my solder connections were all good and some extra length of wire between the joystick and controller was going to be OK so I got everything all together and hooked up on the wheelchair and tried it all out.
The batteries are just sitting behind the battery bay because they are a huge pain to get in there and I wasn't planning on driving it around anyways.
Controller plugged into the actual motor control box at the front (You can't really see it that well in the pic. Normally it is covered by a nice protective metal cover as well.
And the hacked up joystick controller sitting on top connected to the joystick by a nice ribbon cable I had sitting around.
Annnnnnddddd heres the video of the quick test I did to make sure everything is still running tip top. 
Next steps are to drive it over to where I can set up my computer, osciliscope, a couple multimeters and all the arduino stuff and get sniffing on what I need to emulate and see if the joystick controller will take the signals from my mcp4725s like they are the joystick. Hopefully it all works!


  1. Thank you for sharing your work. I recently came across a Jazzy Sport 2, but I don't have the joystick controller. Any advice on hacking (with Arduino) the 4-prong adapter connected to the motor controller? Is there anyway around having to purchase (and hack) the joystick?

    1. Hi Skyler!

      From the research that I have done, I understand that most wheelchair makers use some sort of proprietary closed interface to connect from the joystick controller to the motor controller box. My strengths certainly do not lie in programming or reverse engineering protocols, that stuff is far over my head. I chose the solution above because it played well into my relative strength in electronics. So I am sorry but I cannot offer you any advice about sniffing out the jazzy protocols. Best of luck on your project, make sure the first few times you hook power up the drive wheels are off the ground. Little robots bump into the wall. Big ones tend to make holes :P

  2. Hello it is a very good work.Do you have the datasheet of the joystick?
    i am currently also confused with the joystick