Skip to content
Ben Dyer edited this page Oct 30, 2015 · 20 revisions

Getting started

Updated 2015-09-04

Hardware overview

As at 2015-03-18, all shipped boards are hardware revision 3. The minimum firmware version shipped is aa124d5484.

Depending on the hardware options you selected, you will have received:

  • S2740VC ESC
  • 15 cm 3-pin 0.1" PWM to UAVCAN adapter cable (twisted red, brown and yellow)
  • 15 cm 4-pin Pixhawk DF13 to UAVCAN adapter cable (black wires)
  • 30 cm UAVCAN to UAVCAN cable (black)
  • ST-Link/v2 USB to JTAG/SWD debugger with 20-pin ribbon connector
  • 20-pin to mini 10-pin JTAG/SWD debug adapter
  • Mini-USB cable
  • Fischl USBtin USB to CAN adapter with UAVCAN cable (twisted red, brown and yellow)
  • µCAN USB to CAN adapter with 30 cm UAVCAN to UAVCAN cable

If any hardware is missing or non-functional, please contact [email protected].

Note that the Fischl USBtin adapters we shipped on or prior to the 18th March do not have CAN termination enabled. Depending on your network configuration, this may cause unreliable communications. If you're not able to connect to the ESC(s), try shorting the two large vias closest to the ground (black) wire on the USBtin PCB to enable termination. If this solves the problem, solder a link between those vias.

Software preparation

A VMware virtual machine with all the necessary software pre-installed can be downloaded from the following locations.

Mac OS X/Linux (2.99 GB): http://thiemar.com/downloads/stm32-toolchain.vmwarevm.zip

Windows (2.17 GB): http://thiemar.com/downloads/stm32-toolchain.7z

The username for this machine is dev, and the password is dev.

The software is in a git repository located at /home/dev/workspace/vectorcontrol.

In order to access the firmware, you will need to configure the VM to authenticate using your GitHub account as described here: https://help.github.com/articles/which-remote-url-should-i-use/

By default, the repository on the VM uses SSH authentication, but if you prefer HTTPS, run the following commands:

cd /home/dev/workspace/vectorcontrol
git remote set-url origin https://github.com/thiemar/vectorcontrol.git

After configuring authentication, run:

cd /home/dev/workspace/vectorcontrol
git pull

Alternatively, if not using the VM:

  1. Install Python (version 2.7 or later).
  2. Install the Python pip package (see https://pip.pypa.io/en/latest/installing.html).
  3. Run pip install tornado>=4.0 pyserial uavcan.
  4. Clone the software repository at https://github.com/thiemar/vectorcontrol.git

Toolchain preparation

The S2740VC uses an STM32F302 MCU, so a variety of toolchains can be used. The firmware contains a makefile which builds using gcc, with optional debugging via Eclipse, gdb and OpenOCD.

If you do not use the virtual machine, complete the steps under "Software preparation" above, then ensure you have git and a functioning ARM toolchain installed (e.g. from https://launchpad.net/gcc-arm-embedded ).

Hardware preparation

Bench testing is required before the S2740VC ESC is used in a vehicle. A number of motor and control parameters need to be configured, and depending on the firmware version, motor and application, additional manual tuning may be necessary.

  1. Use a current-limited power supply for testing and motor tuning. In the absence of a current-limited power supply, use a small, low-voltage battery (e.g. 2S / 850 mA h). This may still destroy the ESC and/or motor, but is less likely to pose a fire hazard than a large battery.
  2. Ensure the ESC is placed on a non-conductive surface, and is not near any objects which could be blown onto the ESC by the motor/propeller.
  3. Ensure your motor is securely fastened to a solid object, and is not near any objects which could entangle the rotor or propeller.
  4. Connect the CAN adapter (and debug adapter if required) to the ESC. Pin 1 of the 10-pin SWD connector is identified by a white dot.
  5. Connect the CAN adapter (and debug adapter if required) to your computer. If you're using a non-isolated power supply with a computer connected to mains power, connect the debug adapter via a powered hub to reduce the risk of damage to your computer in the event of a wiring fault.
  6. Connect ESC's three motor phase drive leads to your motor. The order of the leads changes the direction of rotation, but otherwise does not matter. Ensure the phase drive leads are located away from the debug adapter and any EMI-sensitive devices. Also ensure the connectors are physically separated so shorts can't develop between them.
  7. Check the polarity of the ESC's power connector and your power supply. Reversing the supply polarity will immediately destroy the ESC, and may also damage other equipment.
  8. Power the ESC up. You will hear a brief chirp as the ESC measures the electrical properties of your motor, and current draw should stabilize at less than 100 mA depending on the input voltage.

Firmware update

Prior to testing, ensure you are running the latest firmware. This can be compiled by running make -j8 from within the /home/dev/workspace/vectorcontrol directory.

Then:

  1. Connect your CAN adapter.
  2. cd into the tools directory in the vectorcontrol repository.
  3. Run python ui.py --firmware /home/dev/workspace/vectorcontrol/firmware --port 8080 /dev/ttyACM0 (you may need to change /dev/ttyACM0 to point to the CAN adapter's tty device).
  4. Power up the ESC. Wait for the firmware update to complete; after it does, the ESC will restart.

If you are unable to connect to the ESC, ensure it is powered up, and check your CAN wiring.

Configuration

Whether you're using the virtual machine or not, you can now start the S2740VC management interface:

  1. Connect your CAN adapter.
  2. cd into the tools directory in the vectorcontrol repository.
  3. Run python ui.py --firmware /home/dev/workspace/vectorcontrol/firmware --port 8080 /dev/ttyACM0 (you may need to change /dev/ttyACM0 to point to the CAN adapter's tty device).
  4. Open your web browser and navigate to http://localhost:8080/
  5. Power the ESC up

You should now see a series of configuration options on the left-hand side of the page, and charts on the right.

If you intend to use UAVCAN with multiple ESCs, the ESC index should be set. This is equivalent to the RC channel in traditional PWM setups; PWM channel 1 should be set as ESC index 0, PWM channel 2 should be set as ESC index 1, and so forth.

Click "Apply configuration" to save changes to flash and restart the ESC.

Once the ESC starts up again (there will be a chirp from the motor, and the uptime counter will reset), you can configure the other paramters:

  1. Number of poles: Used to convert mechanical speeds to electrical speeds. Your motor's specification sheet should list this; the number will be even and is commonly around 10–14. If you do not know this number, you can leave the default set, but bear in mind that the reported rpm, power and thrust values may be inaccurate.
  2. Current limit: The motor's rated continuous current, in amperes. When testing a new motor it is often good to set this to the lowest value at which the motor will still start up (1 A is sufficient for small motors with low cogging force, while 10 A may be required for cheap high-Kv motors).
  3. Voltage limit: The motor's rated voltage, in volts. When testing a new motor, set this to 2 V initially in order to limit peak current and speed. Subsequently this can be increased to your motor's rated voltage, or even higher provided the maximum speed and power dissipation specifications of the motor are not exceeded.
  4. Resistance, inductance and Kv: These parameters are measured by the ESC on start-up. If your motor specification sheet lists these figures, check that the measured values are within approx 10%. Note that the correct Kv reading will not be shown until after you have spun the motor up for the first time, and exited and re-started the ui.py script.
  5. Click "Apply configuration". The ESC will restart.

After these parameters have been configured, use the "Setpoint" section of the interface to spin your motor up to a moderate speed (for example, equal to twice the motor's Kv value: 1200 rpm if the Kv is 600 rpm / V). To do this, set the "Control mode" field to "rpm", and enter the desired rpm into the "Setpoint" field.

If the motor starts smoothly, you can increase the current and voltage limits, click "Apply configuration", and experiment with higher speeds and dynamic setpoints. If the motor stalls, increase the value of the "Acceleration limit" parameter from its default of 0.5; values up to 1.0 are reasonable.

UAVCAN support

The UAVCAN Linux tools are located at /home/dev/uavcan/build/libuavcan_drivers/linux.

Before these tools can be run, SocketCAN must be started. The version of slcand installed on the stm32-toolchain virtual machine image does not appear to work, so instead, open a new console window and run the following commands:

sudo modprobe can && sudo modprobe can-raw && sudo modprobe slcan
sudo slcan_attach -f -o -s8 -c -w /dev/ttyACM0

(Depending on the device your CAN adapter was enumerated as, you may need to replace /dev/ttyACM0 with /dev/ttyACM1 or similar; the adapter may also be enumerated as /dev/ttyUSB<n>.)

This command does not exit; while it is running, the SocketCAN device slcan0 will be available. Once complete, you can terminate slcan_attach by typing ctrl+c.

After running slcan_attach but prior to using slcan0, you must bring the interface up:

sudo ip link set up slcan0

Two tools are relevant:

  • uavcan_monitor: run ./uavcan_monitor slcan0 to see live status updates for each node on the UAVCAN network.
  • uavcan_nodetool: run ./uavcan_nodetool 126 slcan0 to join the UAVCAN network as node ID 126. This tool provides a command-line interface to configure, restart and get information from any node on the network. Type help and press enter for a command listing.

Prior to flight

Before using the ESC in an aircraft, ensure that you have conducted tests with the motor and propeller you will use, and the ESC functions reliably with that combination.

If rpm control is in use, two tests are recommended prior to flight:

  • Control mode: rpm
  • Command type: step
  • From setpoint: twice your motor's Kv rating in rpm
  • To setpoint: your motor's maximum achievable speed in rpm
  • Low time: 1 s
  • Rise time: 0.01 s
  • High time: 1 s
  • Fall time: 1 s

This first test causes the motor to accelerate from a very low speed to full throttle in the shortest time possible. If the ESC loses sync during the step, reduce the acceleration gain, acceleration torque limit, current limit and/or acceleration rise time.

  • Control mode: rpm
  • Command type: sweep
  • From setpoint: twice your motor's Kv rating in rpm
  • To setpoint: your motor's maximum achievable speed
  • From frequency: 0.25 Hz
  • To frequency: 4 Hz
  • Sweep rise time: 20 s

This test causes the motor to follow a sinusoidal setpoint increasing in frequency from 0.25 Hz to 4 Hz, over its full speed range. If the ESC loses sync during the high-frequency part of the sweep, or motor vibration or prop load is unacceptable, reduce the acceleration gain and/or acceleration rise time until the speed response is sufficiently diminished in magnitude.

Clone this wiki locally