Speeduino
|
#include <stdint.h>
#include "globals.h"
#include "speeduino.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 <RTC_LIB_H>
#include <BOARD_H>
Functions | |
void | setup (void) |
uint16_t | applyFuelTrimToPW (trimTable3d *pTrimTable, int16_t fuelLoad, int16_t RPM, uint16_t currentPW) |
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) |
void | calculateIgnitionAngles (uint16_t dwellAngle) |
uint16_t | calculatePWLimit () |
void | calculateStaging (uint32_t pwLimit) |
void | checkLaunchAndFlatShift () |
Speeduino initialisation and main loop.
|
inline |
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.
uint16_t calculatePWLimit | ( | ) |
void checkLaunchAndFlatShift | ( | ) |
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.
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).
Speeduino main loop.
Main loop chores (roughly in the order that they are performed):
single byte variable LOOP_TIMER plays a big part here as:
This function calculates the required pulsewidth time (in us) given the current system state.
REQ_FUEL | The required fuel value in uS, as calculated by TunerStudio |
VE | Lookup from the main fuel table. This can either have been MAP or TPS based, depending on the algorithm used |
MAP | In 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) |
corrections | Sum of Enrichment factors (Cold start, acceleration). This is a multiplication factor (Eg to add 10%, this should be 110) |
injOpen | Injector opening time. The time the injector take to open minus the time it takes to close (Both in uS) |
uint8_t fuelChannelsOn |
The current state of the fuel system (on or off)
uint8_t ignitionChannelsOn |
The current state of the ignition system (on or off)
uint8_t ignitionChannelsPending = 0 |
Any ignition channels that are pending injections before they are resumed
uint16_t inj_opentime_uS = 0 |
The injector opening time. This is set within Tuner Studio, but stored here in uS rather than mS
uint16_t req_fuel_uS = 0 |
The required fuel variable (As calculated by TunerStudio) in uS
uint32_t rollingCutLastRev = 0 |
Tracks whether we're on the same or a different rev for the rolling cut
uint16_t staged_req_fuel_mult_pri = 0 |
uint16_t staged_req_fuel_mult_sec = 0 |