![]() |
Speeduino
|
#include "globals.h"#include "scheduler.h"#include "scheduledIO.h"#include "timers.h"#include "schedule_calcs.h"#include "preprocessor.h"#include "units.h"Macros | |
| #define | DWELL_AVERAGE_ALPHA 30 |
| #define | DWELL_AVERAGE(input) LOW_PASS_FILTER((input), DWELL_AVERAGE_ALPHA, currentStatus.actualDwell) |
Injector and Ignition (on/off) scheduling (functions). There is usually 8 functions for cylinders 1-8 with same naming pattern.
Structures FuelSchedule and Schedule describe (from scheduler.h) describe the scheduling info for Fuel and Ignition respectively. They contain duration, current activity status, start timing, end timing, callbacks to carry out action, etc.
For Injection:
For Ignition (has more complex schedule setup):
| #define DWELL_AVERAGE | ( | input | ) | LOW_PASS_FILTER((input), DWELL_AVERAGE_ALPHA, currentStatus.actualDwell) |
| #define DWELL_AVERAGE_ALPHA 30 |
Perform the injector priming pulses. Set these to run at an arbitrary time in the future (100us). The prime pulse value is in ms*10, so need to multiple by 100 to get to uS














| void fuelSchedule1Interrupt | ( | ) |
fuelSchedule*Interrupt (All 8 ISR functions below) get called (as timed interrupts) when either the start time or the duration time are reached. This calls the relevant callback function (startCallback or endCallback) depending on the status (PENDING => Needs to run, RUNNING => Needs to stop) of the schedule. The status of schedule is managed here based on startCallback /endCallback function called:

| void fuelSchedule2Interrupt | ( | ) |

| void fuelSchedule3Interrupt | ( | ) |

| void fuelSchedule4Interrupt | ( | ) |

|
inlinestatic |


|
inlinestatic |


< The number of crank degrees until cylinder 1 is at TDC (This is obviously 0 for virtually ALL engines, but there's some weird ones)
< The number of crank degrees until cylinder 2 (and 5/6/7/8) is at TDC
< The number of crank degrees until cylinder 3 (and 5/6/7/8) is at TDC
< The number of crank degrees until cylinder 4 (and 5/6/7/8) is at TDC


< The number of crank degrees until cylinder 1 is at TDC (This is obviously 0 for virtually ALL engines, but there's some weird ones)
< The number of crank degrees until cylinder 2 (and 5/6/7/8) is at TDC
< The number of crank degrees until cylinder 2 (and 5/6/7/8) is at TDC
< The number of crank degrees until cylinder 2 (and 5/6/7/8) is at TDC




|
inlinestatic |

|
inlinestatic |



| void setCallbacks | ( | Schedule & | schedule, |
| voidVoidCallback | pStartCallback, | ||
| voidVoidCallback | pEndCallback | ||
| ) |
Set the schedule action start & end callbacks.
| schedule | Schedule to modify |
| pStartCallback | Start callback |
| pEndCallback | End callback |


| void setSchedule | ( | Schedule & | schedule, |
| uint32_t | delay, | ||
| uint16_t | duration, | ||
| bool | allowQueuedSchedule | ||
| ) |
Set the schedule action to run for a certain duration in the future.
| schedule | Schedule to modify |
| delay | Delay until the action starts (µS) |
| duration | Action duration (µS) |
| allowQueuedSchedule | true to allow a schedule to be queued up if one is currently running; false otherwise |




|
inlinestatic |






|
static |
| FuelSchedule fuelSchedule1(FUEL1_COUNTER, FUEL1_COMPARE) | ( | FUEL1_COUNTER | , |
| FUEL1_COMPARE | |||
| ) |
| FuelSchedule fuelSchedule2(FUEL2_COUNTER, FUEL2_COMPARE) | ( | FUEL2_COUNTER | , |
| FUEL2_COMPARE | |||
| ) |
| FuelSchedule fuelSchedule3(FUEL3_COUNTER, FUEL3_COMPARE) | ( | FUEL3_COUNTER | , |
| FUEL3_COMPARE | |||
| ) |
| FuelSchedule fuelSchedule4(FUEL4_COUNTER, FUEL4_COMPARE) | ( | FUEL4_COUNTER | , |
| FUEL4_COMPARE | |||
| ) |
| IgnitionSchedule ignitionSchedule1(IGN1_COUNTER, IGN1_COMPARE) | ( | IGN1_COUNTER | , |
| IGN1_COMPARE | |||
| ) |
| IgnitionSchedule ignitionSchedule2(IGN2_COUNTER, IGN2_COMPARE) | ( | IGN2_COUNTER | , |
| IGN2_COMPARE | |||
| ) |
| IgnitionSchedule ignitionSchedule3(IGN3_COUNTER, IGN3_COMPARE) | ( | IGN3_COUNTER | , |
| IGN3_COMPARE | |||
| ) |
| IgnitionSchedule ignitionSchedule4(IGN4_COUNTER, IGN4_COMPARE) | ( | IGN4_COUNTER | , |
| IGN4_COMPARE | |||
| ) |
| IgnitionSchedule ignitionSchedule5(IGN5_COUNTER, IGN5_COMPARE) | ( | IGN5_COUNTER | , |
| IGN5_COMPARE | |||
| ) |