Skip to content
Snippets Groups Projects
Verified Commit 64fd523d authored by Thomas Lambert's avatar Thomas Lambert :helicopter:
Browse files

feat(log): logging with serial-studio

parent f0f5aa7a
No related branches found
No related tags found
No related merge requests found
......@@ -13,6 +13,13 @@ This repository contains the Arduino code and mounting schematics.
- To be determined
## Data logging and visualization
The controller sends the important data through serial. A [_json_ configuration
file](mechaRaptor.json) is provided in order to visualize the output stream in
real time with [serial-studio]. This also allows the logging and retention of
all data in _csv_ spreadsheets for future analysis.
## Material
The system consists in two independent sets of wings, powered separately. A
......@@ -26,3 +33,4 @@ single Arduino board is used to control both motors.
## Schematics
[plettenberg]: https://plettenbergmotors.com/
[serial-studio]: https://serial-studio.github.io/
......@@ -42,13 +42,27 @@ void loop() {
int potAnal = analogRead(A0); // read potentiometer value (between 0 and 1023)
int potVal = map(potAnal, 0, 1023, 0, 180); // scale potentiometer value to use with servo lib
// [DEBUG] SERIAL OUTPUT
Serial.print("Pot analogue: ");
Serial.print(potAnal);
Serial.print(", Mapped: ");
Serial.println(potVal);
// [TEST] Write sine values for visualization in serial-studio
float freq = 10;
float angleL = sin(millis()*1000*freq);
float angleR = cos(millis()*1000*freq);;
// Send values to ESCs (currently both receive the same input)
ESC1.write(potVal);
ESC2.write(potVal);
// Print all useful data to serial for processing in serial-studio
Serial.print("/*"); // Frame start sequence [/*]
Serial.print(millis()/1000.0); // %1, MCU runtime [s]
Serial.print(",");
Serial.print(potAnal*5.0/1023.0); // %2, Tension of potentiometer [V]
Serial.print(",");
Serial.print(potVal); // %3, Mapped value of potentiometer [-]
Serial.print(",");
Serial.print(angleL); // %4, Left wing angle [deg]
Serial.print(",");
Serial.print(angleR); // %5, Right wing angle [deg]
Serial.println("*/"); // Frame finish sequence [*/]
delay(50); // Reduce number of data to output
}
{
"frameEnd": "",
"frameStart": "",
"groups": [
{
"datasets": [
{
"alarm": 0,
"fft": false,
"fftSamples": 1024,
"graph": false,
"led": false,
"log": false,
"max": 0,
"min": 0,
"title": "Runtime",
"units": "s",
"value": "%1",
"widget": ""
}
],
"title": "Runtime",
"widget": ""
},
{
"datasets": [
{
"alarm": 0,
"fft": false,
"fftSamples": 1024,
"graph": false,
"led": false,
"log": false,
"max": 0,
"min": 0,
"title": "Potentiometer tension",
"units": "V",
"value": "%2",
"widget": ""
},
{
"alarm": 180,
"fft": false,
"fftSamples": 1024,
"graph": false,
"led": false,
"log": false,
"max": 180,
"min": 0,
"title": "Potentiometer mapped",
"units": "",
"value": "%3",
"widget": "gauge"
}
],
"title": "Inputs",
"widget": ""
},
{
"datasets": [
{
"alarm": 0,
"fft": false,
"fftSamples": 1024,
"graph": false,
"led": false,
"log": false,
"max": 0,
"min": 0,
"title": "Left",
"units": "deg",
"value": "%4",
"widget": ""
},
{
"alarm": 0,
"fft": false,
"fftSamples": 1024,
"graph": false,
"led": false,
"log": false,
"max": 0,
"min": 0,
"title": "Right",
"units": "deg",
"value": "%5",
"widget": ""
}
],
"title": "Wing angles",
"widget": "multiplot"
}
],
"separator": ",",
"title": "MechaRaptor"
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment