Vertical Trajectory System, Mk2 Evolution

Discussions on high/extreme altitude and mach busting rockets.

Moderator: Moderators

User avatar
OverTheTop
It's only money...
It's only money...
Posts: 2991
Joined: Sat Jul 21, 2007 2:20 pm
Location: Melbourne, Australia

More Code Work

Postby OverTheTop » Fri Jan 22, 2021 6:51 pm

More Code Work

Spent a few days learning LUA and coding up a script to look after a flight. Here is the result. It has taken a while to go from "syntax errors" to "bad argument" errors to clean code for the FSM :) . Keeping the units and signs consistent was also something I was paranoid about getting correct.

Code has been tested and should run well on a flight vehicle

Code: Select all

--  This script is the main flight script for a rocket
--  SRC 22JAN2021   v1.0

--  SCRIPT FUNCTIONS
--   1)  Initialise
--   2)  Cycle canards as a servo test for 20s
--   3)  Await for boost detection (accel for > 1s)
--   4)  Switch flight to STABILIZE when drag decelerates airframe
--   5)  Switch to MANUAL when tilt > 45deg or time > 30s
--   6)  Loop forever

--  Note: This routine assumes there will be another script for detecting breakwire break and putting
--          the vehicle in MANU mode at deployment


local state     = 1                   -- state machine variable
local drag      = 0.2                 -- decel drag to trigger STAB (G)
local boost     = 2                   -- accel to sense boost (G)
local tick      = 0                   -- time counter, one tick = 20s
local STAB_mode = 2                   -- STABILIZE mode in Plane
local MANU_mode = 0                   -- MANUAL mode in Plane
local period    = 2                   -- sweep rate for servo test
local z                               -- acceleration variable
local accel                           -- for acquiring 3D vector

function statemachine()
if state == 1 then                    -- initialise
  if tick == 0 then
    gcs:send_text(0,"LUA:Servo Sweeps")
  end
  local t  = 0.001 * millis():tofloat()
  local pi = 3.1416
  local output = math.sin(pi * t * period * 2.0 )
  local pwm = math.floor(1500 + 17 * output)       -- 17 should give +/- 5deg sweep maximum

  srv_channels:set_output_pwm( 4, pwm)       
  srv_channels:set_output_pwm(79, pwm)       
  srv_channels:set_output_pwm(80, pwm)     
  tick = tick + 1
  if tick > (50 * 20) then                     -- 20s is up
    state = 2
    tick = 0
    vehicle:set_mode(MANU_mode)
    gcs:send_text(0,"LUA:Waiting for Boost")
  end

elseif state == 2 then                -- wait for boost detect
  accel = ahrs:get_accel()
  z = accel:z()                       -- accel in m/s^2
  if z < ((-1 - boost) * 9.8) then    -- accelerating up, 1 + boost G
    tick = tick + 1
    if (tick > 50) then               -- one second of boost
      state = 3
      tick = 0
      gcs:send_text(0,"LUA:Boost Detected")
    end
  end

elseif state == 3 then                -- wait for decel (end of boost)
  accel = ahrs:get_accel()
  z = accel:z()                       -- accel in m/s^2
  if z > (drag * 9.8) then            -- decelerating due to drag only, freefall otherwise ;-)
    tick = tick + 1
    if tick > 4 then                  -- over 80ms of coast delay, contiguous
      gcs:send_text(0,"LUA:Coast Detected, STAB Set")
      tick = 0
      vehicle:set_mode(STAB_mode)     -- no guts, no glory
      state = 4
      gcs:send_text(0, "Waiting")
    end
  else tick = 0                       -- debouncing
  end

elseif state == 4 then                -- delay here a little, helps with testing
  if tick >4 then
    tick = 0
    state = 5
  else
    tick = tick + 1   
  end

elseif state == 5 then                -- already in STAB, now look to exit to MANU
  tick = tick + 1
  if (tick > 1000) or (math.abs(ahrs:get_roll()) > 0.78) or (math.abs(ahrs:get_pitch()) > 0.78) then  -- angles in radians
    -- exit stabilisation
    -- rocket pitching over towards ground or time exceeds 20s
    tick = 0
    vehicle:set_mode(MANU_mode)
    gcs:send_text(0,"LUA:Flight Complete")
    state = 6
  end

elseif state == 6 then                -- loop forever
  state = 6
  end

return statemachine, 20               -- reschedule every 20ms
end

return statemachine, 10000            -- wait 10s before starting this script

TRA #13430
L3
"Everybody's simulation model is guilty until proven innocent" (Thomas H. Lawrence 1994)

User avatar
OverTheTop
It's only money...
It's only money...
Posts: 2991
Joined: Sat Jul 21, 2007 2:20 pm
Location: Melbourne, Australia

More Hardware

Postby OverTheTop » Mon Jan 25, 2021 3:07 pm

Telemetry Transmitter
I am adding a 1.3GHz telemetry transmitter to the system. This is capable of up to 630mW so I want to keep it as far away as practicable from any other sensitive electronics. The actual module will be mounted as far aft in the VTS as possible, which puts it as far away from the FC as I can reasonably expect.

I created a deck for mounting the telemetry Tx out of some FR4 single-sided PCB. I normally have just used plain G10 fiberglass but in this case I want a groundplane. The idea is to have the ground plane formed by the PCB be an EMC shield between the Tx and the other electronics. Having a ground plane close to the Tx provides a nice return path for any stray RF to go back to the Tx, rather than make its way into other electronics and cause any grief.
A piece was roughly cut and then fitted to the lathe for turning to the right diameter using my dental drill (480k rpm!) and a diamond burr. A piece of brass was machined (lathe and mill) to form a nice earth point for the antenna connector on the Tx module. This will be soldered to the PCB.
Groundplaneresize.jpg


Unsolderedresize.jpg


The brass was pinned down with a titanium bike spoke I had handy, clamped to the bench. This held it in place while I soldered the joint.
Solderingresize.jpg


Once that was down the transmitter was screwed to that and a couple of squirts of hot-melt glue applied to the distal end to bond the module through the PCB. The ground connections were wired directly to the PCB groundplane, and a small capacitor was soldered across the power pins to attenuate any RF on those lines.

Here it is, ready for integration.
VTXready.jpg


I could cover the entire telemetry module with a tin shield but I think this is overkill. Having a decent groundplane goes a long way to improving EMC. Once I have it up and running I can check the field strengths with some EMC field probes and I I can always fit a shield later if needed. I may as well check the magnetic fields from the servos around the compass area with a Gauss meter while I am at it.

Antenna
The antenna needs to be located somewhere also, again not close to anything that matters, and also robust. I was thinking of using a solid ¼ or ½-wave stick, or perhaps a cloverleaf, but that might have put too much force on the SMA connector on the module during landings. Then, in a moment of inspiration, I decided to use a wire antenna, just made from coax that plugs onto the transceiver module. This is similar to what is done for RC receivers on drones and aircraft. The length of the wire can be trimmed using my VNA to allow for any tuning shift caused by the dielectric of the coax cable or the proximity to the f/g airframe. This wire can then just exit the airframe and be taped to the outside, providing a robust and relatively efficient antenna. I will need to make a long socket tool to screw the SMA connector on once the airframe is fitted to the VTS module. If I get keen I might make a flexible PCB for the antenna, and conform it to the outside of the airframe.
TRA #13430
L3
"Everybody's simulation model is guilty until proven innocent" (Thomas H. Lawrence 1994)

User avatar
OverTheTop
It's only money...
It's only money...
Posts: 2991
Joined: Sat Jul 21, 2007 2:20 pm
Location: Melbourne, Australia

Re: Vertical Trajectory System, Mk2 Evolution

Postby OverTheTop » Thu Feb 18, 2021 12:38 pm

A telemetry antenna for the 1.3GHz was made up for the system using a coax pigtail. It was trimmed to the correct frequency using my VNA.
Details here:
https://www.rocketryforum.com/threads/t ... na.164715/

5resize.jpg
TRA #13430
L3
"Everybody's simulation model is guilty until proven innocent" (Thomas H. Lawrence 1994)

User avatar
OverTheTop
It's only money...
It's only money...
Posts: 2991
Joined: Sat Jul 21, 2007 2:20 pm
Location: Melbourne, Australia

Re: Vertical Trajectory System, Mk2 Evolution

Postby OverTheTop » Thu Oct 07, 2021 8:27 pm

I should really do an update on this, but the lockdown (about day 250 so far) is getting to my enthusiasm. I will present a bit of a teaser:
Vid.jpg

This is the HD image from the video telemetry downlink, showcasing the data overlay.

I have done some upgrades on the system, including long-range 900MHz telemetry, added a miniature cooling fan to the flight computer and generally cleaned up and improved the system. New firmware has just gone in with some greatly improved functionality.

I have also been working towards an Automatic Antenna Tracker. I have got one axis of the drive system working, and am about to start on the altitude axis next.


I recently 3D printed a bracket to attach the antenna boom from my GSE to a NEMA 42 stepper motor. That is 7lb worth of motor in the vice! The antenna boom was clamped to the mount and dropped onto the 3/4" (keyed!) motor shaft. Drive was accomplished with a 24v PSU (15A max) and a TIC 36v4 drive board. This was controlled through a RC transmitter and receiver. So this will be the azimuth drive for the Automatic Antenna Tracker. Works well I think.

Those TIC 36v4 drivers are amazing. They allow you to use a stepper motor in either rate or position modes with all sorts of control inputs.
More info here:
https://www.pololu.com/product/3141


Will try to document things a bit better when I feel so inclined.

Share and Enjoy :D
TRA #13430
L3
"Everybody's simulation model is guilty until proven innocent" (Thomas H. Lawrence 1994)


Return to “Higher, Faster, Further”

Who is online

Users browsing this forum: No registered users and 3 guests