Control Box (part 1) -Overview

CAD rendering of control box

Joystick Overview

The joystick used for this project is of the analog two axis type with a push button switch on the top of the handle. You may or may not be familiar with how an analog joysticks work, but the simple explanation is as follows: each of the two axes of movement (x and y we will call them) are connected to two separate potentiometers. As the two potentiometers are rotated during movement of the joystick, a voltage reading from zero to VSS of the circuit is output onto the wiper of the potentiometer (lets use "pot" as short for potentiometer). The voltage reading of the wiper can then be fed into an analog input of our microcontroller and converted to a digital value with which we can do all sorts of things. In our case, we will perform a series of steps to convert this analog value into 8 bit numbers which will be sent to the ESCs of our ROV and used to control the speed and direction of the six brushless DC motors

ADC

Since I have already explained the use and configuring of the PIC16F1937's ADC module in an earlier tutorial, I won't spend much time going over that here. I will however talk about the differences in implementation of the ADC module for our "ROV-specific" needs. Two analog inputs were used in this process with each AD input connected to a wiper of our joystick potentiometer. You will see how the main loop of our program continuously reconfigures the ADC module to change which input is used as the basis of an AD conversion. This allows us to perform two separate AD conversions in one iteration of the main loop and then come up with digital values to be sent to the ESCs below surface.

The depth (direction of travel along the z-axis) and rotation (rotational movement about z-axis) of the ROV are controlled in the exact same manner with the exception of the process being interrupt driven. Depressing the push-button switch in the handle of the joystick triggers an interrupt which samples the analog inputs in the same manner as described above but with positive y-axis movement of the joystick translated to positive z-axis direction of travel for the ROV (movement towards the surface) and negative y-axis joystick movement translated as negative z-axis direction of travel for the ROV. Additionally, the interrupt translates positive x-axis movement of the joystick as a clockwise rotation about the z-axis and a negative x-axis joystick movement is translated as a counter-clockwise rotation about the z-axis for the ROV. I implemented a series of flags and an encoding scheme to keep track of the intended directional "state" of the ROV based on joystick movement. Each iteration of the control box program's main loop sends 4 separate digital values to the subsurface ROV which are used to control it's movement.

Serial Communication

These four values are sent as data packets via RS-232 transceivers. The designation of the four packets is as follows:

"State"          intended overall direction of ROV

"Forward Speed"   Required speed for motors spinning in forward direction

"Reverse Speed"   Required speed for motors spinning in reverse direction

"Up/Down Speed"   Required speed for motors spinning in up/down direction (two horizontally

                mounted depth control thrusters)

The MCU program on-board the ROV utilizes a counter to keep track of the packets and know how to interpret them in the decoding process. In a later section of this tutorial we will cover the implementation of the PIC's UART module which was interfaced with the RS-232 transceivers. Additionally, the data from sensors on-board the ROV is sent topside to the control box via the UART modules.

My Abilities

As a final consideration, I have to admit that a person with more embedded programming experience would probably produce code that is far more efficient than what you will find here. The number of "firsts" for me were considerable in this project and I aim to make things more efficient as I progress. The complexity of the entire project is significantly more than anything I have done as of now and I fully expect there to be unforeseen bugs that will need to be addressed down the road. Aiming for perfection on the first shot is nearly impossible when inexperience makes it difficult to know exactly what "perfect" means. Aside from reading the data sheets to learn how to use the various PIC peripherals, the implementation is my own imagination and most likely reflects that of an honest first attempt that could be done much better with more experience.

Next up, Control Box (part 2)