Compare commits

..
9 changed files with 42 additions and 14 deletions

No files matched your search

+17 -4
View File
@@ -53,11 +53,11 @@ export function createChart({
}
// Build uPlot data for ALL series (including hidden ones)
const uPlotData: uPlot.AlignedData = [timestamps as uPlot.AlignedData[0]];
const uPlotData: uPlot.AlignedData = [timestamps as any];
allOriginalSeries.forEach(({ series }) => {
const [, values] = seriesToUPlotData(series.long);
uPlotData.push(values as uPlot.AlignedData[1]);
uPlotData.push(values as any);
});
// Add config lines data
@@ -70,7 +70,7 @@ export function createChart({
line.value,
)
: new Array(timestamps.length).fill(line.value);
uPlotData.push(lineData as uPlot.AlignedData[number]);
uPlotData.push(lineData as any);
}
});
@@ -367,13 +367,26 @@ export function createChart({
return ticks.map((ts) => {
const date = new Date(ts);
if (timeRange <= 5 * 60 * 1000) {
if (timeRange <= 30 * 1000) {
return date.toLocaleTimeString(undefined, {
hour12: false,
hour: "2-digit",
minute: "2-digit",
second: "2-digit",
});
} else if (timeRange <= 5 * 60 * 1000) {
return date.toLocaleTimeString(undefined, {
hour12: false,
hour: "2-digit",
minute: "2-digit",
second: "2-digit",
});
} else if (timeRange <= 60 * 60 * 1000) {
return date.toLocaleTimeString(undefined, {
hour12: false,
hour: "2-digit",
minute: "2-digit",
});
} else if (timeRange <= 24 * 60 * 60 * 1000) {
return date.toLocaleTimeString(undefined, {
hour12: false,
+1 -1
View File
@@ -63,7 +63,7 @@
electron
];
ELECTRON_SKIP_BINARY_DOWNLOAD = 1;
ELECTON_SKIP_BINARY_DOWNLOAD = 1;
hardeningDisable = [ "fortify" ];
+2 -2
View File
@@ -252,7 +252,7 @@ impl ExtruderV2 {
self.screw_speed_controller.set_target_screw_rpm(
self.screw_speed_controller.target_rpm,
AngularVelocity::new::<revolution_per_minute>(1500.0),
4,
self.screw_speed_controller.motor_poles,
);
self.screw_speed_controller.set_uses_rpm(uses_rpm);
}
@@ -274,7 +274,7 @@ impl ExtruderV2 {
self.screw_speed_controller.set_target_screw_rpm(
AngularVelocity::new::<revolution_per_minute>(rpm),
AngularVelocity::new::<revolution_per_minute>(1500.0),
4,
self.screw_speed_controller.motor_poles,
);
self.emit_state();
}
+3
View File
@@ -214,12 +214,15 @@ impl MachineNewTrait for ExtruderV2 {
let target_pressure = Pressure::new::<bar>(0.0);
let target_rpm = AngularVelocity::new::<revolution_per_minute>(0.0);
let motor_poles = 4;
let screw_speed_controller = ScrewSpeedController::new(
inverter,
target_pressure,
target_rpm,
pressure_sensor,
FixedTransmission::new(1.0 / 34.0),
motor_poles,
);
let (sender, receiver) = smol::channel::unbounded();
@@ -9,7 +9,7 @@ use ethercat_hal::io::analog_input::AnalogInput;
use units::angular_velocity::revolution_per_minute;
use units::electric_current::milliampere;
use units::f64::*;
use units::frequency::{cycle_per_minute, hertz};
use units::frequency::hertz;
use units::pressure::bar;
use crate::extruder1::mitsubishi_cs80::MitsubishiCS80Status;
@@ -21,6 +21,7 @@ pub struct ScrewSpeedController {
pub pid: ClampingTimeagnosticPidController,
pub target_pressure: Pressure,
pub target_rpm: AngularVelocity,
pub motor_poles: usize,
pub inverter: MitsubishiCS80,
pressure_sensor: AnalogInput,
last_update: Instant,
@@ -42,6 +43,7 @@ impl ScrewSpeedController {
target_rpm: AngularVelocity,
pressure_sensor: AnalogInput,
transmission: FixedTransmission,
motor_poles: usize,
) -> Self {
let now = Instant::now();
Self {
@@ -62,6 +64,7 @@ impl ScrewSpeedController {
frequency: Frequency::new::<hertz>(0.0),
maximum_frequency: Frequency::new::<hertz>(60.0),
minimum_frequency: Frequency::new::<hertz>(0.0),
motor_poles,
}
}
@@ -150,10 +153,13 @@ impl ScrewSpeedController {
pub fn get_motor_status(&self) -> MotorStatus {
let frequency = self.inverter.motor_status.frequency;
let rpm =
AngularVelocity::new::<revolution_per_minute>(frequency.get::<cycle_per_minute>());
let motor_rpm = AngularVelocity::new::<revolution_per_minute>(
frequency.get::<hertz>() * 120.0 / self.motor_poles as f64,
);
let screw_rpm = self.transmission.calculate_angular_velocity_output(rpm);
let screw_rpm = self
.transmission
.calculate_angular_velocity_output(motor_rpm);
let mut status = self.inverter.motor_status;
status.rpm = screw_rpm;
+2 -2
View File
@@ -278,7 +278,7 @@ impl ExtruderV3 {
self.screw_speed_controller.set_target_screw_rpm(
self.screw_speed_controller.target_rpm,
AngularVelocity::new::<revolution_per_minute>(3000.0),
2,
self.screw_speed_controller.motor_poles,
);
self.screw_speed_controller.set_uses_rpm(uses_rpm);
}
@@ -300,7 +300,7 @@ impl ExtruderV3 {
self.screw_speed_controller.set_target_screw_rpm(
AngularVelocity::new::<revolution_per_minute>(rpm),
AngularVelocity::new::<revolution_per_minute>(3000.0),
2,
self.screw_speed_controller.motor_poles,
);
self.emit_state();
}
+3
View File
@@ -213,12 +213,15 @@ impl MachineNewTrait for ExtruderV3 {
let target_pressure = Pressure::new::<bar>(0.0);
let target_rpm = AngularVelocity::new::<revolution_per_minute>(0.0);
let motor_poles = 2;
let screw_speed_controller = ScrewSpeedController::new(
inverter,
target_pressure,
target_rpm,
pressure_sensor,
FixedTransmission::new(1.0 / 30.0),
motor_poles,
);
let (sender, receiver) = smol::channel::unbounded();
+1 -1
View File
@@ -42,7 +42,7 @@ in {
# - CONS: Vulnerable to Spectre, Meltdown, Foreshadow, ZombieLoad, etc.
# Should ONLY be used in completely trusted environments
# - Improves performance by 7-43%
"mitigations=off"
"mitigation=off"
"intel_pstate=performance" # Intel CPU-specific performance mode (if applicable)
# Memory Management
+3
View File
@@ -30,6 +30,9 @@ docker run --rm \
--workdir /workspace \
nixos/nix:latest \
sh -c "
whoami
ls -lh
cd /workspace
echo 'Enabling flakes and nix-command...'
mkdir -p ~/.config/nix
echo 'experimental-features = nix-command flakes' > ~/.config/nix/nix.conf