Merge pull request #321 from DL6ER/development

Add vibrations RMS to Motors tab
10.3.x-maintenance
Dominic Clifton 2016-01-30 12:32:22 +01:00
commit 6935fa62ce
3 changed files with 31 additions and 4 deletions

View File

@ -30,7 +30,7 @@
width: 160px; width: 160px;
/* border: 1px solid silver; */ /* border: 1px solid silver; */
height: 100%; height: 100%;
height: 160px; height: 180px;
margin: 0px; margin: 0px;
background-color: #ECECEC; background-color: #ECECEC;
border-top-right-radius: 3px; border-top-right-radius: 3px;
@ -107,6 +107,18 @@
text-align: right; text-align: right;
} }
.tab-motors .plot_control .rms {
background-color: #00D800;
padding: 3px;
color: #fff;
height: 12px;
float: right;
border-radius: 3px;
line-height: 12px;
margin-bottom: 2px;
text-align: right;
}
.tab-motors .plot_control .x, .tab-sensors .plot_control .y, .tab-sensors .plot_control .z { .tab-motors .plot_control .x, .tab-sensors .plot_control .y, .tab-sensors .plot_control .z {
text-align: right; text-align: right;
} }

View File

@ -54,6 +54,8 @@
<dd class="y">0</dd> <dd class="y">0</dd>
<dt>Z:</dt> <dt>Z:</dt>
<dd class="z">0</dd> <dd class="z">0</dd>
<dt>RMS:</dt>
<dd class="rms">0</dd>
</dl> </dl>
</div> </div>
</div> </div>

View File

@ -202,17 +202,20 @@ TABS.motors.initialize = function (callback) {
var raw_data_text_ements = { var raw_data_text_ements = {
x: [], x: [],
y: [], y: [],
z: [] z: [],
rms: []
}; };
$('.plot_control .x, .plot_control .y, .plot_control .z').each(function () { $('.plot_control .x, .plot_control .y, .plot_control .z, .plot_control .rms').each(function () {
var el = $(this); var el = $(this);
if (el.hasClass('x')) { if (el.hasClass('x')) {
raw_data_text_ements.x.push(el); raw_data_text_ements.x.push(el);
} else if (el.hasClass('y')) { } else if (el.hasClass('y')) {
raw_data_text_ements.y.push(el); raw_data_text_ements.y.push(el);
} else { } else if (el.hasClass('z')) {
raw_data_text_ements.z.push(el); raw_data_text_ements.z.push(el);
} else if (el.hasClass('rms')) {
raw_data_text_ements.rms.push(el);
} }
}); });
@ -265,9 +268,19 @@ TABS.motors.initialize = function (callback) {
samples_accel_i = addSampleToData(accel_data, samples_accel_i, accel_with_offset); samples_accel_i = addSampleToData(accel_data, samples_accel_i, accel_with_offset);
drawGraph(accelHelpers, accel_data, samples_accel_i); drawGraph(accelHelpers, accel_data, samples_accel_i);
// Compute RMS of acceleration in displayed period of time
// This is particularly useful for motor balancing as it
// eliminates the need for external tools
var sum = 0.0;
for (var j = 0; j < accel_data.length; j++)
for (var k = 0; k < accel_data[j].length; k++)
sum += accel_data[j][k][1]*accel_data[j][k][1];
var rms = Math.sqrt(sum/(accel_data[0].length+accel_data[1].length+accel_data[2].length));
raw_data_text_ements.x[0].text(accel_with_offset[0].toFixed(2) + ' (' + accel_max_read[0].toFixed(2) + ')'); raw_data_text_ements.x[0].text(accel_with_offset[0].toFixed(2) + ' (' + accel_max_read[0].toFixed(2) + ')');
raw_data_text_ements.y[0].text(accel_with_offset[1].toFixed(2) + ' (' + accel_max_read[1].toFixed(2) + ')'); raw_data_text_ements.y[0].text(accel_with_offset[1].toFixed(2) + ' (' + accel_max_read[1].toFixed(2) + ')');
raw_data_text_ements.z[0].text(accel_with_offset[2].toFixed(2) + ' (' + accel_max_read[2].toFixed(2) + ')'); raw_data_text_ements.z[0].text(accel_with_offset[2].toFixed(2) + ' (' + accel_max_read[2].toFixed(2) + ')');
raw_data_text_ements.rms[0].text(rms.toFixed(4));
for (var i = 0; i < 3; i++) { for (var i = 0; i < 3; i++) {
if (Math.abs(accel_with_offset[i]) > Math.abs(accel_max_read[i])) accel_max_read[i] = accel_with_offset[i]; if (Math.abs(accel_with_offset[i]) > Math.abs(accel_max_read[i])) accel_max_read[i] = accel_with_offset[i];