Speeduino
Loading...
Searching...
No Matches
Macros | Functions
crankMaths.h File Reference
#include "maths.h"
#include "globals.h"
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define MICROS_PER_DEG_1_RPM   INT32_C(166667)
 At 1 RPM, each degree of angular rotation takes this many microseconds.
 
#define MAX_RPM   INT16_C(18000)
 The maximum rpm that the ECU will attempt to run at.
 
#define MIN_RPM   ((MICROS_PER_DEG_1_RPM/(UINT16_MAX/16UL))+1UL)
 Absolute minimum RPM that the crank math (& therefore all of Speeduino) can be used with.
 

Functions

static int16_t ignitionLimits (int16_t angle)
 Makes one pass at nudging the angle to within [0,CRANK_ANGLE_MAX_IGN].
 
static int16_t injectorLimits (int16_t angle)
 Makes one pass at nudging the angle to within [0,CRANK_ANGLE_MAX_INJ].
 
void setAngleConverterRevolutionTime (uint32_t revolutionTime)
 Set the revolution time, from which some of the degree<-->angle conversions are derived.
 
Converts angular degrees to the time interval that amount of rotation

will take at current RPM.

Based on angle of [0,720] and min/max RPM, result ranges from 9 (MAX_RPM, 1 deg) to 2926828 (MIN_RPM, 720 deg)

Parameters
angleAngle in degrees
Returns
Time interval in uS
uint32_t angleToTimeMicroSecPerDegree (uint16_t angle)
 
Converts a time interval in microsecods to the equivalent degrees of angular (crank)

rotation at current RPM.

Inverse of angleToTimeMicroSecPerDegree

Parameters
timeTime interval in uS
Returns
Angle in degrees
uint16_t timeToAngleDegPerMicroSec (uint32_t time)
 

Macro Definition Documentation

◆ MAX_RPM

#define MAX_RPM   INT16_C(18000)

The maximum rpm that the ECU will attempt to run at.

It is NOT related to the rev limiter, but is instead dictates how fast certain operations will be allowed to run. Lower number gives better performance

◆ MICROS_PER_DEG_1_RPM

#define MICROS_PER_DEG_1_RPM   INT32_C(166667)

At 1 RPM, each degree of angular rotation takes this many microseconds.

◆ MIN_RPM

#define MIN_RPM   ((MICROS_PER_DEG_1_RPM/(UINT16_MAX/16UL))+1UL)

Absolute minimum RPM that the crank math (& therefore all of Speeduino) can be used with.

This is dictated by the use of uint16_t as the base type for storing angle<->time conversion factor (degreesPerMicro)

Function Documentation

◆ angleToTimeMicroSecPerDegree()

uint32_t angleToTimeMicroSecPerDegree ( uint16_t  angle)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ignitionLimits()

static int16_t ignitionLimits ( int16_t  angle)
inlinestatic

Makes one pass at nudging the angle to within [0,CRANK_ANGLE_MAX_IGN].

Parameters
angleA crank angle in degrees
Returns
int16_t
Here is the call graph for this function:
Here is the caller graph for this function:

◆ injectorLimits()

static int16_t injectorLimits ( int16_t  angle)
inlinestatic

Makes one pass at nudging the angle to within [0,CRANK_ANGLE_MAX_INJ].

Parameters
angleA crank angle in degrees
Returns
int16_t
Here is the call graph for this function:
Here is the caller graph for this function:

◆ setAngleConverterRevolutionTime()

void setAngleConverterRevolutionTime ( uint32_t  revolutionTime)

Set the revolution time, from which some of the degree<-->angle conversions are derived.

Parameters
revolutionTimeThe crank revolution time.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ timeToAngleDegPerMicroSec()

uint16_t timeToAngleDegPerMicroSec ( uint32_t  time)
Here is the call graph for this function:
Here is the caller graph for this function: