www.viniciocoletti.it > Projects > R/C Boat

Vinicio Coletti site

R/C Boat

Here is the beginning of the story. In November 2001 I went to a big hardware store and bought five cheap pieces of wood. I don't even know what kind of wood it is, but it's quite light. Each table is 50x10x1 cm.
Three tables were only cut a bit along one border, to put them at the right inclination. I derived from the other two tables the rear trapeze and the three triangles for the front.
To build the boat vessel I didn't use any metal parts, but only a good two-components glue, specific for wood. You may argue that the vessel is not too idrodynamic, but, well, this boat was not designed thinking to speed.
I installed then, after some months I left it apart, a 600BB cc motor, with joint and propeller axis. The inclination of the axis is about 10 degrees and the propeller is plastic and it has a diameter of 4 cm.
This is another view of the electric motor and the frontal part of the boat.
This is a bottom view of the propeller and the axis. Since the 600BB motor is directly connected to the propeller axis, it must rotate quite quickly, thus I choosed a two-blades propeller. I am not sure this reasonment is correct...
The inner motor axis rotate inside an outer metallic pipe, which is fixed to the boat shell. Between the two metallic parts I put some drops of mineral oil.
In June 2002 I realized that if I wouldn't work at the boat, it will not sail during summer holidays, so I bought the colors and I begun painting.
The first kind of paint colors the wood, so that it looks much better, and protects it against the infiltration of water. I put three layers of this painting on the boat.
The second paint is named flatting and is a water repellent. I put two layers of it on the boat.
At the end I tested the boat in my bathroom, just to see if it really didn't sink...
It was ok! I estimated a volume of about 5 dm3, so the weight of the boat must never go over 5 kg. Actually, to have a good navigation, I decided not to go over 2,5 kg, all included.
In July there was still a lot of work to do: I had to make and install the rudder and also make the controller card for the motor, because I decided not to buy a commercial controller. I cut the rudder from the same wood used from the vessel and painted it the same way. A metallic bar and pipe made the rudder axis and I cut them to the right length.
Here is an external view of the rudder. To drive it I used the servo I found included in the Futaba R/C transmitter package. Unfortunately, during one of the tests of the motor controller I inverted the power cables and the servo burned in a second. I had to buy another one. The controller survived, because I put a protection diode on it.
This is the motor speed controller card. It is on a pcb and is based on the Microchip PIC16F84A microcontroller and few other components. Look here for a detailed description of the card.
This is the rear part of the boat. You can the the lead acid battery (6 V, 4 Ah), the rudder bar, the servo, the R/C receiver (Futaba, 5 channels, 40 MHz) and the motor controller card.
Here we see the power transistor module (4 x 2N3055 on a dissipating module). They are connected in a Darlington configuration, with the first one driving the other three in parallel. This permits a steady motor current of about 15 A or more and peaks of 45 A (about 270 Watt).
Here you can see the motor and the two relays. I wanted to use a single 30 A x 2 relay but I found only these one, that are 10 A x 3. So I put two of them, with the three switches put in parallel. They are used to invert the motion direction, forward or reverse. Although the reverse is barely used, it can be vital in some situations (and is also a good brake).
Here is a total view of the boat, with all components and ready to go. The coverage is made with balsa wood packed with oven paper. It is a temporary solution, because I think I will paint the balsa the same color of the boat.
The boat is now really ready to go! On the left side you can see the Futaba R/C transmitter. The antenna is made with the wire of the receiver put inside several plastic pipes (those used for drinks!). Light and cheap. The coverage was put in case some water enters the boat, but of course has the problem to reduce the dissipation of the heat coming from the motor and the transistors module. Some other solutions may be tried in the future.
Here is the boat sailing at a very slow speed in a lake, not too far from the shore. Here ther antenna is a yellow pipe :-)
The first time the speed was actually limited because the motor axis was not fixed well to the motor. Tightening some screws fixed the problem.

The motor control circuit

Released August 10, 2002

General description

This controller is part of the homebrew remote controlled ship I built during summer 2002.
The ship engine is a 600BB CC motor and the card described here can control the speed and motion direction (forward or backward).

Power and features

The controller card gets its power from the 6V lead accumulator that powers all the ship. Actually, the voltage goes up to about 6.7 V for a full charged battery, so a series diode protects the PIC from voltage inversions and drops the voltage by about 0.7 V. The PIC 16F84A should not receive more than 5.5 V but I found that even at 6.0 V there is no problems, so the single diode is the unique regulation of the input voltage.
The PIC oscillator is a classical 4 MHz crystal plus 2 capacitors, giving an istruction time of 1 microsecond.
The controller card has the following connectors and features:

  • Power connector (+6V, ground)
  • R/C input (4 TTL inputs from R/C radio receiver)
  • Motor pwm output (goes to power transistor module)
  • Motor direction output (goes to a couple 30 A switches, inverting motor polarity)
  • Aux output (designed to drive an optional high brightness LED)
  • On board LED (to signal different states)
  • On board button (mainly for test purposes, available for future use)

Reading the pulses

The main purpose of the program on the PIC is to read the R/C pulses coming from the radio receiver, compute the desired speed and produce adequate pwm pulses on the output, thus regulating motor's speed.
First of all, it's better to remind how an R/C command works. For example a 4 channel R/C command has 2 paddles in it, able to move both horizontally and vertically (4 commands). The R/C transmitter reads the position of every paddle, then sends the following sequence:

  1. A 4 ms (or longer) pulse to signal the start of the sequence
  2. A 1 ms pause
  3. The position of the first paddle, coded as a pulse going from 1 ms (min) to 2 ms (max)
  4. A 1 ms pause
  5. Steps 3 and 4 are repeated other 3 times, to send all remaining channels

Thus a whole sequence lasts at most 17 ms and if the trasmitter doesn't pause itself, you can have more than 59 motion commands per second. It's enough even for very fast airplane models, I guess.
The R/C radio receiver de-multiplexes the 4 channels and outputs them on 4 different connectors, as TTL pulses. Even if the card can read all 4 channels (in parallel also), the current version of the software reads only channel 2 (motor control).
The main difficulty writing this program came from the fact that the 16F84A has only one timer module, so the same timer had to be used both to read pulses and to generate the pwm output. But let's describe the workflow.

How it works

When a TTL input goes up, a PORTB interrupt on change is generated. The interrupt service routine reads and saves the current Timer0 value, for future use. When the TTL input goes down, another interrupt is generated and this time the service routine computes the difference with the saved value, stores it and activates a validity flag.
In the main program loop, when a validity flag for channel 2 is detected, a routine reads the value stored by the interrupt service routine, resets the validity flag, sets the motor direction (ON or OFF to the switch output) and computes the pwm value.
When Timer0 goes in overflow (a 16x prescaler is used, so this happens every about 4 ms), if the pwm is not zero the motor is started. In the main loop, when Timer0 value becomes greater than the current pwm value, the motor is stopped. Thus the pwm frequency is about 250 Hz, certainly not the best but to avoid this I should implement a different program logic and reduce the length of the interrupt service routine to the minimum. Anyway it works.
Timer0 is also used to increment several "slow" counters, used in different parts of the program. For example, when no PORT B interrupts are detected for about 1 second, this means that R/C signal is missing, so the motor is stopped. The program then looks for new stable signals and if they come, the normal computing is resumed.
To drive the motor output I use 4 pins of the PORT B in parallel, to have a driving current of 80 mA. This current goes to the base of a 2N3055 transistor, whose output goes to the bases of other 3 2N3055, connected in parallel. I used this big-Darlington configuration simply because I had available an used 4 x 2N3055 module, nicely mounted on a dissipating plate.

The bug

The very first version of the program had a serious bug: there was no total OFF of the motor when the paddle was in the center position and there were always spurious max speed pulses. Debugging was useless, until I went back to the Microchip manuals to read carefully how the "PORT B interrupt on change" really worked. This way I discovered that when I switched ON or OFF the pwm output (four PORT B pins), I fired at the same time the interrupt, because every write to a port is also a read from that port! Thus, the interrupt service routine was confused by all these false interrupts and mixed wrong readings to the good ones.
Sadly, I already had the circuit mounted and tested when I discovered this, otherwise I would have used a PORT A pin + a small transistor to drive the output. Thus, in the single point where the motor is stopped, in place of a simple clrf PORTB instruction, I put the following:

   bcf    INTCON,RBIE    ; disables interrupts on PORTB
   clrf   PORTB          ; stops motor
   movf   PORTB,f        ; reads again PORTB to clear pins inequalities
   bcf    INTCON,RBIF    ; clears PORTB interrupt flag, if just activated
   bsf    INTCON,RBIE    ; enables interrupts on PORTB

Cheaper than another transistor, isn't it?
This fixed the bug, but for added security, mainly in case I change radio transmitter, I filtered out all pulses shorter than 0.9 ms and longer than 2.1 ms. Also, the pulses in the range 0.9-1.0 ms were normalized to 1 ms and those in the range 2.0-2.1 ms were normalized to 2 ms.

Future developments

There are many possibilities, if you really want to make your life busier:

  • A better coverage, same color of the ship, and a battery voltmeter (already planned)
  • One (or many) high brightness LED, as ship lamp
  • A card-size digital camera, to take pictures of animals, lake bottom, etc. (how to drive USB?)
  • Thermal and voltage sensors, to avoid burning transistors (max speed for a long time) or having a dead battery at the center of the lake...
  • Someone suggested a rescue system in case the ship sinks, but I am quite optimist about this, after I saw how well it navigates!

The circuit


List of components

  • 1x Microchip PIC 16F84 (or 16F84A), in the 18 pins DIP package
  • 1x 18 pins DIP socket
  • 1x 2N5320 transistor (or similar)
  • 1x 1N4002 diode
  • 1x red LED
  • 1x white LED (hight brightness)
  • 1x 4 MHz crystal
  • 2x 27 pF capacitors
  • 1x 56 Ohm, 1/4 W resistor
  • 1x 62 Ohm, 1/2 W resistor
  • 1x 470 Ohm, 1/4 W resistor
  • 1x 810 Ohm, 1/4 W resistor
  • 1x 4.7 KOhm, 1/4 W resistor
  • 2x 100 KOhm 1/4 W resistors
  • 9x connection points

Outside the controller card

  • 4x 2N3055 transistors, mounted on a dissipating plate
  • 1x 2 switches 30A relay (I used two separate relays of 3 x 10A each)
  • 1x 1N5406 diode

Links

This page is also available in Italian language (in italiano)