Skip to content

Commit 7c72c6d

Browse files
committed
Hardcode and remove the Loop Hertz config option
Feature: Remove the Loop Hertz config option > The value no longer directly influences motor control and is now hard-coded to 500 Hz.
1 parent 88acd10 commit 7c72c6d

3 files changed

Lines changed: 5 additions & 30 deletions

File tree

‎src/conf/datatypes.h‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,6 @@ typedef struct {
214214
float mahony_kp_roll;
215215
float kp_brake;
216216
float kp2_brake;
217-
uint16_t hertz;
218217
float fault_pitch;
219218
float fault_roll;
220219
float fault_adc1;

‎src/conf/settings.xml‎

Lines changed: 1 addition & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -221,30 +221,6 @@ p, li { white-space: pre-wrap; }
221221
<suffix>x</suffix>
222222
<vTx>7</vTx>
223223
</kp2_brake>
224-
<hertz>
225-
<longName>Loop Hertz</longName>
226-
<type>2</type>
227-
<transmittable>1</transmittable>
228-
<description>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
229-
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
230-
p, li { white-space: pre-wrap; }
231-
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'Roboto'; ; font-weight:400; font-style:normal;&quot;&gt;
232-
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-weight:600; text-decoration: underline;&quot;&gt;Frequency of Balance Loop Cycle&lt;/span&gt;&lt;/p&gt;
233-
&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-weight:600; text-decoration: underline;&quot;&gt;&lt;br /&gt;&lt;/p&gt;
234-
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-style:italic;&quot;&gt;Recommended Value: Same or multiple of IMU Sample Rate&lt;/span&gt;&lt;/p&gt;
235-
&lt;ul style=&quot;margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; -qt-list-indent: 1;&quot;&gt;&lt;li style=&quot; font-style:italic;&quot; style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;Little FOCer v3.1 (LSM6DS3): 832Hz&lt;/li&gt;
236-
&lt;li style=&quot; font-style:italic;&quot; style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;Little FOCer v3 (BMI160): 800Hz&lt;/li&gt;&lt;/ul&gt;&lt;/body&gt;&lt;/html&gt;</description>
237-
<cDefine>CFG_DFLT_HERTZ</cDefine>
238-
<editorScale>1</editorScale>
239-
<editAsPercentage>0</editAsPercentage>
240-
<maxInt>4000</maxInt>
241-
<minInt>50</minInt>
242-
<showDisplay>0</showDisplay>
243-
<stepInt>16</stepInt>
244-
<valInt>832</valInt>
245-
<suffix> Hz</suffix>
246-
<vTx>3</vTx>
247-
</hertz>
248224
<fault_pitch>
249225
<longName>Pitch Axis Fault Cutoff</longName>
250226
<type>2</type>
@@ -1169,7 +1145,7 @@ p, li { white-space: pre-wrap; }
11691145
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'Roboto'; ; font-weight:400; font-style:normal;&quot;&gt;
11701146
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;Vibrating frequency of both Warning and Error haptic feedback.&lt;/p&gt;
11711147
&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;br /&gt;&lt;/p&gt;
1172-
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-style:italic;&quot;&gt;Note: When changing this option, the actual frequency will be changing in larger discrete steps, as the configured frequency is being rounded down to the nearest division of Loop Hertz / 2.&lt;/span&gt;&lt;/p&gt;
1148+
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-style:italic;&quot;&gt;Note: When changing this option, the actual frequency will be changing in larger discrete steps, as the configured frequency is being rounded down to the nearest division of control loop frequency / 2.&lt;/span&gt;&lt;/p&gt;
11731149
&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;br /&gt;&lt;/p&gt;
11741150
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-style:italic;&quot;&gt;(generated by modulating a square wave on requested current, not using foc_play_tone from 6.05)&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</description>
11751151
<cDefine>CFG_DFLT_HAPTIC_VIBRATE_FREQUENCY</cDefine>
@@ -3916,7 +3892,6 @@ p, li { white-space: pre-wrap; }
39163892
<ser>mahony_kp_roll</ser>
39173893
<ser>kp_brake</ser>
39183894
<ser>kp2_brake</ser>
3919-
<ser>hertz</ser>
39203895
<ser>fault_pitch</ser>
39213896
<ser>fault_roll</ser>
39223897
<ser>fault_adc1</ser>
@@ -4301,7 +4276,6 @@ p, li { white-space: pre-wrap; }
43014276
<param>::sep::Refloat Package Details</param>
43024277
<param>disabled</param>
43034278
<param>::sep::Balance Loop</param>
4304-
<param>hertz</param>
43054279
<param>::sep::Voltage Pushbacks</param>
43064280
<param>tiltback_hv</param>
43074281
<param>tiltback_lv</param>

‎src/main.c‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@
5757

5858
HEADER
5959

60+
#define MAIN_THREAD_FREQ 500
61+
6062
typedef enum {
6163
BEEP_NONE = 0,
6264
BEEP_LV = 1,
@@ -195,7 +197,7 @@ static void reconfigure(Data *d) {
195197
static void configure(Data *d) {
196198
state_set_disabled(&d->state, d->float_conf.disabled);
197199

198-
d->main_loop_ticks = SYSTEM_TICK_RATE_HZ / d->float_conf.hertz;
200+
d->main_loop_ticks = SYSTEM_TICK_RATE_HZ / MAIN_THREAD_FREQ;
199201

200202
// Backwards compatibility hack:
201203
// If mahony kp from the firmware internal filter is higher than 1, it's
@@ -1209,7 +1211,7 @@ static void data_init(Data *d) {
12091211

12101212
time_init(&d->time);
12111213

1212-
frequency_tracker_init(&d->main_freq_tracker, d->float_conf.hertz, &d->time);
1214+
frequency_tracker_init(&d->main_freq_tracker, MAIN_THREAD_FREQ, &d->time);
12131215
int imu_sample_rate = VESC_IF->get_cfg_int(CFG_PARAM_IMU_sample_rate);
12141216
if (imu_sample_rate == 0) {
12151217
// 6.02 doesn't provide IMU frequency; use a random number between 416

0 commit comments

Comments
 (0)