2015-07-10 06:01:56 -07:00
|
|
|
/**
|
|
|
|
* @file engine_math.h
|
|
|
|
*
|
|
|
|
* @date Jul 13, 2013
|
2017-01-03 03:05:22 -08:00
|
|
|
* @author Andrey Belomutskiy, (c) 2012-2017
|
2015-07-10 06:01:56 -07:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef ENGINE_MATH_H_
|
|
|
|
#define ENGINE_MATH_H_
|
|
|
|
|
|
|
|
#include "engine_configuration.h"
|
|
|
|
|
|
|
|
#include "trigger_structure.h"
|
|
|
|
#include "table_helper.h"
|
|
|
|
#include "engine.h"
|
|
|
|
|
2019-01-10 16:25:07 -08:00
|
|
|
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
|
|
|
|
2019-01-10 16:25:07 -08:00
|
|
|
void setFlatInjectorLag(float value DECLARE_CONFIG_PARAMETER_SUFFIX);
|
2016-06-30 21:02:20 -07:00
|
|
|
|
2018-12-25 19:47:29 -08: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
|
|
|
|
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
|
|
|
|
2019-01-20 08:33:40 -08:00
|
|
|
ignition_mode_e getCurrentIgnitionMode(DECLARE_ENGINE_PARAMETER_SIGNATURE);
|
2018-03-10 17:58:51 -08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* 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
|
|
|
|
2019-01-10 16:25:07 -08:00
|
|
|
void setFuelRpmBin(float from, float to DECLARE_CONFIG_PARAMETER_SUFFIX);
|
|
|
|
void setFuelLoadBin(float from, float to DECLARE_CONFIG_PARAMETER_SUFFIX);
|
|
|
|
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
|
|
|
|
|
|
|
void setSingleCoilDwell(engine_configuration_s *engineConfiguration);
|
|
|
|
|
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() \
|
2017-03-01 19:18:25 -08:00
|
|
|
(ENGINE(triggerCentral.triggerShape.tdcPosition) + CONFIG(globalTriggerAngleOffset))
|
2015-07-10 06:01:56 -07:00
|
|
|
|
|
|
|
#endif /* ENGINE_MATH_H_ */
|