Hy,
i'm working on a sensor system that runs at 50 Hz. As such, i'd like to log these sensors onto an SD card at 50Hz aswell. However, i'd like to write the same data at 2Hz to both the USB port and a Serial port (#5) for both wired and wireless monitoring.
However printing all the sensor data (41 different values, floats and ints) 3x using the following code takes a lot of time as the data is converted every time. I tried writing to a buffer using sprintf to format the data and then writing this string to the 3 ports, but this made the system really slow.
I was wondering if the following:
- Is there a way to link the USB Serial and Serial 5 to each other, as i'm writing the same data to them.
- how can i make it format only once and then send 3 times?
Thnx,
RR
i'm working on a sensor system that runs at 50 Hz. As such, i'd like to log these sensors onto an SD card at 50Hz aswell. However, i'd like to write the same data at 2Hz to both the USB port and a Serial port (#5) for both wired and wireless monitoring.
However printing all the sensor data (41 different values, floats and ints) 3x using the following code takes a lot of time as the data is converted every time. I tried writing to a buffer using sprintf to format the data and then writing this string to the 3 ports, but this made the system really slow.
Code:
void SerialTerminal_update(Stream &port) {
SerialTerminal_COMMON(port); port.print(" | ");
SerialTerminal_VI(port); port.print(" | ");
SerialTerminal_RC(port); port.print(" | ");
SerialTerminal_BME(port); port.print(" | ");
SerialTerminal_BNO(port); port.print(" | ");
SerialTerminal_Lidar(port); port.println();*/
}
void SerialTerminal_COMMON(Stream &port) {
port.print(airspeed_value); port.print(" , ");
port.print(rpm_value);
}
void SerialTerminal_VI(Stream &port) {
port.print(v_supply); port.print(" , ");
port.print(v_mot); port.print(" , ");
port.print(v_solar); port.print(" , ");
port.print(i_mot); port.print(" , ");
port.print(i_solar); port.print(" , ");
port.print(used_mah_since_arm); port.print(" , ");
port.print(charged_mah_since_arm); port.print(" , ");
port.print(used_mWh_since_arm); port.print(" , ");
port.print(charged_mWh_since_arm);
}
void SerialTerminal_RC(Stream &port) {
port.print(RC_Roll); port.print(" , ");
port.print(RC_Pitch); port.print(" , ");
port.print(RC_Throttle); port.print(" , ");
port.print(RC_Yaw); port.print(" , ");
port.print(RC_Flaps); port.print(" , ");
port.print(RC_FlightMode); port.print(" , ");
port.print(RC_Arm); port.print(" , ");
port.print(RC_RSSI); port.print(" , ");
port.print(RC_LostFrame); port.print(" , ");
port.print(RC_Failsafe); port.print(" , ");
port.print(RC_Trim_Roll); port.print(" , ");
port.print(RC_Trim_Pitch); port.print(" , ");
port.print(RC_Trim_Yaw);
}
void SerialTerminal_BME(Stream &port) {
port.print(bme_temperature); port.print(" , ");
port.print(bme_pressure); port.print(" , ");
port.print(bme_altitude);
}
void SerialTerminal_BNO(Stream &port) {
port.print(bno_temp); port.print(" , ");
port.print(orient_pitch); port.print(" , ");
port.print(orient_roll); port.print(" , ");
port.print(orient_yaw); port.print(" , ");
port.print(acc_forward); port.print(" , ");
port.print(acc_side); port.print(" , ");
port.print(acc_up); port.print(" , ");
port.print(comp_forward); port.print(" , ");
port.print(comp_side); port.print(" , ");
port.print(comp_up); port.print(" , ");
port.print(gyro_pitch); port.print(" , ");
port.print(gyro_roll); port.print(" , ");
port.print(gyro_yaw);
}
void SerialTerminal_Lidar(Stream &port) {
port.print(lidar_dist);
}
I was wondering if the following:
- Is there a way to link the USB Serial and Serial 5 to each other, as i'm writing the same data to them.
- how can i make it format only once and then send 3 times?
Thnx,
RR