Speeduino
Loading...
Searching...
No Matches
Macros | Functions | Variables
speeduino.h File Reference

Speeduino main file containing initial setup and system loop functions. More...

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define CRANK_RUN_HYSTER   15
 

Functions

void setup (void)
 
void loop (void)
 
uint16_t PW (int REQ_FUEL, byte VE, long MAP, uint16_t corrections, int injOpen)
 This function calculates the required pulsewidth time (in us) given the current system state.
 
byte getVE1 (void)
 
byte getAdvance1 (void)
 
uint16_t calculatePWLimit ()
 
void calculateStaging (uint32_t)
 
void calculateIgnitionAngles (uint16_t dwellAngle)
 
void checkLaunchAndFlatShift ()
 

Variables

uint16_t req_fuel_uS
 
uint16_t inj_opentime_uS
 
Staging

These values are a percentage of the total (Combined) req_fuel value that would be required for each injector channel to deliver that much fuel.

Eg:

  • Pri injectors are 250cc
  • Sec injectors are 500cc
  • Total injector capacity = 750cc
  • staged_req_fuel_mult_pri = 300% (The primary injectors would have to run 3x the overall PW in order to be the equivalent of the full 750cc capacity
  • staged_req_fuel_mult_sec = 150% (The secondary injectors would have to run 1.5x the overall PW in order to be the equivalent of the full 750cc capacity
uint16_t staged_req_fuel_mult_pri
 
uint16_t staged_req_fuel_mult_sec
 

Detailed Description

Speeduino main file containing initial setup and system loop functions.

Author
Josh Stewart

This file contains the main system loop of the Speeduino core and thus much of the logic of the fuel and ignition algorithms is contained within this It is where calls to all the auxiliary control systems, sensor reads, comms etc are made

It also contains the setup() function that is called by the bootloader on system startup

Macro Definition Documentation

◆ CRANK_RUN_HYSTER

#define CRANK_RUN_HYSTER   15

Function Documentation

◆ 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:

◆ calculatePWLimit()

uint16_t calculatePWLimit ( )
Here is the call graph for this function:
Here is the caller graph for this function:

◆ calculateStaging()

void calculateStaging ( uint32_t  pwLimit)
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()

byte getAdvance1 ( void  )

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()

byte getVE1 ( void  )

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:

◆ PW()

uint16_t PW ( int  REQ_FUEL,
byte  VE,
long  MAP,
uint16_t  corrections,
int  injOpen 
)

This function calculates the required pulsewidth time (in us) given the current system state.

Parameters
REQ_FUELThe required fuel value in uS, as calculated by TunerStudio
VELookup from the main fuel table. This can either have been MAP or TPS based, depending on the algorithm used
MAPIn KPa, read from the sensor (This is used when performing a multiply of the map only. It is applicable in both Speed density and Alpha-N)
correctionsSum of Enrichment factors (Cold start, acceleration). This is a multiplication factor (Eg to add 10%, this should be 110)
injOpenInjector opening time. The time the injector take to open minus the time it takes to close (Both in uS)
Returns
uint16_t The injector pulse width in uS
Here is the call graph for this function:
Here is the caller graph for this function:

◆ setup()

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

Variable Documentation

◆ inj_opentime_uS

uint16_t inj_opentime_uS
extern

The injector opening time. This is set within Tuner Studio, but stored here in uS rather than mS

◆ req_fuel_uS

uint16_t req_fuel_uS
extern

The required fuel variable (As calculated by TunerStudio) in uS

◆ staged_req_fuel_mult_pri

uint16_t staged_req_fuel_mult_pri
extern

◆ staged_req_fuel_mult_sec

uint16_t staged_req_fuel_mult_sec
extern