MAVLINKHUD

Overview

The SPRAY parameter group configures the Agricultural Sprayer subsystem. This allows the drone to autonomously control pumps and spinners for crop dusting or industrial spraying missions.

Key Concepts

1. Speed-Based Flow (SPRAY_PUMP_RATE)

To ensure even coverage, the pump speed must increase as the drone flies faster and decrease as it slows down.

  • SPRAY_PUMP_RATE: Defines the relationship between ground speed and pump PWM.

2. Auto-Shutoff (SPRAY_SPEED_MIN)

Prevents the drone from dumping chemicals while hovering or waiting for a GPS lock.

  • SPRAY_SPEED_MIN: The pump will only activate if the drone is moving faster than this speed (m/s).

Parameter Breakdown

  • SPRAY_ENABLE: Master switch.
  • SPRAY_SPINNER: Toggles the centrifugal spinner (used to atomize the liquid).

Integration Guide

  1. Pin: Map a servo output to Sprayer (Function 40) for the pump and SprayerSpinner (Function 83).
  2. Config: Calibrate the flow rate based on your nozzle specs.

Developer Notes

  • Library: libraries/AC_Sprayer.

SPRAY_ENABLE

Default 0
Range 0 1

SPRAY_ENABLE: Sprayer enable/disable

Description

This parameter enables or disables the automatic crop sprayer functionality.

Values

Value Meaning
0 Disabled
1 Enabled
  • Default: 0

Description

The Sprayer module is designed for agricultural drones. It automatically controls a pump and a spinner based on the aircraft's ground speed and position.

  • Function: When enabled, the autopilot will calculate the required pump speed (SPRAY_PUMP_RATE) to ensure an even distribution of liquid regardless of how fast the drone is flying.
  • Automation: It can be configured to start and stop automatically when the drone enters or leaves a designated spray area in a mission.
  • Hardware: Requires a servo or ESC-controlled pump assigned to SERVOx_FUNCTION = 94 (SprayerPump) and optionally a spinner on SERVOx_FUNCTION = 95 (SprayerSpinner).

SPRAY_PUMP_MIN

%
Default 0
Range 0 100

Sprayer Pump Speed Minimum (SPRAY_PUMP_MIN)

Description

SPRAY_PUMP_MIN sets the "Idle Speed" for your crop sprayer's pump.

Agricultural pumps often struggle to start or maintain pressure at very low throttle values. This parameter ensures that if the sprayer is active, the pump never drops below a certain speed, even if the drone is moving slowly.

The Engineer's View

Defined in AC_Sprayer.cpp.
The sprayer logic calculates the required pump speed based on ground speed (SPRAY_PUMP_RATE).
$$ \text{Target Speed} = \text{Ground Speed} \times \text{SPRAY\_PUMP\_RATE} $$
This target is then clamped:
$$ \text{Output} = \max(\text{Target Speed}, \text{SPRAY\_PUMP\_MIN}) $$

This prevents the pump from stalling or pulsing when the drone slows down for a turn.

Tuning & Behavior

  • Default Value: 0%.
  • Recommendation: Set to the lowest percentage where your pump still produces a clean spray pattern (e.g., 10% or 15%).

SPRAY_PUMP_RATE

%
Default 10
Range 0 100

SPRAY_PUMP_RATE: Pump speed

Description

Desired pump speed when travelling 1m/s expressed as a percentage.

Values

  • Range: 0 to 100
  • Units: %
  • Default: 10

Description

This parameter defines the "Volume" of the spray.

  • Function: It sets the baseline pump speed (PWM output) required to deliver the desired amount of liquid per square meter when the drone is flying at exactly 1 meter per second.
  • Scaling: If the drone flies faster (e.g., 2m/s), the autopilot will automatically double the pump speed to maintain the same application rate. If it slows down, the pump slows down.
  • Tuning: You must calibrate this based on your nozzle size and pump flow rate. If you find the drone is under-applying, increase this value.

SPRAY_SPEED_MIN

cm/s
Default 100
Range 0 1000

Sprayer Minimum Speed (SPRAY_SPEED_MIN)

Description

SPRAY_SPEED_MIN prevents "Chemical Dumping" while the drone is moving too slowly.

In agricultural spraying missions, you want a uniform application of fertilizer or pesticide. If the drone is hovering or just starting to move, the sprayer would apply too much chemical to a single spot. This parameter ensures the pump only turns on when the drone has reached a safe, productive ground speed.

Tuning & Behavior

  • Default: 100 cm/s (1.0 m/s).
  • Recommendation: Set this to your minimum effective spraying speed.
  • Physics: This acts as a logical gate. Below this speed, the pump is OFF. Above this speed, the pump is ON (or modulated based on SPRAY_PUMP_RATE).

SPRAY_SPINNER

PWM
Default 1500
Range 1000 2000

Sprayer Spinner PWM (SPRAY_SPINNER)

Description

SPRAY_SPINNER defines the speed of the centrifugal dispersal mechanism on your sprayer.

Instead of just a simple nozzle, many high-end agricultural drones use a spinning disk to fling the chemicals outward. A higher PWM value makes the disk spin faster, throwing the liquid in a wider swath.

  • 1000: Stopped.
  • 2000: Maximum dispersal width.

Tuning & Behavior

  • Calibration: Set this based on the desired "Swath Width" for your mission. If you are flying 4m apart and the chemical is not reaching the edge, increase this value.