Skip to content

Commit

Permalink
Merge pull request #163 from ericogr/aat-improvements
Browse files Browse the repository at this point in the history
Enhance Automatic Antenna Tracker (AAT) configuration via web interface
  • Loading branch information
pkendall64 authored Oct 19, 2024
2 parents 575681d + 4748d00 commit cfeb404
Show file tree
Hide file tree
Showing 6 changed files with 66 additions and 13 deletions.
3 changes: 3 additions & 0 deletions html/scan.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,10 @@ function updateAatConfig(config)
_('azim_center').value = config.aat.azim_center;
_('azim_min').value = config.aat.azim_min;
_('azim_max').value = config.aat.azim_max;
_('azim_sff').checked = config.aat.azim_sff === 1;
_('elev_min').value = config.aat.elev_min;
_('elev_max').value = config.aat.elev_max;
_('satmin').value = config.aat.satmin;
aatAzimCenterChanged();

// VBAT
Expand Down Expand Up @@ -412,6 +414,7 @@ function aatLineElementChanged()
body: new URLSearchParams({
'bear': _('bear').value,
'elev': _('elev').value,
'azim_sff': _('azim_sff').checked ? 1 : 0,
})
});
}
Expand Down
35 changes: 30 additions & 5 deletions html/vrx_index.html
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,8 @@ <h2>RTC Update via NTP</h2>
<form action="/aatconfig" id="aatconfig" method="POST" class="mui-form">
<div class="mui-panel">
<fieldset><legend>Servo maximum speed</legend>
Use the slider to limit the maximum rotational speed of the servo. Note that when the azimuth servo
must flip from one side to the other, the servo always will move at full speed.
Use the slider to set a limit on the servo's maximum rotational speed. Note that when the azimuth servo
needs to flip from one side to the other, it may move at full speed if the 'Fast Flip' option is enabled.
<input type="range" id="servosmoo" name="servosmoo" list="servosmoo_markers" value="5" min="0" max="9" step="1" style="width: 100%;"/>
<datalist id="servosmoo_markers">
<option value="0" label="Fast" title="Lickedy Speed"></option>
Expand Down Expand Up @@ -138,7 +138,7 @@ <h2>RTC Update via NTP</h2>
</div>
<div class="mui-panel">
<fieldset><legend>Azimuth servo</legend>
Enter the micrsecond (us) values for the min and max position of the horizontal servo, using the slider to test positions.
Enter the microsecond (us) values for the min and max position of the horizontal servo, using the slider to test positions.
<input type="range" id="bear" name="bear" class="aatlive" list="azim_markers" value="0" min="-180" max="180" step="45" style="width: 100%;"/>
<datalist id="bear_markers">
<option value="-180"></option>
Expand All @@ -164,9 +164,15 @@ <h2>RTC Update via NTP</h2>
<input id="azim_max" type="number" name="azim_max" min="500" max="2500"/>
<label for="azim_max">Max</label>
</div>
<div class="mui-checkbox mui-col-xs-12">
<label>
<input id="azim_sff" type="checkbox" name="azim_sff" value="1">
Fast Flip (If the azimuth servo needs to move more than 80% of the distance, jump immediately)
</label>
</div>
</fieldset>
<fieldset><legend>Elevation servo</legend>
Enter the micrsecond (us) values for the min and max position of the vertical servo, using the slider to test positions.
Enter the microsecond (us) values for the min and max position of the vertical servo, using the slider to test positions.
<input type="range" id="elev" name="elev" class="aatlive" list="elev_markers" value="45" min="0" max="90" step="15" style="width: 100%;"/>
<datalist id="elev_markers">
<option value="0" label="0"></option>
Expand All @@ -192,7 +198,7 @@ <h2>RTC Update via NTP</h2>
</div>
<div class="mui-panel">
<fieldset><legend>Battery voltage</legend>
Battery voltage is calculated using the formula <strong>VBAT = (ADC - offset) / scale</strong>. If voltage is reading too high, increase scale.
<div>Battery voltage is calculated using the formula <strong>VBAT = (ADC - offset) / scale</strong>. If voltage is reading too high, increase scale.</div>
<div class="mui-textfield mui-col-xs-6">
<input id="vbat_scale" type="number" name="vbat_scale" min="1" max="1000"/>
<label for="vbat_scale">Scale</label>
Expand All @@ -203,6 +209,25 @@ <h2>RTC Update via NTP</h2>
</div>
</fieldset>
</div>
<div class="mui-panel">
<fieldset>
<legend>Home position settings</legend>
Define the minimum number of satellites required to establish the home position.
<input type="range" id="satmin" name="satmin" list="satmin_markers" min="5" max="21" step="2"
style="width: 100%;" />
<datalist id="satmin_markers">
<option value="5" label="5" title="Less precise"></option>
<option value="7" label="7"></option>
<option value="9" label="9"></option>
<option value="11" label="11"></option>
<option value="13" label="13"></option>
<option value="15" label="15"></option>
<option value="17" label="17"></option>
<option value="19" label="19"></option>
<option value="21" label="21" title="More precise"></option>
</datalist>
</fieldset>
</div>
<input type="hidden" name="commit" value="1"/>
<input type="submit" id="aatsubmit" value="Save" class="mui-btn mui-btn--primary"/>
</form>
Expand Down
13 changes: 13 additions & 0 deletions lib/config/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ VrxBackpackConfig::SetDefaults()
m_config.aat.project = 0xff;
m_config.aat.servoSmooth = 5;
m_config.aat.centerDir = 0; // N
m_config.aat.azimuthServoFastFlip = 1;
m_config.aat.servoEndpoints[0].low = 500; // AZIM
m_config.aat.servoEndpoints[0].high = 2500;
m_config.aat.servoEndpoints[1].low = 1000; // ELEV
Expand Down Expand Up @@ -220,6 +221,12 @@ VrxBackpackConfig::SetAatServoSmooth(uint8_t val)
CONFIG_MOD_CHECK(m_config.aat.servoSmooth, val);
}

void
VrxBackpackConfig::SetAatAzimuthServoFastFlip(uint8_t val)
{
CONFIG_MOD_CHECK(m_config.aat.azimuthServoFastFlip, val);
}

void
VrxBackpackConfig::SetAatServoLow(uint8_t idx, uint16_t val)
{
Expand Down Expand Up @@ -256,6 +263,12 @@ VrxBackpackConfig::SetAatServoMode(uint8_t val)
CONFIG_MOD_CHECK(m_config.aat.servoMode, val);
}

void
VrxBackpackConfig::SetAatSatelliteHomeMin(uint8_t val)
{
CONFIG_MOD_CHECK(m_config.aat.satelliteHomeMin, val);
}

/**
* @brief: Validate that the endpoints have a valid range, i.e. low/high not the same
*/
Expand Down
18 changes: 11 additions & 7 deletions lib/config/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,14 @@ typedef struct {

#if defined(AAT_BACKPACK)
struct __attribute__((packed)) tagAatConfig {
uint8_t satelliteHomeMin; // minimum number of satellites to establish home
uint8_t servoSmooth; // 0-9 for min smoothing to most smoothing
uint8_t centerDir; // Direction servo points at center position 0=N 2=E 4=S 6=W (can hold 45 degrees but only 90 is supported)
uint8_t project; // FUTURE: 0=none, 1=projectAzim, 2=projectElev, 3=projectBoth
uint8_t units; // FUTURE: 0=meters, anything else=also meters :-D
uint8_t servoMode; // 0=2:1, 1=clip180, FUTURE: 180+flip servo
// Also maybe invertAzim / invertElev servo bit or just swap low/high
uint8_t satelliteHomeMin; // minimum number of satellites to establish home
uint8_t azimuthServoFastFlip; // 0=off, 1=on
uint8_t servoSmooth; // 0-9 for min smoothing to most smoothing
uint8_t centerDir; // Direction servo points at center position 0=N 2=E 4=S 6=W (can hold 45 degrees but only 90 is supported)
uint8_t project; // FUTURE: 0=none, 1=projectAzim, 2=projectElev, 3=projectBoth
uint8_t units; // FUTURE: 0=meters, anything else=also meters :-D
uint8_t servoMode; // 0=2:1, 1=clip180, FUTURE: 180+flip servo
// Also maybe invertAzim / invertElev servo bit or just swap low/high
struct __attribute__((packed)) tagServoEndoint {
uint16_t low;
uint16_t high;
Expand Down Expand Up @@ -129,6 +130,9 @@ class VrxBackpackConfig

#if defined(AAT_BACKPACK)
uint8_t GetAatSatelliteHomeMin() const { return m_config.aat.satelliteHomeMin; }
void SetAatSatelliteHomeMin(uint8_t val);
uint8_t GetAatAzimuthServoFastFlip() const { return m_config.aat.azimuthServoFastFlip; }
void SetAatAzimuthServoFastFlip(uint8_t val);
uint8_t GetAatServoSmooth() const { return m_config.aat.servoSmooth; }
void SetAatServoSmooth(uint8_t val);
uint8_t GetAatServoMode() const { return m_config.aat.servoMode; }
Expand Down
8 changes: 8 additions & 0 deletions src/devwifi_proxy_aat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ void WebAatAppendConfig(ArduinoJson::JsonDocument &json)
{
auto aat = json["config"].createNestedObject("aat");
aat["satmin"] = config.GetAatSatelliteHomeMin();
aat["azim_sff"] = config.GetAatAzimuthServoFastFlip();
aat["servosmoo"] = config.GetAatServoSmooth();
aat["servomode"] = config.GetAatServoMode();
aat["project"] = config.GetAatProject();
Expand All @@ -28,6 +29,10 @@ void WebAatConfig(AsyncWebServerRequest *request)
// Servos
if (request->hasArg("servosmoo"))
config.SetAatServoSmooth(request->arg("servosmoo").toInt());
if (request->hasArg("azim_sff"))
config.SetAatAzimuthServoFastFlip(request->arg("azim_sff").toInt());
else
config.SetAatAzimuthServoFastFlip(0);
if (request->hasArg("servomode"))
config.SetAatServoMode(request->arg("servomode").toInt());
if (request->hasArg("azim_center"))
Expand All @@ -50,6 +55,9 @@ void WebAatConfig(AsyncWebServerRequest *request)
vrxModule.overrideTargetBearing(request->arg("bear").toInt());
if (request->hasArg("elev"))
vrxModule.overrideTargetElev(request->arg("elev").toInt());
// Satellite Config
if (request->hasArg("satmin"))
config.SetAatSatelliteHomeMin(request->arg("satmin").toInt());

const char *response;
if (request->arg("commit").toInt() == 1)
Expand Down
2 changes: 1 addition & 1 deletion src/module_aat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -578,7 +578,7 @@ void AatModule::servoUpdate(uint32_t now)
int32_t maxDiff = (10 - config.GetAatServoSmooth()) * SMOOTHNESS_US_PER_STEP;
// If the distance the servo needs to go is more than 80% away
// jump immediately. otherwise smooth it
if (idx == IDX_AZIM && (abs(diff) * 100 / range) > 80)
if (config.GetAatAzimuthServoFastFlip() && idx == IDX_AZIM && (abs(diff) * 100 / range) > 80)
{
// Prevent the servo from flipping back and forth around the 180 point
// by only allowing 1 flip ever Xms. Just keep pushing toward the limit
Expand Down

0 comments on commit cfeb404

Please sign in to comment.