Design – Control Interface

roverctrl2I have several ideas for the control interface. I have decided that it should be accessible on a tablet device, and thus the easiest way to do this is to create a web page and use JavaScript to send commands to the Pi.

According to this article, the Mars rover drivers plan out a course using a combination of data, which they then run a simulation on and adjust. Once the course is ready, the driver gives the signal and the rover follows the pre-assigned instructions. It makes sense that the rover is not under manual control since there is about a 4 minute delay sending signals to the red planet.

In order to make it interesting and not too complicated however I have decided not to simulate this entirely. I do however think that the user should have to input instructions and then execute them which will provide more of an interesting and simulative experience than if they were just driving the rover around like it were an RC car.

In its simplest form, this would involve the user inputting a direction and angle of rotation and a distance or amount of degrees and then sending the command. The tilt for the camera could probably be activated as soon as the button is pressed.

homofaciens.deOn the website (home of the RoboSpatium as mentioned in a previous post), the control system for the robots is fairly simple and easy to use. Additionally, he has provided the source code and instructions on how to set up Apache2 on the Pi to be able to communicate with another computer and send and receive instructions.


Working with the Electronics

I decided to use a stepper motor to control the wheels of the rover. A stepper motor unlike a regular DC motor can be told to move in specific increments and stop at various angles. I thought that this would be useful so that the operator could tell the rover to move its wheels forward a certain number of steps and then stop.

DSC_0132editI researched and purchased a driver board and motor that I had found instructions for the usage of together.

The motor had two screw fixings on it so that it would also be easy to mount upon the body of the rover too.

I soldered pins onto the driver board and connected it up to the Pi, power supply and motor, and it showed me via an LED that it was receiving power.

I then sent ‘on’ and ‘off’ signals to the appropriate GPIO pin on the raspberry pi, but this failed to activate the motor at all.

Meanwhile I decided to see if I could work the servo that would tilt the camera. Whereas the motor requires a separate driver board, the pi can directly drive servos from its GPIO pins.

My research found that the different lengths of pulses sent to the GPIO tell the server what position to move to:

By default, the Pi sends a pulse that lasts 20ms, so using Python, a code needed to be written that changed the pulse length, and that means setting the pin to use PWM (Pulse Width Modulation). Doing this, you can change the duty cycle (or the length of each pulse) to what it needs to be to direct the servo to move to a specific angle.

This gives me several options in letting the user control the camera tilt:

  1. Give them 3 positions to be able to move to – up, down and central
  2. Calculate some in between values and let them select from a wider range of angles
  3. Create a script that when they choose any angle themselves, it calculates the correct duty cycle and activates it.

Here is a video of a script that moves the servo to each of the 3 extremes of positions. (Note that the servo only actually moves to 160 degrees)