Added RMS display in Motors tab

10.3.x-maintenance
Dominik Derigs 2016-01-17 22:54:10 +01:00
parent 2581abb662
commit a3c39289bd
3 changed files with 43 additions and 7 deletions

View File

@ -30,7 +30,7 @@
width: 160px;
/* border: 1px solid silver; */
height: 100%;
height: 160px;
height: 180px;
margin: 0px;
background-color: #ECECEC;
border-top-right-radius: 3px;
@ -107,6 +107,18 @@
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 {
text-align: right;
}

View File

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

View File

@ -66,7 +66,6 @@ TABS.motors.initialize = function (callback) {
}
return data;
}
function addSampleToData(data, sampleNumber, sensorData) {
for (var i = 0; i < data.length; i++) {
var dataPoint = sensorData[i];
@ -78,6 +77,7 @@ TABS.motors.initialize = function (callback) {
data[i].max = dataPoint;
}
}
while (data[0].length > 300) {
for (i = 0; i < data.length; i++) {
data[i].shift();
@ -201,17 +201,20 @@ TABS.motors.initialize = function (callback) {
var raw_data_text_ements = {
x: [],
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);
if (el.hasClass('x')) {
raw_data_text_ements.x.push(el);
} else if (el.hasClass('y')) {
raw_data_text_ements.y.push(el);
} else {
} else if (el.hasClass('z')) {
raw_data_text_ements.z.push(el);
} else if (el.hasClass('rms')) {
raw_data_text_ements.rms.push(el);
}
});
@ -261,12 +264,31 @@ TABS.motors.initialize = function (callback) {
];
updateGraphHelperSize(accelHelpers);
samples_accel_i = addSampleToData(accel_data, samples_accel_i, accel_with_offset);
samples_accel_i = addSampleToData(accel_data, samples_accel_i, accel_with_offset,rms);
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 k = 0; k < accel_data[0].length; k++)
{
sum += accel_data[0][k][1]*accel_data[0][k][1];
}
for (var k = 0; k < accel_data[1].length; k++)
{
sum += accel_data[1][k][1]*accel_data[1][k][1];
}
for (var k = 0; k < accel_data[2].length; k++)
{
sum += accel_data[2][k][1]*accel_data[2][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.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.rms[0].text(rms.toFixed(4));
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];