Posted on by

BLUEsat’s  NUMBAT rover is due for completion early next year, and it needs a new and updated control system to go along with it. That’s where the prototype for the new joystick comes in.

First, let me take you through the previous controllers. The BLUEtongue rover was controlled via two different Xbox controllers; one to control the movement of its wheels, and the other to control the arm and claw.

The one I was to make was to incorporate all the above features onto one single joystick. An Xbox controller does not have sufficient number of buttons so creating one using an Arduino seemed to be the best option.

Speed Control

The first task was to implement speed control. Initially, I had an idea that this could be achieved by using a potentiometer as the speed control, but I wasn’t sure how. With a bit of experimentation and fumbling about, I realised how it could be done.

Firstly, to control the old space rover, two different joysticks are used, one to control the rover’s movement in the ‘Y-axis’ and the other in the ‘X-axis’.  This is done to ensure that the rover moves precisely forwards or backwards without any deviation. This was a good method to control the movement and thus I will not change this.

A joystick itself is simply two different potentiometers combined, one for each axis. They both work simultaneously to provide a reading. The values of both axis range from 0-1023, as does with any potentiometer. Therefore, the resting position of a joystick is somewhere between 500 – 530 (this is where the velocity is zero). With this idea in mind, as an example, if the joystick reads a value greater than 530 in the X and Y-axis, it means that the joystick has been move to the top-right position and the rover should also move towards the North-East direction. Using this, I can get the rover to move in any direction I want, so what about the speed control?

Arduino joystick attachment overlaid with 2D graph axis
This illustrates the direction of both potentiometer ranges for the axes

This is where the second potentiometer comes in. As mentioned above, it has a range from 0 – 1023. When the reading is 0, the velocity of the rover should be zero and when the reading is 1023, the rover should be moving at max speed. Thus, I needed a way to map the readings from the joysticks to the respective maximum boundaries set by the potentiometer. Lucky for me, there is a ‘map()’ function in the Arduino library that does just that. It, in simplicity remaps  a number from from one range to another. Testing this  on the BLUEtongue rover proved that this method worked and slowed the rover down to a specific speed depending on the reading from the potentiometer.

A small snippet of this implementation is illustrated below.


int yaxis = analogRead(A0);
int xaxis = analogRead(A1);
//Sensor reading from the potentiometer
double sensorValue = analogRead(A2);
//remapping the yaxis vector between 0 and the reading form the potentiometer reading
double remapy;
//remapping the xaxis vector between 0 and the reading form the potentiometer reading
double remapx;

if((yaxis >= 493 && yaxis <= 553)&&(xaxis >= 493 && xaxis <= 553)){ //No movement
      command.drive_vector.y = 0.00; 
      command.drive_vector.x = 0.00;
 }else if((yaxis >= 553)&&(xaxis >= 493 && xaxis <= 553)){ //FORWARDS
      remapy = map(yaxis, 553, 1023,0, sensorValue);
      command.drive_vector.y = remapy/1023; 
      command.drive_vector.x = 0.00; 
 }else if((yaxis <= 493)&&(xaxis >= 493 && xaxis <= 553)){ //BACKWARDS
      remapy = map(yaxis, 493, 0,0, sensorValue);
      command.drive_vector.y = -(remapy/1023);
      command.drive_vector.x = 0.00;
else if(yaxis >= 553 && xaxis >= 553){ //TOP-LEFT
      remapy = map(yaxis, 553,1023,0,sensorValue);
      remapx = map(xaxis, 553, 1023,0, sensorValue); 
      command.drive_vector.y = (remapy)/1023;
      command.drive_vector.x = (remapx)/1023; 
 }else if(yaxis >= 553 && xaxis <= 493){ //TOP-RIGHT
      remapy = map(yaxis, 553,1023,0,sensorValue);
      remapx = map(xaxis, 493, 0,0, sensorValue);
      command.drive_vector.y = (remapy)/1023;
      command.drive_vector.x = -((remapx)/1023);

It basically does the same thing as aforementioned, detecting the direction each joystick faces and maps them to their respective direction and velocity for the rover.


Now with the speed control done, next was to implement buttons to control the extending and retraction of the arm, claws and their rotation. This was just using buttons and depending on what the PWM (pulse width modulation) value was for the specific action. This has been mostly completed, however some revision is still required.

Webcam switching is also something that is to be completed via buttons on the joystick itself, but it has yet to begin implementation.

A code snippet of the button implementation is shown below.

if(digitalRead(ARM_LOWER_EXTEND) == HIGH){
    command.arm_lower_pwm = 2000; //Extend the lower arm
}else if(digitalRead(ARM_LOWER_RETRACT) == HIGH){
    command.arm_lower_pwm = 1000;//Retract the lower arm
    command.arm_lower_pwm = 1500;

if(digitalRead(ARM_UPPER_EXTEND) == HIGH){
    command.arm_upper_pwm = 1000; //Extend the upper arm
}else if(digitalRead(ARM_UPPER_RETRACT) == HIGH){
    command.arm_upper_pwm = 2000;//Retract the upper arm
    command.arm_upper_pwm = 1500;

In the Near Future

Prototype Joystick for BLUEsat UNSW's NUMBAT Rover - A breadboard with buttons on it, two joysticks and an arduino uno.
This is what the joystick currently looks like

As shown above, that is what the prototype currently looks like. There are a lot of buttons, and they will continue to increase. After the prototype is confirmed to be working properly to a satisfactory level, a casing for it will being to be designed. The design would have to incorporate space for all of the button, the two joysticks as well as the potentiometer. Not only that, they must all be in comfortable positions that are easy to access without causing any hand strain due to long time usage. This design will then be 3D printed when decided upon. Hopefully the prototype joystick will have a home soon.