From 422b69d1f293f85009dbe9da8f2e79f836fdb899 Mon Sep 17 00:00:00 2001 From: lekrsu <17946529+lekrsu@users.noreply.github.com> Date: Fri, 10 May 2024 17:37:02 +0200 Subject: [PATCH] Fixed up the logic website --- logic/index.html | 3 ++- logic/script.js | 25 ++++++++++++++++--------- logic/style.css | 12 ++---------- 3 files changed, 20 insertions(+), 20 deletions(-) diff --git a/logic/index.html b/logic/index.html index 6d67a53..9d8fa02 100644 --- a/logic/index.html +++ b/logic/index.html @@ -9,6 +9,7 @@

Peak Current Draw Calculator

+

Note: The values calculated here represent theoretical outputs based on input parameters. Actual values may vary due to system efficiency, environmental conditions, and component tolerances. Please use these values for planning purposes and consult hardware specifications for real-world applications.

@@ -22,7 +23,7 @@ - +
diff --git a/logic/script.js b/logic/script.js index 7780742..d7f5057 100644 --- a/logic/script.js +++ b/logic/script.js @@ -1,19 +1,26 @@ function calculatePeakCurrentDraw() { - // Gathering inputs const torqueAmps = parseFloat(document.getElementById('torqueAmps').value); // Iq (Torque component) const initialFlux = parseFloat(document.getElementById('initialFlux').value); // Id base component - const variableFlux = parseFloat(document.getElementById('variableFlux').value) / 1000; // Convert mAh to A and represent Id variable component + const variableFlux = parseFloat(document.getElementById('variableFlux').value) / 1000; // Convert mAh to A for Id variable component const currentMaxSpeed = parseFloat(document.getElementById('currentMaxSpeed').value); const startSpeed = parseFloat(document.getElementById('activationSpeed').value); - // Calculating Id (Flux component) including field weakening effect - const fieldWeakeningAmps = initialFlux + (variableFlux * (currentMaxSpeed - startSpeed)); + let totalFluxAmps = initialFlux; + let fluxMessage = ''; - // Calculating Peak Current Draw (I_total) using Pythagorean theorem - const ITotal = Math.sqrt(Math.pow(torqueAmps, 2) + Math.pow(fieldWeakeningAmps, 2)).toFixed(2); + // Apply field weakening effect based on speed difference if applicable + if (currentMaxSpeed >= startSpeed) { + totalFluxAmps += variableFlux * (currentMaxSpeed - startSpeed); // Multiply variable flux per km/h above activation speed + } - // Displaying the result - document.getElementById('result').innerHTML = `Peak Current Draw (Itotal): ${ITotal} A
+ if (totalFluxAmps > 30) { + fluxMessage = '

Warning: Flux current exceeds the default 30A phase limit. Please review the system configuration.

'; + } + + const ITotal = Math.sqrt(Math.pow(torqueAmps, 2) + Math.pow(totalFluxAmps, 2)).toFixed(2); + + const resultDiv = document.getElementById('result'); + resultDiv.innerHTML = fluxMessage + `Total Peak Current Draw (Itotal): ${ITotal} A
Torque Component (Iq): ${torqueAmps} A
- Flux Component (Id): ${fieldWeakeningAmps.toFixed(2)} A`; + Flux Component (Id): ${totalFluxAmps.toFixed(2)} A`; } diff --git a/logic/style.css b/logic/style.css index a1b3fed..2f0c059 100644 --- a/logic/style.css +++ b/logic/style.css @@ -1,3 +1,4 @@ +css body { font-family: Arial, sans-serif; background-color: #121212; @@ -11,7 +12,6 @@ body { max-width: 600px; margin: 20px auto; padding: 0 15px; - /* Add horizontal padding here */ box-sizing: border-box; } @@ -23,35 +23,27 @@ body { .input-section input, button { width: 100%; - /* Full width */ padding: 10px; margin-bottom: 20px; - /* Spacing between elements */ background-color: #333; border: 1px solid #444; - /* Subtle border */ color: white; box-sizing: border-box; - /* Include padding and border in the element's total width and height */ } button { cursor: pointer; display: block; - /* Ensure it's block-level */ } -/* Responsive adjustments for mobile devices */ @media (max-width: 768px) { .container { margin: 10px; - /* Smaller margin on smaller screens */ } - /* Inputs and button fill the width minus the container's padding */ .input-section input, button { margin-left: auto; margin-right: auto; } -} \ No newline at end of file +}