Industrial Calculator Engine
Relevant source files
The following files were used as context for generating this wiki page:
The Industrial Calculator Engine is a specialized module designed to perform complex CNC (Computer Numerical Control) machining calculations. It provides essential tools for technical staff to determine critical parameters such as cutting speeds, feed rates, and material removal rates for milling and drilling operations.
This engine is integrated into the ELMEC Mobile App to assist technicians in the field, ensuring that machining processes are optimized for efficiency and tool longevity. It supports both metric and imperial measurement systems, providing a versatile toolset for various industrial environments. Sources: README.md:16, utils/calculatorUtils.ts:1-5, VALIDACION-COMPLETA.md:92-96
Architecture and Components
The engine is built using a functional approach where mathematical logic is decoupled from the UI components. It relies on a set of utility functions for calculations and a reactive state management system to handle user inputs and real-time updates.
Calculation Logic Flow
The following diagram illustrates how user input triggers a chain of calculations to update dependent machining parameters.
The calculation engine performs these updates using specific mathematical formulas derived from machining standards. Sources: utils/calculatorUtils.ts:1-90, components/calculator/CalculatorView.tsx:103-180
Core Components
| Component | Description |
|---|---|
calculatorUtils.ts | Contains pure mathematical functions for CNC calculations (Vc, N, fz, vf, tc, Q). |
CalculatorView.tsx | The primary UI component that renders input fields and the custom numerical keyboard. |
calculatorSlice.ts | (Inferred from usage) Manages the global state for the calculator, including current values and measurement units. |
Theme Colors | Provides dynamic styling based on the application's light or dark mode. |
Sources: utils/calculatorUtils.ts:153-220, components/calculator/CalculatorView.tsx:32-55
Mathematical Formulas
The engine implements standardized industrial formulas for machining. These are categorized into milling and drilling operations.
Milling and General Formulas
- Cutting Speed (Vc): $Vc = \frac{\pi \times D \times N}{1000}$
- Rotation Speed (N): $N = \frac{Vc \times 1000}{\pi \times D}$
- Feed per Tooth (fz): $fz = \frac{fn}{Z}$
- Feed Velocity (vf): $vf = fn \times N$
- Material Removal Rate (Q): $Q = \frac{ap \times ae \times vf}{1000}$
Sources: utils/calculatorUtils.ts:11-85
Drilling Formulas
- Material Removal Rate (Q Barrenado): $Q = \frac{(\pi \times D^2 / 4) \times vf}{1000}$
- Cutting Time (tc Barrenado): $tc = \frac{pb \times nb}{vf}$
Sources: utils/calculatorUtils.ts:93-112
Data Parameters Summary
The parameters used by the engine are described in the table below:
| Field | Label | Metric Unit | Imperial Unit |
|---|---|---|---|
D | Diameter | mm | in |
Z | Number of Flutes | - | - |
N | Rotation Speed | rpm | rpm |
Vc | Cutting Speed | m/min | ft/min |
fz | Feed per tooth | mm/rev | in/rev |
vf | Feed velocity | mm/min | in/min |
ap | Axial Depth | mm | in |
ae | Radial Depth | mm | in |
Q | Removal Rate | cm³/min | in³/min |
Sources: utils/calculatorUtils.ts:140-160, utils/calculatorUtils.ts:182-205
Data Interaction and Validation
The engine includes robust validation to ensure technical safety and accuracy. Input values are checked against typical machining ranges to prevent erroneous data entry.
Validation Sequence
The UI triggers a validation check every time a field is modified.
Validation limits include:
- Diameter (D): 0.1 to 500 mm.
- RPM (N): 1 to 50,000.
- Cutting Speed (Vc): 1 to 2,000 m/min.
- Feed per tooth (fz): 0.001 to 10 mm/tooth.
Sources: utils/calculatorUtils.ts:223-255, utils/logger.ts:145-155
UI Update Logic
The performCalculations function in the view layer uses a switch statement based on the editable field index to decide which dependent variables need updating. For example, changing the Diameter (editable === 1) triggers a recalculation of Vc if N is present, or N if Vc is present. Sources: components/calculator/CalculatorView.tsx:112-160
// Example from performCalculations logic
case 1: // Diámetro (D)
if (N > 0) {
const newVc = calcVc(D, N);
dispatch(setField({ field: 'Vc', value: formatNumber(newVc, 0) }));
}
if (Vc > 0 && D > 0) {
const newN = calcN(D, Vc);
dispatch(setField({ field: 'N', value: formatNumber(newN, 0) }));
}
break;
Sources: components/calculator/CalculatorView.tsx:127-137
Conclusion
The Industrial Calculator Engine serves as a critical utility within the ELMEC platform, bridging the gap between field technicians and complex machining mathematics. By centralizing calculation logic and enforcing strict validation ranges, it ensures high precision in CNC parameter estimation, contributing to the overall stability and professional scope of the mobile application. Sources: VALIDACION-COMPLETA.md:145-150, README.md:28-30