fome-fw/firmware/controllers/math/engine_math.h

72 lines
2.5 KiB
C
Raw Normal View History

2015-07-10 06:01:56 -07:00
/**
* @file engine_math.h
*
* @date Jul 13, 2013
2020-01-13 18:57:43 -08:00
* @author Andrey Belomutskiy, (c) 2012-2020
2015-07-10 06:01:56 -07:00
*/
2019-07-08 15:02:21 -07:00
#pragma once
2015-07-10 06:01:56 -07:00
#include "engine_configuration.h"
#include "trigger_structure.h"
#include "table_helper.h"
#include "engine.h"
void setAlgorithm(engine_load_mode_e algo DECLARE_CONFIG_PARAMETER_SUFFIX);
2015-07-10 06:01:56 -07:00
2018-09-10 19:10:55 -07:00
#define assertEngineReference() efiAssertVoid(CUSTOM_ENGINE_REF, engine != NULL, "engine is NULL")
2018-02-03 07:48:35 -08:00
void setFlatInjectorLag(float value DECLARE_CONFIG_PARAMETER_SUFFIX);
2016-06-30 21:02:20 -07:00
#define fixAngle(angle, msg, code) fixAngle2(angle, msg, code, ENGINE(engineCycle))
2016-06-30 21:02:20 -07:00
2015-07-10 06:01:56 -07:00
/**
* @return time needed to rotate crankshaft by one degree, in milliseconds.
* @deprecated use at least Us, maybe even Nt
*/
#define getOneDegreeTimeMs(rpm) (1000.0f * 60 / 360 / (rpm))
/**
* @return float, time needed to rotate crankshaft by one degree, in microseconds.
* See also engine->rpmCalculator.oneDegreeUs
*/
#define getOneDegreeTimeUs(rpm) (1000000.0f * 60 / 360 / (rpm))
/**
* @return float, time needed to rotate crankshaft by one degree, in native clicks.
*/
#define getOneDegreeTimeNt(rpm) (US2NT(1000000) * 60.0f / 360 / (rpm))
2015-09-07 06:03:24 -07:00
floatms_t getCrankshaftRevolutionTimeMs(int rpm);
2017-05-15 20:33:22 -07:00
floatms_t getEngineCycleDuration(int rpm DECLARE_ENGINE_PARAMETER_SUFFIX);
2015-07-10 06:01:56 -07:00
float getFuelingLoad(DECLARE_ENGINE_PARAMETER_SIGNATURE);
float getIgnitionLoad(DECLARE_ENGINE_PARAMETER_SIGNATURE);
// getEngineLoadT is deprecated - please use one of the above functions, getFuelingLoad or getIgnitionMode
2017-05-15 20:33:22 -07:00
float getEngineLoadT(DECLARE_ENGINE_PARAMETER_SIGNATURE);
2015-07-10 06:01:56 -07:00
2017-05-15 20:33:22 -07:00
floatms_t getSparkDwell(int rpm DECLARE_ENGINE_PARAMETER_SUFFIX);
2015-07-10 06:01:56 -07:00
ignition_mode_e getCurrentIgnitionMode(DECLARE_ENGINE_PARAMETER_SIGNATURE);
/**
* This lightweight method is invoked in case of a configuration change or initialization.
* But also it's used for "Spinning-up to Cranking" transition.
*/
void prepareIgnitionPinIndices(ignition_mode_e ignitionMode DECLARE_ENGINE_PARAMETER_SUFFIX);
2017-05-15 20:33:22 -07:00
int getCylinderId(int index DECLARE_ENGINE_PARAMETER_SUFFIX);
2015-07-10 06:01:56 -07:00
void setTimingRpmBin(float from, float to DECLARE_CONFIG_PARAMETER_SUFFIX);
void setTimingLoadBin(float from, float to DECLARE_CONFIG_PARAMETER_SUFFIX);
2015-07-10 06:01:56 -07:00
2019-11-05 20:17:44 -08:00
void setSingleCoilDwell(DECLARE_CONFIG_PARAMETER_SIGNATURE);
2015-07-10 06:01:56 -07:00
2018-10-13 06:24:41 -07:00
// we combine trigger-defined triggerShape.tdcPosition with user-defined CONFIG(globalTriggerAngleOffset)
// expectation is that for well-known triggers CONFIG(globalTriggerAngleOffset) would usually be zero
// while for toothed wheels user would have to provide a value
2015-07-10 06:01:56 -07:00
#define tdcPosition() \
(TRIGGER_WAVEFORM(tdcPosition) + CONFIG(globalTriggerAngleOffset))