Peak calculator added

This commit is contained in:
lekrsu 2024-03-24 14:53:43 +01:00
parent b0a5639543
commit a5c8b353e8
4 changed files with 105 additions and 2 deletions

View File

@ -5,13 +5,13 @@ SHFW is a custom firmware available for flashing via the Scooterhacking Utility
- [Quick SHFW Configuration Walkthrough](#quick-shfw-configuration-walkthrough)
- [Installation](#installation)
- [Usage](#usage)
- [Peak Current Draw Calculator](#peak-current-draw-calculator)
- [Ninebot G30](#ninebot-g30)
- [Xiaomi Pro 2, 3](#xiaomi-pro-2-3)
- [Xiaomi Essential, Lite, 1S](#xiaomi-essential-lite-1s)
- [Field Weakening Calculations and Logic](#field-weakening-calculations-and-logic)
- [What is Field Weakening?](#what-is-field-weakening)
- [Field Weakening Flux Calculation](#field-weakening-flux-calculation)
- [Recommended Field Weakening Settings](#recommended-field-weakening-settings)
- [Custom batteries and BMS emulation](#custom-batteries-and-bms-emulation)
- [Upcoming Features](#upcoming-features)
- [ADC modding info (G30)](#adc-modding-info-g30)
@ -52,6 +52,15 @@ To install SHFW, follow these steps:
Please be aware that the information provided below is intended for practical use, but it should be used with caution. Remember, field weakening, because of its nature, will not be efficient.
### Peak Current Draw Calculator
- **Torque Amps Calculation**: Users can input their torque amps (\(I_q\)) to calculate the torque component accurately.
- **Field Weakening Calculation**: By entering the initial flux in A, variable flux in mAh, current max speed in km/h, and start speed in km/h, the calculator determines the flux component (\(I_d\)), incorporating field weakening effects.
- **Peak Current Draw**: With the input parameters, the calculator computes the peak current draw (\(I_{total}\)), providing essential insights into the system's maximum electrical demand.
[**Try the Peak Current Draw Calculator**](https://lekrsu.github.io/shfw-walkthrough/logic/index.html) - A user-friendly tool designed for clarity and efficiency in calculating electrical parameters.
#### [Ninebot G30](#ninebot-g30)
To achieve the top speed for Ninebot G30, follow these configurations:
@ -85,7 +94,7 @@ For Xiaomi Essential Lite, use these configurations:
2. Go to the field weakening tab and:
- Enable field weakening for sport mode.
- Configure as follows: 15 km/h, 3A, 1000.
- Configure as follows: 17 km/h, 5A, 1000.
The rest of the configurations are up to you. Feel free to explore and set up profiles according to your preferences.If it isn't reaching the performance you expected then consider fine-tuning it to your liking.

33
logic/index.html Normal file
View File

@ -0,0 +1,33 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Peak Current Draw Calculator</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<div class="container">
<h1>Peak Current Draw Calculator</h1>
<div class="input-section">
<!-- Iq (Torque component) -->
<label for="torqueAmps">Torque amps (I<sub>q</sub>) in A:</label>
<input type="number" id="torqueAmps">
</div>
<div class="input-section">
<!-- Inputs for calculating Id (Flux component) -->
<label for="initialFlux">Initial flux (I<sub>d</sub>, base) in A:</label>
<input type="number" id="initialFlux">
<label for="variableFlux">Variable flux (I<sub>d</sub>, variable) in mAh:</label>
<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>
<input type="number" id="activationSpeed">
</div>
<button onclick="calculatePeakCurrentDraw()">Calculate Peak Current Draw (I<sub>total</sub>)</button>
<div id="result"></div>
</div>
<script src="script.js"></script>
</body>
</html>

19
logic/script.js Normal file
View File

@ -0,0 +1,19 @@
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 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));
// Calculating Peak Current Draw (I_total) using Pythagorean theorem
const ITotal = Math.sqrt(Math.pow(torqueAmps, 2) + Math.pow(fieldWeakeningAmps, 2)).toFixed(2);
// Displaying the result
document.getElementById('result').innerHTML = `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`;
}

42
logic/style.css Normal file
View File

@ -0,0 +1,42 @@
body {
font-family: Arial, sans-serif;
background-color: #121212;
color: #e0e0e0;
display: flex;
justify-content: center;
align-items: center;
min-height: 100vh;
margin: 0;
}
.container {
max-width: 600px;
width: 100%;
padding: 20px;
}
.input-section label {
display: block;
margin: 10px 0 5px;
}
.input-section input {
width: 100%;
padding: 10px;
margin-bottom: 20px;
background-color: #333;
border: none;
color: #fff;
}
button {
padding: 10px 20px;
background-color: #333;
color: #fff;
border: none;
cursor: pointer;
}
#result {
margin-top: 20px;
}