Speeduino
Loading...
Searching...
No Matches
Macros | Functions | Variables
speeduino.ino File Reference
#include <stdint.h>
#include "globals.h"
#include "scheduler.h"
#include "comms.h"
#include "comms_legacy.h"
#include "comms_secondary.h"
#include "maths.h"
#include "corrections.h"
#include "timers.h"
#include "decoders.h"
#include "idle.h"
#include "auxiliaries.h"
#include "sensors.h"
#include "storage.h"
#include "crankMaths.h"
#include "init.h"
#include "utilities.h"
#include "engineProtection.h"
#include "scheduledIO.h"
#include "secondaryTables.h"
#include "comms_CAN.h"
#include "SD_logger.h"
#include "schedule_calcs.h"
#include "load_source.h"
#include "board_definition.h"
#include <RTC_LIB_H>
#include "units.h"
#include "fuel_calcs.h"

Macros

#define CRANK_RUN_HYSTER   15
 

Functions

void calculateIgnitionAngles (uint16_t dwellAngle)
 
void checkLaunchAndFlatShift ()
 
void setup (void)
 
static uint16_t applyFuelTrimToPW (trimTable3d *pTrimTable, uint16_t fuelLoad, int16_t RPM, uint16_t currentPW)
 
static uint8_t getVE1 (void)
 
static int8_t getAdvance1 (void)
 
void loop (void)
 

Variables

uint8_t ignitionChannelsOn
 
uint8_t ignitionChannelsPending = 0
 
uint8_t fuelChannelsOn
 
uint32_t rollingCutLastRev = 0
 
uint32_t revLimitAllowedEndTime = 0
 
static table2D_u8_u16_4 injectorAngleTableconfigPage2
 
static table2D_u8_u8_8 rotarySplitTableconfigPage10
 
static table2D_i8_u8_4 rollingCutTableconfigPage15
 
static table2D_u8_u8_10 idleTargetTableconfigPage6
 

Detailed Description

Speeduino initialisation and main loop.

Macro Definition Documentation

◆ CRANK_RUN_HYSTER

#define CRANK_RUN_HYSTER   15

Function Documentation

◆ applyFuelTrimToPW()

static uint16_t applyFuelTrimToPW ( trimTable3d pTrimTable,
uint16_t  fuelLoad,
int16_t  RPM,
uint16_t  currentPW 
)
inlinestatic
Here is the call graph for this function:
Here is the caller graph for this function:

◆ calculateIgnitionAngles()

void calculateIgnitionAngles ( uint16_t  dwellAngle)

Calculate the Ignition angles for all cylinders (based on config2::nCylinders). both start and end angles are calculated for each channel. Also the mode of ignition firing - wasted spark vs. dedicated spark per cyl. - is considered here.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ checkLaunchAndFlatShift()

void checkLaunchAndFlatShift ( )
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getAdvance1()

static int8_t getAdvance1 ( void  )
inlinestatic

Lookup the ignition advance from 3D ignition table. The values used to look this up will be RPM and whatever load source the user has configured.

Returns
byte The current target advance value in degrees
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getVE1()

static uint8_t getVE1 ( void  )
inlinestatic

Lookup the current VE value from the primary 3D fuel map. The Y axis value used for this lookup varies based on the fuel algorithm selected (speed density, alpha-n etc).

Returns
byte The current VE value
Here is the call graph for this function:
Here is the caller graph for this function:

◆ loop()

void loop ( void  )

Speeduino main loop.

Main loop chores (roughly in the order that they are performed):

  • Check if serial comms or tooth logging are in progress (send or receive, prioritise communication)
  • Record loop timing vars
  • Check tooth time, update statuses (currentStatus) variables
  • Read sensors
  • get VE for fuel calcs and spark advance for ignition
  • Check crank/cam/tooth/timing sync (skip remaining ops if out-of-sync)
  • execute doCrankSpeedCalcs()

single byte variable LOOP_TIMER plays a big part here as:

  • it contains expire-bits for interval based frequency driven events (e.g. 15Hz, 4Hz, 1Hz)
  • Can be tested for certain frequency interval being expired by (eg) BIT_CHECK(LOOP_TIMER, BIT_TIMER_15HZ)
Here is the call graph for this function:

◆ setup()

void setup ( void  )
Here is the call graph for this function:

Variable Documentation

◆ configPage10

table2D_u8_u8_8 rotarySplitTable& configPage10
static

◆ configPage15

table2D_i8_u8_4 rollingCutTable& configPage15
static

◆ configPage2

table2D_u8_u16_4 injectorAngleTable& configPage2
static

◆ configPage6

table2D_u8_u8_10 idleTargetTable& configPage6
static

◆ fuelChannelsOn

uint8_t fuelChannelsOn

The current state of the fuel system (on or off)

◆ ignitionChannelsOn

uint8_t ignitionChannelsOn

The current state of the ignition system (on or off)

◆ ignitionChannelsPending

uint8_t ignitionChannelsPending = 0

Any ignition channels that are pending injections before they are resumed

◆ revLimitAllowedEndTime

uint32_t revLimitAllowedEndTime = 0

◆ rollingCutLastRev

uint32_t rollingCutLastRev = 0

Tracks whether we're on the same or a different rev for the rolling cut