mirror of
https://github.com/lekrsu/shfw-walkthrough.git
synced 2024-11-27 16:00:52 +01:00
Fixed up the logic website
This commit is contained in:
parent
0b6dd4c1ef
commit
422b69d1f2
@ -9,6 +9,7 @@
|
||||
<body>
|
||||
<div class="container">
|
||||
<h1>Peak Current Draw Calculator</h1>
|
||||
<p class="note">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.</p>
|
||||
<div class="input-section">
|
||||
<!-- Iq (Torque component) -->
|
||||
<label for="torqueAmps">Torque amps (I<sub>q</sub>) in A:</label>
|
||||
@ -22,7 +23,7 @@
|
||||
<input type="number" id="variableFlux">
|
||||
<label for="currentMaxSpeed">Current max speed in km/h:</label>
|
||||
<input type="number" id="currentMaxSpeed">
|
||||
<label for="activationSpeed">Start speed in km/h:</label>
|
||||
<label for="activationSpeed">Field weakening start speed in km/h:</label>
|
||||
<input type="number" id="activationSpeed">
|
||||
</div>
|
||||
<button onclick="calculatePeakCurrentDraw()">Calculate Peak Current Draw (I<sub>total</sub>)</button>
|
||||
|
@ -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 (I<sub>total</sub>): ${ITotal} A<br>
|
||||
if (totalFluxAmps > 30) {
|
||||
fluxMessage = '<p style="color: red;">Warning: Flux current exceeds the default 30A phase limit. Please review the system configuration.</p>';
|
||||
}
|
||||
|
||||
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 (I<sub>total</sub>): ${ITotal} A<br>
|
||||
Torque Component (I<sub>q</sub>): ${torqueAmps} A<br>
|
||||
Flux Component (I<sub>d</sub>): ${fieldWeakeningAmps.toFixed(2)} A`;
|
||||
Flux Component (I<sub>d</sub>): ${totalFluxAmps.toFixed(2)} A`;
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user