Parametric FreeCAD model, 3D-printable (PLA/PETG). Built for two 9g servos (SG90) and scalable to MG996R by changing one line.
/Applications/FreeCAD.app/Contents/Resources/bin/freecadcmd antenna_tracker.py
- Edit
SERVO = "9g"to"MG996R"at the top ofantenna_tracker.py, or run withAAT_SERVO=MG996R. - Writes
AAT.FCStd(assembled model, with servo dummies) andstl/<servo>/{base,turntable,antenna_arm}.stl. - Runs self-checks: valid solids, servo fit, pan +-90 and tilt 0-180 sweep collisions, Prusa bed fit, watertight STLs.
| part | notes |
|---|---|
base |
pan servo drops into the pocket, tabs screw into the rim. Flange has 4 mounting holes. Cable slot at the rear. |
turntable |
plate screwed onto the pan horn. Wall A holds the tilt servo and wall B is the pivot wall. |
antenna_arm |
C-frame on the tilt horn, with an antenna plate (centre 6.5 mm hole + 4 small holes). Prints with the antenna plate face down. |
| 9g | MG996R | |
|---|---|---|
| servos | 2x SG90-class | 2x MG996R |
| servo tab screws (4) | M2 x 8 self-tapping | M4 x 12 self-tapping |
| horn screws (4 + 4) | M2 x 6 self-tapping (horn bolt-circle holes) | M2.5/M3 x 8 self-tapping |
| pivot bolt + nut | M3 x 10 + nyloc nut | M5 x 16 + nyloc nut |
| base mounting | 4x M4 | 4x M5 |
Pivot assembly: the bolt head sits inside the arm frame, goes through the arm's ear, and is clamped by a nut on the wall-B side of the ear. The shank turns freely in the wall-B hole.
0.2 mm layers, 3-4 walls, 25% infill, no supports. Print orientation is already baked into the STLs.
- A 9g servo gives about 180 deg, so each axis covers 180 deg, and flip mode gives full 360 deg tracking (see below). The arm swings 0-180 deg: 0 = horizontal facing front, 90 = straight up, 180 = horizontal facing back. The arm touches the turntable just past 180 deg, so keep the servo end stop at 180 deg.
- Payload is about 150 g or less for 9g. The MG996R build handles several times more.
- Servo dimensions in the table are nominal. Measure yours with calipers and adjust
SERVOS(especiallytab_z,shaft_off,horn_topand the horn bolt pattern) before printing. - Set the servo to centre (90 deg) before fitting the horns. Pan centre should face the middle of your tracking range.
Sketch: antenna_tracker/antenna_tracker.ino (needs only the built-in Servo library).
| From | To |
|---|---|
| Pan servo signal | Nano D9 |
| Tilt servo signal | Nano D10 |
| Servo power (red) | 5 V (9g: Nano 5 V pin is OK; MG996R: external 5-6 V supply) |
| Servo ground (brown/black) | GND, shared with the Nano and any external supply |
| Telemetry TX (plane/receiver) | Nano RX (D0) |
| Telemetry GND | Nano GND |
- With an external servo supply, join its ground to the Nano GND. Do not connect its +V to the Nano 5 V pin.
- Add a 470-1000 uF capacitor across the servo power rails to prevent brown-outs.
- Telemetry must be 5 V TTL. Use a level shifter or divider for 3.3 V sources if the link is bidirectional.
- Serial carries the plane data, so there is no debug output.
- Disconnect the telemetry wire from D0 while uploading the sketch.
One line per update at 57600 baud (change SERIAL_BAUD in the sketch to match your link):
SATS,LAT,LON,ALT
9,45.123456,19.123456,152.4
LAT and LON are signed decimal degrees, and ALT is in metres.
- Mount the tracker level. Face the pan centre toward the middle of your flight area and set
PAN_CENTER_BEARINGto that compass bearing (0 = north, 90 = east). - Upload the sketch. Both servos centre on power-up, so fit the horns at pan 90 deg and tilt horizontal.
- If an axis moves the wrong way, flip
PAN_REVERSEorTILT_REVERSE. If tilt 0 deg is not horizontal, adjustTILT_ZERO_ANGLE. - Power the tracker at the launch point. Home is set from the average of the first 10 frames with
SATS > 5, and the LED on D13 turns on. - Frames with 5 or fewer satellites are ignored, and the tracker holds its last position.
Open the Serial monitor at the sketch's baud rate (line ending: Newline).
- Send
8,45.0,19.0,100ten times to set home. The LED turns on. - Send
8,45.001,19.0,150. The tracker points north and up. - Send
8,45.001,19.001,100. The tracker pans about 35 deg east of north (pan servo near 125 deg) and stays horizontal. - Pure east (
8,45.0,19.001,100) sits exactly on the ±90 deg pan limit with the defaultPAN_CENTER_BEARING = 0, so the pan servo goes to its end stop at 180 deg. - A plane south (
8,44.999,19.0,100) is behind the tracker, so it flips: pan 90 deg, tilt 180 deg (antenna horizontal, facing backwards).
- Full circle (flip mode,
FULL_CIRCLE = true): the pan servo covers ±90 deg aroundPAN_CENTER_BEARING. For a plane behind that, the pan turns to the opposite bearing and the tilt swings past vertical (tilt = 180 deg - elevation), so the antenna points backwards at the plane. SetFULL_CIRCLE = falseto limit tracking to ±90 deg pan and 0-90 deg tilt. - The flip happens 5 deg beyond the ±90 deg edge (
FLIP_HYST) so the tracker does not flap on the boundary. - When the plane crosses the flip line, both servos have to swing a long way. At the default 90 deg/s (
MAX_SLEW_DPS) that takes about 2 s, so the antenna lags the plane there. RaiseMAX_SLEW_DPSfor fast planes (a 9g servo is rated at roughly 400-500 deg/s unloaded, less under load). - The tilt servo now uses its full 180 deg travel. Calibrate
SERVO_MIN_US/SERVO_MAX_USso 0 and 180 deg land exactly on the arm's front and back horizontal positions without the servo stalling at an end stop. - Targets below the horizon are held at horizontal.
- Within 5 m of home the pan holds.
- Altitude is measured relative to home, so the plane's ALT must use the same reference for the whole flight.
Do this once after assembly, and again if you change a servo or a horn. The sketch maps 0-180 deg linearly onto SERVO_MIN_US ... SERVO_MAX_US (default 500-2400 us), and both servos share that one pair. Real servos differ, so a wrong range causes one of two faults:
- Pulse range too wide: the servo hits its internal stop and buzzes or stalls. A stalled servo draws a lot of current and can overheat or brown out the Nano.
- Pulse range too narrow: the servo never reaches 0 or 180 deg. Pan then loses its ±90 deg coverage, and tilt cannot swing the arm back to horizontal for flip mode.
The tilt axis needs the most care. It uses the full 180 deg, and the arm hits the turntable shortly past 180 deg (about 200 deg in the CAD check), so its end stops must be exact.
- The simulator (see below) to drive the servos to known angles. The
stepsscenario visits both pan ends (0, 90, 180 deg) and both tilt ends (0 and 180 deg). - A phone spirit-level app or a small level, to check horizontal.
- For MG996R, an external 5-6 V servo supply (see Wiring). Never calibrate MG996R from the Nano 5 V pin.
- Remove both horns, or at least unscrew the arm from the tilt horn, so nothing can jam.
- Start with a conservative range in the sketch:
SERVO_MIN_US = 700andSERVO_MAX_US = 2300. Upload it. - Run the
stepsscenario with long holds so you can listen and look:The servos only move once home is set (about 11 s after start). You can hold a single step withpython3 simulator/plane_sim.py --port /dev/cu.usbserial-XXXX --scenario steps --hold 10--step N(for example--step 1,--step 5and--step 7for the end stops listed below).
Watch the pan servo at its 0 and 180 deg steps, and the tilt servo at its 0 and 180 deg steps. The table lists the first steps of the sequence:
| step | pan servo | tilt servo | what you should see |
|---|---|---|---|
| 1 | 0 | 0 | pan at its one end, arm horizontal in front |
| 2 | 45 | 0 | |
| 3 | 90 | 0 | pan centred |
| 4 | 135 | 0 | |
| 5 | 180 | 0 | pan at its other end |
| 7 | 90 | 180 | tilt at its far end, arm horizontal pointing backwards |
At each end stop:
- Buzzing or humming, or the horn spline stops moving while the pulse still increases: the pulse is beyond the servo's travel. Narrow that side by 50 us and retry.
- Servo quiet but short of the target angle: the range is too narrow. Widen that side by 50 us and retry.
Settle on the widest range where neither end buzzes. Typical results are 500-2400 us for 9g and 500-2500 us for MG996R, but servos vary, and cheap 9g servos often reach only about 600-2300 us. If the two servos disagree, use the range that is safe for both, because the sketch has one shared pair.
Use --step N to hold the servos at one known position while you work. Step 3 is pan 90 deg (centre) and tilt 0 deg:
python3 simulator/plane_sim.py --port /dev/cu.usbserial-XXXX --scenario steps --step 3
The servos move once home is set (about 11 s), then stay put. Fit the horns now:
- Pan: press the turntable onto the horn so the antenna side faces your
PAN_CENTER_BEARINGdirection. - Tilt: press the arm onto the horn with the antenna plate pointing level forward. Check horizontal with the level.
- Fit the screws. The horn spline moves in steps of 360 / teeth: about 17 deg for 21-tooth 9g horns and about 14 deg for 25-tooth MG996R horns. Re-seat the horn on a different tooth if the error is larger than one step.
With the horn on, run steps again and compare against the level:
- Tilt 0 deg: the arm must be level pointing forward. If it is off by a few degrees, change
TILT_ZERO_ANGLEby the same amount (for example2.0) instead of re-seating the horn. - Tilt 180 deg: the arm must be level pointing backwards and must not touch the turntable. If it hits, reduce
SERVO_MAX_USuntil it clears. Leave at least 3 deg of margin. - Tilt 90 deg: the arm must be vertical. If 0 and 180 are right but 90 is not, the servo is not linear. Adjust the end values until 0, 90 and 180 are all within a few degrees.
If the tilt direction is reversed, set TILT_REVERSE = true and TILT_ZERO_ANGLE = 180, and run the simulator with --tilt-reverse --tilt-zero 180.
- At the pan 0 and 180 deg steps the turntable must stop at the same angle either side of centre (±90 deg), with no buzzing.
- Cables must not wrap or pull at either end.
- If the antenna turns the wrong way, set
PAN_REVERSE = true.
Run the whole steps scenario once with the arm and antenna fitted:
python3 simulator/plane_sim.py --port /dev/cu.usbserial-XXXX --scenario steps --hold 6
Confirm the following:
- Both servos reach every position, with no buzzing and no part touching.
- At -135, 180 and +135 deg (flip mode) the antenna faces backwards and the arm is clear of the turntable.
- At 85 deg elevation the arm is near vertical.
Write your final SERVO_MIN_US, SERVO_MAX_US and TILT_ZERO_ANGLE into the sketch and into this README, so you can restore them after re-flashing.
simulator/plane_sim.py sends fake SATS,LAT,LON,ALT lines over serial, the same way the plane's telemetry does. It needs Python 3 and pip install pyserial (not needed for --dry-run).
The Nano's USB port is wired to the same hardware Serial (D0/D1) the sketch listens on, so no telemetry wiring is needed.
python3 simulator/plane_sim.py --list-ports
python3 simulator/plane_sim.py --port /dev/cu.usbserial-XXXX --scenario steps
- Use the same baud as
SERIAL_BAUDin the sketch (default 57600,--baudto change). - Close the Arduino Serial monitor first, because only one program can hold the port.
- Opening the port resets the Nano, so the simulator waits 2 s for the bootloader.
--dry-runprints the lines without a port.
- No fix: sats 0-3 at
0,0. The tracker must ignore these. - Weak fix: sats 4-5 at home. This must not set home, because it needs
SATS > 5. - Good fix: sats 9 at home for about 5 s. The tracker averages 10 frames to set home, and the LED on D13 turns on.
- Scenario: the chosen flight starts.
The log prints the expected PAN and TILT servo angles every second, using the same maths as the sketch. Compare them with the servos.
| name | what it tests |
|---|---|
steps |
holds fixed directions for 6 s each: -90, -45, 0, +45, +90 deg pan, then behind the tracker (+135, 180, -135 deg, flip mode), then tilt 15 to 85 deg. Use it first to check servo direction, centre and end stops. |
arc |
sweeps left and right across the pan range while climbing and descending (normal flight). |
orbit |
full 360 deg circle. The log shows FLIP where the tracker swings the antenna to the back (pan jumps, tilt goes from elevation to 180 - elevation). |
outback |
flies out and climbs, then returns and overflies home (tests the 5 m pan hold). |
flyover |
straight pass directly over home, with elevation near 90 deg and the bearing flipping. |
dropout |
arc, but with weak fix and total GPS loss every 20 s. The tracker must hold its last position. |
| option | meaning |
|---|---|
--pan-center 90 |
match PAN_CENTER_BEARING. Also match --pan-reverse, --tilt-reverse, --tilt-zero and --no-flip (for FULL_CIRCLE = false) to the sketch so the expected angles are right. |
--lat/--lon/--home-alt |
home position (default 45.0, 19.0, 120 m). Altitude is sent as home-alt + height, so it also tests the relative-altitude logic. |
--radius 300 |
flight radius in metres. |
--noise 0.5 |
GPS jitter in metres. |
--glitch 0.05 |
corrupts about 5% of lines. The tracker must not jump. |
--rate 5 |
updates per second. |
--duration 60 |
stop after 60 s of flight. |
--skip-home |
skips phases 1-3. Use it only when the tracker already has its home. |
Example full test, with the tracker facing east and noisy, glitchy data:
python3 simulator/plane_sim.py --port /dev/cu.usbserial-XXXX --scenario arc \
--pan-center 90 --noise 1.0 --glitch 0.05
To retest home, reset the Nano. Home is only set once per power-up.
simulator/map_sim/ is a browser-based simulator. It shows the tracker and the plane on a real map. You drag the plane, change its height, and the tracker (a virtual copy, or your real Nano) follows. It sends the same SATS,LAT,LON,ALT lines as plane_sim.py.
cd simulator/map_sim
python3 server.py # then open http://127.0.0.1:8765/
- The map tiles come from the internet (OpenStreetMap, Esri satellite), so you need to be online.
server.pyserves the page and can talk to the serial port. For preview-only or Chrome/Edge browser serial you can also usepython3 -m http.serverin that folder. Openhttp://localhost:8000/, because Web Serial needslocalhostor https.
- Tracker tower at home. Drag it to move home (only before sending starts).
- Plane, with a label showing its height and distance. Drag it anywhere on the map.
- Height: use the slider, the up/down arrow keys (Shift = x5), or the mouse wheel over the plane.
- Range rings at 250 m, 500 m, 1 km and 2 km.
- Green zone = front half, covered without flipping. Amber zone = rear half, where the tracker flips.
- Antenna beam: a cone from the tracker showing where the antenna really points, delayed by the servo speed limit. It is green when within 6 degrees of the plane, amber under 20 and red beyond.
- Gauges: pan and tilt servo angle. The solid needle is where the servo is, and the dashed one is where it was told to go.
- Readouts: distance, bearing, elevation, zone, pointing error, what the tracker last did with a line (
tracking,ignored (sats 5 < 6),averaging home 4/10, ...). - Lines sent: every line, including corrupted ones, with the tracker's reaction.
| mode | use |
|---|---|
| Manual | drag the plane. Dragging always switches to this mode. |
| Orbit around home | circles home at the chosen radius and speed, to test the flip. |
| Fly to clicked point | click the map and the plane flies there at the set speed. |
| link | how |
|---|---|
| Preview only | no hardware: only the virtual tracker runs. |
| Browser serial | Chrome or Edge. Choose "Connect", pick the Nano's USB port. |
| Python bridge | any browser. Open the page from server.py, pick the port and connect. Needs pip install pyserial. |
- Connecting resets the Nano (about 3 s), and Start unlocks after that. Close the Arduino Serial monitor first.
- Baud must match
SERIAL_BAUDin the sketch. - The virtual tracker runs alongside in every mode, so you can compare it with the real servos.
- Set the tracker settings (section 4) to match the sketch. Pan centre, reverse flags and
MAX_SLEW_DPSmust be the same. - Press Start sending. It runs the same phases as
plane_sim.py: no fix, weak fix, then good fix at home. The tracker sets home and the home chip turns green. - Drag the plane around. Move it behind the tracker (into the amber zone) to see the flip. Raise it to test elevation. Lower the satellites to 5 or tick GPS lost to check the tracker holds position. Raise Corrupt lines to check it ignores garbage.
- Press Stop sending. To repeat the home phase on real hardware, reconnect, because the Nano only sets home once per power-up.
- The virtual tracker is a JavaScript copy of the sketch logic (
model.js), not the sketch itself.node simulator/map_sim/test_model.jschecks that copy against the sketch's behaviour. Real servos can still differ (calibration, speed). - Home on the map is where the tracker is. After sending starts it is locked, so the plane's reported positions stay consistent with what the Nano has stored.
plane_sim.pystill works for scripted tests without a browser.
The sketch has no debug output (Serial carries the plane data), so use the LED on D13 and the simulator's log to see what the tracker is doing.
| symptom | likely cause | fix |
|---|---|---|
| Servos stay at their start position and the LED on D13 stays off | Home is not set yet. The tracker ignores everything until it has 10 frames with SATS > 5. |
Check the plane's data really shows 6+ satellites. Test with the simulator (it sends the home phase first). Reset the Nano to retry. |
| LED never turns on even with good data | Data is not reaching the Nano. | Check TX goes to Nano RX (D0), the grounds are joined, and the baud matches SERIAL_BAUD. Close the Arduino Serial monitor, because it can hold the port. |
| Data reaches the Nano but the LED still stays off | The line format is wrong. | Each line must be SATS,LAT,LON,ALT ending in a newline, with decimal degrees (45.123456), not NMEA (4507.4074). Lines longer than 63 characters are dropped. 0,0 positions are ignored. |
| Sketch will not upload | The telemetry wire on D0 blocks the USB serial. | Unplug it while uploading. |
| Works on USB with the simulator but not with the real telemetry | The telemetry is 3.3 V, inverted, or the wrong baud. | Check the voltage level and baud. Test the link with a USB-serial adapter first. |
| symptom | likely cause | fix |
|---|---|---|
| Antenna turns the opposite way (left when the plane goes right) | Servo mounted mirrored. | Set PAN_REVERSE = true. |
| Pan is off by a fixed angle | PAN_CENTER_BEARING does not match where you faced the tracker. |
Measure the compass bearing the pan centre faces and set that. |
| Points the mirror image, or east and west swapped | LAT and LON swapped, or the sign of LON is wrong (west must be negative). | Fix the order and signs at the plane. |
| Tilt goes down when the plane climbs | Tilt servo mounted the other way. | Set TILT_REVERSE = true and TILT_ZERO_ANGLE = 180 (see calibration). |
| Tilt is always high or always low by the same amount | The altitude reference differs from the home altitude (for example MSL at home, relative later). | The plane's ALT must use the same reference for the whole flight. Home altitude is the average of the first 10 good frames. |
| Home is in the wrong place | The telemetry first got a fix away from the tracker. | Power the plane's GPS up at the tracker, or reset the Nano when the plane is at home. |
| symptom | likely cause | fix |
|---|---|---|
| Servo buzzes or hums at the ends | Pulse range goes beyond the servo's travel. | Narrow SERVO_MIN_US / SERVO_MAX_US (see calibration). |
| Nano resets or servos twitch when they move | Servo current drops the 5 V rail. | Power the servos from a separate 5-6 V supply (required for MG996R), join the grounds, and add a 470-1000 uF capacitor across the servo supply. |
| Antenna jitters while the plane is near home | The bearing is noisy at close range. | This is expected within 5 m (MIN_DISTANCE_M), where the pan holds. Raise that value if the jitter reaches further. |
| Small continuous wobble | GPS noise. | Test with --noise 0 to confirm. Slow MAX_SLEW_DPS down for a calmer tracker. |
| Tilt hits the turntable at 180 deg | Servo range is too wide. | Reduce SERVO_MAX_US until the arm clears (see calibration). |
| symptom | likely cause | fix |
|---|---|---|
| Antenna lags behind a fast plane | Slew limit. | Raise MAX_SLEW_DPS (default 90 deg/s). |
| Long swing when the plane passes behind the tracker | Flip mode swings both servos about 180 deg. | Expected. The flip happens at 95 deg from PAN_CENTER_BEARING. Pick PAN_CENTER_BEARING so the plane spends most of the flight in front. |
| Cannot track behind the tracker | FULL_CIRCLE is false. |
Set FULL_CIRCLE = true. |
| Tracker freezes mid-flight | Telemetry stopped, or SATS dropped to 5 or below. |
By design the tracker holds its last position until a good fix returns. |
| Antenna does not follow when the plane is overhead | Within 5 m of home the pan holds. | Expected. Tilt keeps working. |
| symptom | likely cause | fix |
|---|---|---|
pyserial missing |
Not installed. | pip install pyserial (not needed for --dry-run). |
| Port busy or permission denied | Another program (Arduino Serial monitor) holds it. | Close it and retry. On Linux, add yourself to the dialout group. |
| Port not listed | Cable is charge-only, or the driver is missing. | Use a data cable. Install the CH340 driver if your Nano clone needs it. List ports with --list-ports. |
| Nothing happens in the first seconds | The simulator waits 2 s for the Nano to reset, then sends the home phase. | Wait about 11 s before the servos move. Use --skip-home only if home is already set. |
| Servos do not match the "expect PAN / TILT" values | Simulator options differ from the sketch, or the servos are not calibrated. | Match --pan-center, --pan-reverse, --tilt-reverse, --tilt-zero and --no-flip to the sketch, then calibrate. |
| Sketch behaves differently after you change settings | Old sketch still on the board. | Re-upload after every change. |
| symptom | likely cause | fix |
|---|---|---|
| Servo does not fit the pocket or window | Your servo differs from the table, or the printer is tight. | Measure the servo and edit SERVOS in antenna_tracker.py. Raise C (clearance, default 0.3 mm). Re-run to regenerate the STLs. |
| Servo is loose | Clearance too large. | Lower C, or use thicker tab washers. |
| Horn holes do not line up | Different horn pattern. | Set horn_bolt_r, horn_pilot_d and horn_head_d for your horn, then regenerate. |
| Screws split the plastic | Pilot holes too small for your material. | Raise tab_pilot_d / horn_pilot_d by 0.1-0.2 mm, or print with more walls. |
| Pivot is stiff or loose | Nut tightness. | The arm should swing freely. Use a nyloc nut and tighten until the play just disappears. |