-
Notifications
You must be signed in to change notification settings - Fork 33
Getting started
Updated 2015-03-26
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)
- 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)
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.
The S2740VC uses an STM32F302 MCU, so a variety of toolchains can be used. The firmware contains an Eclipse project which builds using gcc, with debugging via gdb and OpenOCD.
A VMware virtual machine with all the necessary software pre-installed can be downloaded from here (3.2 GB): http://thiemar.com/downloads/stm32-toolchain.ova
The same virtual machine, packaged for VirtualBox, can be downloaded here (2.9 GB): http://thiemar.com/downloads/stm32-toolchain.zip
The username for this machine is dev, and the password is dev.
The firmware is in a git repository located at
/home/dev/workspace/vectorcontrol
; the default Eclipse workspace includes
that project so it will load when Eclipse is opened.
If you do not use the virtual machine, follow these steps:
- Ensure you have git and a functioning ARM toolchain installed.
- Install Python (version 2.6 or later).
- Install the Python
pip
package (see https://pip.pypa.io/en/latest/installing.html). - Run
pip install tornado>=4.0 pyserial
. - Clone the firmware repository at https://github.com/thiemar/vectorcontrol.git (if you do not have access to this repository, contact [email protected]).
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.
- 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.
- 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.
- Ensure your motor is securely fastened to a solid object, and is not near any objects which could entangle the rotor or propeller.
- 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.
- 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.
- 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.
- 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.
- Power the ESC up. You will hear a brief, soft chirp as the ESC identifies your motor, and current draw should stabilize at less than 100 mA depending on the input voltage.
Whether you're using the virtual machine or not, you can now start the S2740VC management interface:
- Connect your CAN adapter.
-
cd
into thetools
directory in thevectorcontrol
repository. - Run
python ui.py --port 8080 /dev/ttyACM0
(you may need to change/dev/ttyACM0
to point to the CAN adapter's tty device). - Open your web browser and navigate to http://localhost:8080/
- 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.
Critical parameters are:
- The first parameter to configure is the UAVCAN node ID. All your ESCs will initially have the same ID, but you will need to set this to a unique value from 1 to 125 before multiple ESCs are able to coexist on the same CAN bus.
- If you intend to use UAVCAN with multiple ESCs, the ESC index should be set. This is essentially 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 (there will be a chirp from the motor, and the uptime counter will reset), configure the motor paramters:
- Number of poles: Used to convert mechanical speeds to electrical speeds. Your motor's specification sheet will list this; the number will be even and is commonly around 10–14.
- 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).
- 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.
- Maximum speed: The motor's rated maximum speed, in rpm.
- Resistance and inductance: 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%.
- Kv: The motor's back-EMF constant, in rpm per volt. If you have an empirical value for this parameter, enter that here; otherwise, enter the value quoted in your motor's specification sheet. Frequently this value is over-stated for marketing reasons; it is not uncommon for a motor's actual back-EMF constant to be 10–15% lower than quoted.
- Click "Apply configuration". The ESC will restart again.
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 the motor's Kv value: 600 rpm if the Kv is 600 rpm / V). 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 starts roughly, the primary tuning parameters are "Acceleration torque limit" and "Acceleration gain". Reduce either or both of these values for more gentle starts and smoother responses to changes in throttle; increase the values if the cogging force of your motor prevents rotation otherwise.
In general, very little tuning should be required: the acceleration gain should remain in the range 0.005 to 0.05, and the acceleration torque limit should generally be around 20% of the motor's maximum current. The "Nominal load torque" value can be set to the current draw at full throttle for somewhat faster response to speed inputs, but the default value of 10 A is sufficient for most supported motors.
For multirotors and possibly certain fixed-wing configurations, it is more appropriate to use the torque controller than the speed controller, as the torque controller provides more direct influence over output thrust and generally faster response. The only parameter used in torque control mode is "Acceleration torque limit"; set this to the largest value at which the motor still starts smoothly. A reasonable starting point for this parameter is 20–50% of the motor's current limit.
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_status_monitor
: runuavcan_status_monitor slcan0
to see live status updates for each node on the UAVCAN network. -
uavcan_nodetool
: runuavcan_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. Typehelp
and press enter for a command listing.
For compatibility with conventional RC equipment outputting PWM throttle signals, the S2740VC includes a 3-pin 0.1" to UAVCAN adapter cable. The firmware recognises 3.3–5 V pulses ranging in duration from 1000–2000 µs as PWM throttle commands, and translates them to a speed or torque controller setpoint based on your PWM input configuration (see "Configuration" above).
Ensure that no CAN equipment is connected to the S2740VC while PWM input is being used, and power off the S2740VC before connecting a PWM device to ensure the PWM input is recognised.
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 speed control is in use, two tests are recommended prior to flight:
- Control mode: rpm
- Command type: step
- From setpoint: your motor's Kv rating in rpm
- To setpoint: your motor's maximum achievable speed
- 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: 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.
TODO
Warning: if you're using a debugger, DO NOT CLICK PAUSE/STOP WHILE THE MOTOR IS RUNNING. If you do, the motor will stop instantly and the resulting voltage spike is likely to destroy one of the ESC's MOSFET drivers, resulting in shoot-through on the affected phase and probably quite a bit of smoke.
It may be best to customize your Eclipse toolbar to hide those buttons, as they're super-tempting.