Thursday, February 19, 2015

CableCam Controller Board

This Blog post is one of an entire series
Motivation and Design
Download Link for CAD drawings (updated regular)
Bill of Materials
Motor and ESC considerations
CableCam rope
Building the DSLR CableCam
CableCam controller board

Motivation

The goal from the outset was to automate the cablecam as much as possible. While it is okay for one person to drive the cablecam and operate the gimbal at the same time, I cannot film myself without help. It should have a mode where it repeats the same movements on a trigger signal and drives back to start all by itself.

When discussing we came up with a first list of features
  1. Safety mechanism to stay between the start and endpoint always: No matter what the user does with the stick, never drive into the pole the rope is attached on. It is so easy to focus on the live stream of the camera, completely forgetting the braking and as result crash into something.
  2. Acceleration/Deceleration limiter: If you push the stick brutally forward, the wheels would be spinning, the timing belt of the gear might jump over some teeth,... Hence the controller should increase the speed linear.
  3. Point of interest: At a first position you point the gimbal to fixed point, then you drive to a second position and retarget the camera to the some point. With this information the controller can calculate the relative position and when driving the cablecam, it can turn the gimbal automatically facing the same object. Great for introduction shots, when filming once from front, driving by and then from the rear.
  4. Hold position: If the cablecam is driving downhill, the initial brake force might be too weak, the cablecam keeps rolling downhill slowly. But neutral means "Stay where you are".
  5. Record a run and repeat it
Of course we can later add more functionality and more sensors if needed, e.g. LiPo voltage control, alerts, monitoring,....

Requirements

In order to use this controller you need
  1. The OpenPilot CC3D board. No software, just the board.
  2. A receiver sending a Sum-PPMS signal or S-Bus
  3. A way to program the CC3D with a new firmware, best is buying a STM32F4 Discovery board and using its ST-Link Programmer and Debugger
  4. The sensor board with a matching sensor wheel - see below
  5. The Firmware either as source code or the hex file, latest version to be found on github.
  6. Either an FTDI adapter or a Bluetooth module with an on board 7V voltage regulator.

Implementation

Without the controller the RC receiver would be connected directly to the ESC and gimbal. Our controller acts as a preprocessor to the receiver signal with various additional inputs like the current position.


For the gimbal signal the most common behavior of the controller will to simply route the signals through, logically unchanged. The ESC is a problem. When you read our wishlist from above, we actually want the stick to control the speed. 0% means stop, 100% full speed forward. That sounds obvious but actually it is not. Imagine the cablecam is driving downhill a steep slope. For the ESC a 0% means 0% energy - let it roll downhill. And 100% thrust means full energy whatever the speed will be. And downhill, that is going to be fast.
Hence the controller takes the RC input signal as the desired speed and has to turn that into an energy/thrust value for the ESC.
On the steep hill the input of 0% means zero speed and the ESC might get -10% thrust to hold the cablecam at its current position instead of rolling downhill. And +100% speed might mean  20% forward thrust because with this little it rolls downhill already at 50mph.
Regarding the position information, my immediate thought was to use the motor hall sensors. I wanted to avoid any complex mechanics and would have accepted the slippage of the motor as error. Over the months of discussions and testing we found that the mechanics are quite simple and the slippage of the motor wheel not as little as I thought, hence changed my mind.
We drilled into the skate wheel 22 holes, 9mm deep and 3mm in diameter, equidistant on a d=60mm circle. In we gave d3x8mm magnets alternating north/south pole. These are then secured with Loctite.

The distance between two magnets is 8.6mm (=60mm*pi/22), the distance between two magnets with the same orientation 17.2mm. In order to not only measure the rotation speed but also its direction, we need to use two hall sensors where one is always a bit behind in measuring a north/south switch. I have put the two sensors 13mm apart.

These hall sensors (AN1120) work from 3V onwards to 24V and output their supply voltage. Hence a voltage regulator (LM1117 MP3,3 low drop) and its required tantalum capacitor (10uF 16V Typ C) was added to get a proper 3V input to the microprocessor.


Another huge discussion was the microprocessor to use. I insisted on one with enough UART channels, a 16bit hardware quadruple counter for the hall sensor and a convenient way to measure the input RC signals and create my own. The break through idea was to hijack the hardware of a flight controller, the OpenPilot CC3D board.
The 16bit counter makes life much easier and allows counting from 0 to 295m (or from 0 to -295m).

It has a powerful STM32 MCU, lots of timers, even SPI and an EEPROM for saving settings and monitoring information.

Best of all, you get in easily and costs just 20USD.


Usage

The controller should get input mostly from the rc receiver, later support Bluetooth as alternative command input.
The cablecam is turned on and this current position is hence zero. The start and end position is set to -32768 and +32768. Using the RC stick the cablecam is driven either forward or reverse towards the desired end position. The controller checks the rc input and allows the cablecam to drive normally, only the max speed is greatly reduced. If no RC input is received for 30 seconds, the current position is assumed to be the end position, the start position is zero.
From now on the cablecam can be driven between those two points with the programmed speed and acceleration limits. If at any time the speed is so high that the remaining braking distance would not suffice, the controller does reduce the speed at max acceleration.
This video gives a first impression of the positional control

Hardware installation

The CC3D comes with a couple of cables which we use for the various connectivity.



Motor ESC

The Motor ESC with all its three pins is connected to Servo Out 1, the multi-pin connector with the label "1". The ESC does also power the CC3D and all its connected peripherials, hence we need all three wires connected: Gnd, Vcc and Signal-

Sensorboard

The Conn1 connector is the broadest JST-SH 8 pin plug and we use the two outer pins of it.
Pin1 - black - Gnd <--> Gnd
Pin2 - red - Vcc <--> Vcc
Pin7 - grey - Sensor1 <--> S1
Pin8 - white - Sensor2 <--> S2

RC Receiver

Program your RC receiver to produce a SumPPM signal and connect its 3 Pins to the Pin called Servo out 4. In the image above it is the multipin connector with the label "4". Yes(!), the Input from the receiver goes into the Servo Out 4, it is reprogrammed as input.

Gimbal

Servo Out 2 and 3 does produce a normal PWM Signal for Pitch (2) and Yaw (3). As the gimbal board is powered from the same battery like the ESC, they share a common Gnd already and hence connect the signal pins only. Two wires only!

UART for Debugging and settings

The Flexiport provides a serial port to send commands to the CC3D firmware and provide debugging information. The port settings are 38400 baud, one stop bit, no parity.
Attention! Do not connect Pin2 with your FTDI UART-to-USB.
In my case I have connected a pre-configured Bluetooth module here and can use the tablet with a bluetooth serial terminal to send commands.

Installing and using the software

In the google drive folder there is the "CC3D Cablecam Controller.zip" file, which contains all the source code and the CooCox IDE project files. In the bin subfolder the compiled hex file is found.
Flash the CC3D with this hex file by whatever standard methods available to you.

Once all is powered up, open a terminal session with the board and type a first command "$h" followed by a sequence. This will print the help text with all further commands.

One of the first settings you have to make is setting the channels. So type "$i" and you will see the current RC values for each channel and what channel is used for which input function. The first 8 channels are from regular PWM inputs which we haven't talked about yet and the next 8 channels are the first 8 Sum-PPMS channels. Using the command "$i 9,11,12" you would set the Speed Input to the first channel (8+1) of the SumPPMS, channel 3 (8+3) is pitch and channel 4 (8+4) is yaw input.

To make save these changes permanently to the eeprom of the CC3D use the command "$w".

The first test you can make is moving the cablecam manually on the rope. Thus the sensor board will recognize the move, the controller finds that it is no longer at position 0 and will start to engage the ESC to move it back into the proper positon. Hopefully the P, I and D values are a good enough match for your cable cam.

Software implementation

The basic principle is that we read the rc input, based on the last position and current speed calculate the new target position. In parallel a PIC control loop does whatever it takes to drive the cablecam to this target position.





Post a Comment