only:proteus_f7
This commit is contained in:
rusefi 2023-05-15 21:12:34 -04:00
parent 5a8f4599f2
commit cee27257dd
2 changed files with 71 additions and 28 deletions

View File

@ -1,6 +1,7 @@
-- communication with https://github.com/rusefi/rusefi-hardware/tree/main/GDI-4ch/firmware
GDI4_BASE_ADDRESS = 0xF0
GDI_CHANGE_ADDRESS = GDI4_BASE_ADDRESS + 0x10
hexstr = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, "A", "B", "C", "D", "E", "F" }
@ -29,7 +30,7 @@ function arrayToString(arr)
end
function printPacket(bus, id, dlc, data)
print('Received ' ..arrayToString(data))
print('Received status packet ' ..arrayToString(data))
end
function getTwoBytesLSB(data, offset, factor)
@ -42,50 +43,94 @@ function setTwoBytesLsb(data, offset, value)
data[offset + 1] = value & 0xff
end
function onCanConfiguration(bus, id, dlc, data)
print('Received configuration ' ..arrayToString(data))
print ("BoostVoltage " ..getTwoBytesLSB(data, 0, 0.01) )
print ("BoostCurrent " ..getTwoBytesLSB(data, 2, 0.01) )
print ("PeakCurrent " ..getTwoBytesLSB(data, 4, 0.01) )
print ("HoldCurrent " ..getTwoBytesLSB(data, 6, 0.01) )
function onCanConfiguration1(bus, id, dlc, data)
print("Received configuration1 "..arrayToString(data))
print("GDI4 says BoostVoltage "..getTwoBytesLSB(data, 0, 1) )
print("GDI4 says BoostCurrent "..getTwoBytesLSB(data, 2, 1 / 128) )
print("GDI4 says TBoostMin "..getTwoBytesLSB(data, 4, 1) )
print("GDI4 says TBoostMax "..getTwoBytesLSB(data, 6, 1) )
end
function onCanConfiguration2(bus, id, dlc, data)
print("Received configuration2 "..arrayToString(data))
print("GDI4 says PeakCurrent "..getTwoBytesLSB(data, 0, 1 / 128) )
print("GDI4 says TpeakDuration "..getTwoBytesLSB(data, 2, 1) )
print("GDI4 says TpeakOff "..getTwoBytesLSB(data, 4, 1) )
print("GDI4 says Tbypass "..getTwoBytesLSB(data, 6, 1) )
end
function onCanConfiguration3(bus, id, dlc, data)
print("Received configuration3 "..arrayToString(data))
print("GDI4 says HoldCurrent "..getTwoBytesLSB(data, 0, 1 / 128) )
print("GDI4 says TholdOff "..getTwoBytesLSB(data, 2, 1) )
print("GDI4 says THoldDuration "..getTwoBytesLSB(data, 4, 1) )
end
function onCanVersion(bus, id, dlc, data)
year = data[1] * 100 + data[2]
month = data[3]
day = data[4]
print ("GDI4 FW " .. year .. '/' .. month .. '/' .. day)
print ("GDI4 firmware " .. year .. '/' .. month .. '/' .. day)
end
canRxAdd(GDI4_BASE_ADDRESS, printPacket)
canRxAdd(GDI4_BASE_ADDRESS + 1, onCanConfiguration)
canRxAdd(GDI4_BASE_ADDRESS + 2, printPacket)
canRxAdd(GDI4_BASE_ADDRESS + 3, onCanVersion)
canRxAdd(GDI4_BASE_ADDRESS + 1, onCanConfiguration1)
canRxAdd(GDI4_BASE_ADDRESS + 2, onCanConfiguration2)
canRxAdd(GDI4_BASE_ADDRESS + 3, onCanConfiguration3)
canRxAdd(GDI4_BASE_ADDRESS + 4, onCanVersion)
local data_set_voltage = { 0x88, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }
local data_set_settings = { 0x77, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }
FIXED_POINT = 100
FIXED_POINT = 128
setTickRate(2)
function onTick()
boostVoltage = getCalibration("mc33_hvolt")
boostCurrent = getCalibration("mc33_i_boost") / 1000.0
peakCurrent = getCalibration("mc33_i_peak") / 1000.0
print("To send: boostVoltage " .. boostVoltage .." boostCurrent " ..boostCurrent .." peakCurrent " ..peakCurrent)
-- set mc33_hvolt 60
boostVoltage = getCalibration("mc33_hvolt")
boostCurrent = getCalibration("mc33_i_boost") / 1000.0
TBoostMin = getCalibration("mc33_t_min_boost")
print("To send 0: boostVoltage " .. boostVoltage .." boostCurrent " ..boostCurrent .." TBoostMin " ..TBoostMin)
-- set mc33_t_max_boost 380
TBoostMax = getCalibration("mc33_t_max_boost")
setTwoBytesLsb(data_set_voltage, 1, boostVoltage * FIXED_POINT)
setTwoBytesLsb(data_set_voltage, 3, boostCurrent * FIXED_POINT)
setTwoBytesLsb(data_set_voltage, 5, peakCurrent * FIXED_POINT)
print('Will be sending ' ..arrayToString(data_set_voltage))
-- set mc33_i_peak 14500
peakCurrent = getCalibration("mc33_i_peak") / 1000.0
TpeakDuration = getCalibration("mc33_t_peak_tot")
print("To send 1: TBoostMax " .. TBoostMax .." peakCurrent " ..peakCurrent .." TpeakDuration " ..TpeakDuration)
TpeakOff = getCalibration("mc33_t_peak_off")
Tbypass = getCalibration("mc33_t_bypass")
txCan(1, 0x201, 1, data_set_voltage)
holdCurrent = getCalibration("mc33_i_hold") / 1000.0
print("To send 2: TpeakOff " .. TpeakOff .. " Tbypass " .. Tbypass .." holdCurrent " ..holdCurrent)
TholdOff = getCalibration("mc33_t_hold_off")
THoldDuration = getCalibration("mc33_t_hold_tot")
print("To send 3: TholdOff " .. TholdOff .. " THoldDuration " .. THoldDuration)
holdCurrent = getCalibration("mc33_i_hold")
peakDuration = getCalibration("mc33_t_peak_tot") / 1000.0
holdDuration = getCalibration("mc33_t_hold_tot") / 1000.0
print("To send: holdCurrent " .. holdCurrent .. " peakDuration " .. peakDuration .." hold duration " ..holdDuration)
setTwoBytesLsb(data_set_settings, 1, boostVoltage)
setTwoBytesLsb(data_set_settings, 3, boostCurrent * FIXED_POINT)
setTwoBytesLsb(data_set_settings, 5, TBoostMin)
print('Will be sending ' ..arrayToString(data_set_settings))
txCan(1, GDI_CHANGE_ADDRESS, 1, data_set_settings)
setTwoBytesLsb(data_set_settings, 1, TBoostMax)
setTwoBytesLsb(data_set_settings, 3, peakCurrent * FIXED_POINT)
setTwoBytesLsb(data_set_settings, 5, TpeakDuration)
print('Will be sending ' ..arrayToString(data_set_settings))
txCan(1, GDI_CHANGE_ADDRESS + 2, 1, data_set_settings)
setTwoBytesLsb(data_set_settings, 1, TpeakOff)
setTwoBytesLsb(data_set_settings, 3, Tbypass)
setTwoBytesLsb(data_set_settings, 5, holdCurrent * FIXED_POINT)
print('Will be sending ' ..arrayToString(data_set_settings))
txCan(1, GDI_CHANGE_ADDRESS + 3, 1, data_set_settings)
setTwoBytesLsb(data_set_settings, 1, TholdOff)
setTwoBytesLsb(data_set_settings, 3, THoldDuration)
setTwoBytesLsb(data_set_settings, 5, 0)
print('Will be sending ' ..arrayToString(data_set_settings))
txCan(1, GDI_CHANGE_ADDRESS + 4, 1, data_set_settings)
end

View File

@ -2741,7 +2741,6 @@ cmd_set_engine_type_default = "@@TS_IO_TEST_COMMAND_char@@@@ts_command_e_TS_
field = "MC33816 flag0", mc33816_flag0
field = "Boost voltage", mc33_hvolt
field = "Boost current target", mc33_i_boost
field = "Min boost time", mc33_t_min_boost
field = "Max boost time (timeout)", mc33_t_max_boost
@ -2755,7 +2754,6 @@ cmd_set_engine_type_default = "@@TS_IO_TEST_COMMAND_char@@@@ts_command_e_TS_
field = "Hold phase loop off time", mc33_t_hold_off
field = "Maximum injection duration", mc33_t_hold_tot
; Sensor Inputs
dialog = otherSensorInputs, "Other Sensor Inputs"
field = "Clutch Down", clutchDownPin