Skip to content

manipulating CHUCK firmware

Björn Stenberg edited this page May 26, 2020 · 11 revisions

Editing the configuration

Most configuration is in a file called /etc/parameters.conf, on-board the drone. Some settings can (only) be changed with start-up parameters to the program dragon-prog.

Some config is in the startup-script, given as startup parameters to the main program: "dragon-prog".

Note: backup first! Make sure you mount the 'disk' as writeable! Settings get overwritten on reset and upgrade!

testing the temperature

There are three known temperature sensors, see: https://github.com/uavpal/disco-docs/issues/9

BLDC test

Run BLDC_Test_bench -h to get a list of options. This program is used in both Disco and Bebop, so some options are only useful on either model.

Locator sound when you loose your Disco

BLDC_Test_bench -M -1 or -2 plays sound #1 respectively #2 in a loop.

dragon-prog

Command-line parameters: https://github.com/uavpal/disco-docs/blob/master/dragon-prog%20-h.txt

dragon-prog can only have one instance, because /tmp/.dragon-prog.lock is used as lock file.

When you kill dragon-prog, the cooling fan stops. The fan can be turned on again with the command:

echo 1 > /sys/devices/platform/user_gpio/FAN/value

Setting bitrate/reducing the data usage for video

"I did experiment a bit with limiting disco video streaming bandwidth to FFPro. For persistancy I modded /usr/bin/DragonStarter.sh script and applied -q option to dragon-prog execution line. Normally I would get 2.4Mbit streaming while disco is recording in 1080p. You can go down with 0.8 Mbit steps - ie limiting streaming bandwidth either to 1.6Mbit or 0.8Mbit. One thing to note with dragon-prog -q option - you have to set bandwidth limit a bit ABOVE desired result - otherwise streaming bandwidth starts flipping between lower values. Ie for achieving 0.8Mbit limit you should set dragon-prog -q 1000 - and for 1.6Mbit it should be 1800 (and not 1600). It needs a bit headroom - otherwise bandwidth flipping occurs." at -q 500, the lag is really noticeable

Using the extra servo ports

The CHUCK has six servo connectors numbered 1-6. Number 1 and 6 are used to control the left and right elevons and number 2-5 are protected by red rubber covers. These servo ports can be controlled by software.

The servo outputs are exposed to userspace as PWM class sysfs directories:

Servo port Sysfs directory
1 /sys/class/pwm/pwm_4
2 /sys/class/pwm/pwm_5
3 /sys/class/pwm/pwm_6
4 /sys/class/pwm/pwm_1
5 /sys/class/pwm/pwm_2
6 /sys/class/pwm/pwm_3

After boot only pwm_3 and pwm_4 of these are visible in the sysfs tree, since they have been created by dragon-prog. To create another entry, you need to send its' pwm number to /sys/class/pwm/export. For example, to create an entry for servo port two (pwm number 5), run this command:

echo 5 > /sys/class/pwm/export

The pwm directories contain three interesting files:

File Description
period_ns The PWM period, in nanoseconds
duty_ns The PWM duty cycle, in nanoseconds
run 0 to disable pwm output, 1 to enable

Servos turn to a position defined by the length of the pulse you send it. A 1.5ms pulse means "go to center", a 1.0ms pulse means "rotate to 45 degrees left" and a 2.0ms pulse means "rotate to 45 degrees right". Although exactly how much they rotate are device specific. Servos vary, and there is no standardization.

To send a 1.5ms (1500000ns) pulse every 10ms (10000000ns), write these these values to the pwm files:

echo 10000000 > /sys/class/pwm/pwm_5/period_ns
echo 1500000 > /sys/class/pwm/pwm_5/duty_ns
echo 1 > /sys/class/pwm/pwm_5/run

So what are those other PWM devices?

If you've peeked into /sys/class/pwm, you've no doubt seen device 10, 11 and 12 there and asked yourself what they are and if they are anything fun to play with? Well, they're not so fun I'm afraid:

PWM device Description
pwm_10 IMU heating control
pwm_11 Gyro clock control
pwm_12 Camera MCLK control
pwm_13 Camera MCLK control