rusEFI
The most advanced open source ECU
Loading...
Searching...
No Matches
Functions
harley.h File Reference

Functions

void setHarley ()
 

Function Documentation

◆ setHarley()

void setHarley ( )

HARLEY set engine_type 6

Definition at line 16 of file harley.cpp.

16 {
19 engineConfiguration->ignitionMode = IM_INDIVIDUAL_COILS;
20 engineConfiguration->injectionMode = IM_SEQUENTIAL;
21 for (size_t i = engineConfiguration->cylindersCount;i < MAX_CYLINDER_COUNT;i++) {
24 }
25
26 strcpy(engineConfiguration->scriptSettingName[0], "compReleaseRpm");
28 strcpy(engineConfiguration->scriptSettingName[1], "compReleaseDur");
30 engineConfiguration->afr.hwChannel = EFI_ADC_NONE;
32
33 // total 45 degree odd fire, split across two cylinders mostly for fun
34 engineConfiguration->timing_offset_cylinder[0] = -HARLEY_V_TWIN / 2;
35 engineConfiguration->timing_offset_cylinder[1] = +HARLEY_V_TWIN / 2;
36
37 // work-around for https://github.com/rusefi/rusefi/issues/5894 todo: fix it!
40
46 engineConfiguration->triggerGapOverrideFrom[1] = 0.05; // this one is custom
48 engineConfiguration->triggerGapOverrideFrom[2] = 1.850; // this one is custom
50
51 engineConfiguration->vvtMode[0] = VVT_MAP_V_TWIN;
52
55
56 setCustomMap(/*lowValue*/ 20, /*mapLowValueVoltage*/ 0.79, /*highValue*/ 101.3, /*mapHighValueVoltage*/ 4);
57
58#if HW_PROTEUS && EFI_PROD_CODE
59 engineConfiguration->acrPin = Gpio::PROTEUS_IGN_8;
60 engineConfiguration->acrPin2 = Gpio::PROTEUS_IGN_9;
61
62 engineConfiguration->triggerInputPins[0] = PROTEUS_VR_1;
63 // for now we need non wired camInput to keep TS field enable/disable logic happy
64#if EFI_PROD_CODE
65 engineConfiguration->camInputs[0] = PROTEUS_DIGITAL_6;
66#else
68#endif
69
70 engineConfiguration->luaOutputPins[0] = Gpio::PROTEUS_LS_12;
71
72 setTPS1Inputs(PROTEUS_IN_TPS, PROTEUS_IN_TPS1_2);
73
74 setPPSInputs(PROTEUS_IN_ANALOG_VOLT_4, PROTEUS_IN_ANALOG_VOLT_5);
75
76
77 strncpy(config->luaScript, R"(
78--outputIndex = 0
79--startPwm(outputIndex, 100, 0)
80
81rpmLimitSetting = findSetting("compReleaseRpm", 300)
82compReleaseDulationLimit = findSetting("compReleaseDur", 6000)
83
84every200msTimer = Timer.new();
85everySecondTimer = Timer.new();
86every50msTimer = Timer.new();
87offCounter = 0
88-- cranking!
89packet542 = {0x20, 0x82, 0x81, 0xd9, 0x00, 0x00, 0x00, 0x00}
90packet543 = {0x13, 0x57, 0x13, 0x45, 0x00, 0xe8, 0x00, 0x00}
91packet541 = {0x00, 0x00, 0x00, 0x00, 0x00, 0x45, 0x00, 0xFF}
92
93-- every 200ms
94packet540 = {0x00, 0x00, 0x5a, 0x4c, 0xff, 0x00, 0x00, 0x00}
95
96-- every 1000ms
97packet502 = {0x01}
98packet546 = {0x35, 0x48, 0x44, 0x31, 0x46, 0x48}
99packet547 = {0x50, 0x41, 0x31, 0x4b, 0x42, 0x36}
100packet548 = {0x33, 0x34, 0x38, 0x32, 0x32, 0x00}
101
102counter543 = 0;
103setTickRate(66);
104
105canRxAdd(0x570)
106canRxAdd(0x500)
107
108function onCanRx(bus, id, dlc, data)
109 --print('got CAN id=' .. id .. ' dlc=' .. dlc)
110
111 if id == 0x500 then --Check can state of BCM
112 canState = data[1]
113 if canState == 01 then
114 packet502[1] = 0x01
115 else
116 packet502[1] = 0x00
117 end
118 if id == 0x570 then
119 curState = data[1]
120 if curState == 06 then -- Cranking TODO: MUST ONLY DO THIS ON RPM TILL STARt
121 packet542[2] = 0x82
122 end
123 if curState == 04 then -- Kill off
124 packet542[2] = 0x82
125 end
126 if curState == 01 then -- Kill
127 packet542[2] = 0xA2
128 end
129 end
130 end
131end
132
133
134function onTick()
135
136 if packet502[1] == 01 then
137 offCounter = 0
138 counter543 = (counter543 + 1) % 64
139 packet543[7] = 64 + counter543
140 packet543[8] = crc8_j1850(packet543, 7)
141 APP = getSensor("AcceleratorPedal")
142 if APP == nil then
143 packet543[5] = 0
144 else
145 packet543[5] = APP *2
146 end
147
148 txCan(1, 0x543, 0, packet543)
149 txCan(1, 0x541, 0, packet541)
150
151 if every200msTimer:getElapsedSeconds() > 0.2 then
152 every200msTimer:reset();
153 txCan(1, 0x540, 0, packet540)
154 end
155
156 if every50msTimer:getElapsedSeconds() > 0.05 then
157 every50msTimer:reset();
158 txCan(1, 0x542, 0, packet542)
159 end
160
161 if everySecondTimer:getElapsedSeconds() > 1 then
162 everySecondTimer:reset();
163 txCan(1, 0x502, 0, packet502)
164 txCan(1, 0x546, 0, packet546)
165 txCan(1, 0x547, 0, packet547)
166 txCan(1, 0x548, 0, packet548)
167 end
168
169
170 rpm = getSensor("RPM")
171-- handle nil RPM, todo: change firmware to avoid nil RPM
172 rpm = (rpm == nil and 0 or rpm)
173 --print('Rpm ' .. rpm)
174 --print('getTimeSinceTriggerEventMs ' .. getTimeSinceTriggerEventMs())
175 enableCompressionReleaseSolenoid = getTimeSinceTriggerEventMs() < compReleaseDulationLimit and rpm < rpmLimitSetting
176 duty = enableCompressionReleaseSolenoid and 1 or 0
177-- print("Compression release solenoid " .. duty)
178-- setPwmDuty(outputIndex, duty)
179 else
180 if offCounter == 0 then --goodbye sweet love
181 txCan(1, 0x502, 0, packet502) --goodbye
182 offCounter = 1 --One shot
183 end
184 end
185end
186)", efi::size(config->luaScript));
187#endif
188}
@ Unassigned
void setCustomMap(float lowValue, float mapLowValueVoltage, float highValue, float mapHighValueVoltage)
void setPPSInputs(adc_channel_e pps1, adc_channel_e pps2)
void setTPS1Inputs(adc_channel_e tps1, adc_channel_e tps2)
static constexpr persistent_config_s * config
static constexpr engine_configuration_s * engineConfiguration
static void harleyEngine()
Definition harley.cpp:6
brain_input_pin_e triggerInputPins[TRIGGER_INPUT_PIN_COUNT]

Referenced by applyEngineType().

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

Go to the source code of this file.