only gdi4: smarter TX timing
This commit is contained in:
parent
b2cf3cb2b0
commit
f3c0014d2c
|
@ -94,65 +94,76 @@ local data_set_settings = { GDI4_CAN_SET_TAG, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
|||
|
||||
FIXED_POINT = 128
|
||||
|
||||
setTickRate(2)
|
||||
setTickRate(10)
|
||||
|
||||
counter = 0
|
||||
packet_kinds = 5
|
||||
|
||||
function onTick()
|
||||
counter = counter + 1
|
||||
|
||||
TpeakOff = getCalibration("mc33_t_peak_off")
|
||||
Tbypass = getCalibration("mc33_t_bypass")
|
||||
|
||||
holdCurrent = getCalibration("mc33_i_hold") / 1000.0
|
||||
print("To send 2: TpeakOff " .. TpeakOff .. " Tbypass " .. Tbypass .." holdCurrent " ..holdCurrent)
|
||||
|
||||
|
||||
if (counter % packet_kinds) == 0 then
|
||||
-- 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)
|
||||
setTwoBytesLsb(data_set_settings, 1, boostVoltage)
|
||||
setTwoBytesLsb(data_set_settings, 3, boostCurrent * FIXED_POINT)
|
||||
setTwoBytesLsb(data_set_settings, 5, TBoostMin)
|
||||
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)
|
||||
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)
|
||||
txCan(1, GDI_CHANGE_ADDRESS, 1, data_set_settings)
|
||||
end
|
||||
|
||||
-- set mc33_t_max_boost 380
|
||||
TBoostMax = getCalibration("mc33_t_max_boost")
|
||||
-- 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)
|
||||
setTwoBytesLsb(data_set_settings, 1, TBoostMax)
|
||||
setTwoBytesLsb(data_set_settings, 3, peakCurrent * FIXED_POINT)
|
||||
setTwoBytesLsb(data_set_settings, 5, TpeakDuration)
|
||||
if (counter % packet_kinds) == 1 then
|
||||
-- set mc33_t_max_boost 380
|
||||
TBoostMax = getCalibration("mc33_t_max_boost")
|
||||
-- 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)
|
||||
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 + 1, 1, data_set_settings)
|
||||
txCan(1, GDI_CHANGE_ADDRESS + 1, 1, data_set_settings)
|
||||
end
|
||||
|
||||
setTwoBytesLsb(data_set_settings, 1, TpeakOff)
|
||||
setTwoBytesLsb(data_set_settings, 3, Tbypass)
|
||||
setTwoBytesLsb(data_set_settings, 5, holdCurrent * FIXED_POINT)
|
||||
if (counter % packet_kinds) == 2 then
|
||||
holdCurrent = getCalibration("mc33_i_hold") / 1000.0
|
||||
print("To send 2: TpeakOff " .. TpeakOff .. " Tbypass " .. Tbypass .." holdCurrent " ..holdCurrent)
|
||||
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 + 2, 1, data_set_settings)
|
||||
txCan(1, GDI_CHANGE_ADDRESS + 2, 1, data_set_settings)
|
||||
end
|
||||
|
||||
|
||||
pumpPeakCurrent = getCalibration("mc33_hpfp_i_peak")
|
||||
|
||||
TholdOff = getCalibration("mc33_t_hold_off")
|
||||
THoldDuration = getCalibration("mc33_t_hold_tot")
|
||||
print("To send 3: TholdOff " .. TholdOff .. " THoldDuration " .. THoldDuration)
|
||||
setTwoBytesLsb(data_set_settings, 1, TholdOff)
|
||||
setTwoBytesLsb(data_set_settings, 3, THoldDuration)
|
||||
if (counter % packet_kinds) == 3 then
|
||||
TholdOff = getCalibration("mc33_t_hold_off")
|
||||
THoldDuration = getCalibration("mc33_t_hold_tot")
|
||||
pumpPeakCurrent = getCalibration("mc33_hpfp_i_peak")
|
||||
print("To send 3: TholdOff " .. TholdOff .. " THoldDuration " .. THoldDuration .. " pumpPeakCurrent " .. pumpPeakCurrent)
|
||||
setTwoBytesLsb(data_set_settings, 1, TholdOff)
|
||||
setTwoBytesLsb(data_set_settings, 3, THoldDuration)
|
||||
-- set mc33_hpfp_i_peak 6
|
||||
setTwoBytesLsb(data_set_settings, 5, pumpPeakCurrent * FIXED_POINT)
|
||||
print('Will be sending ' ..arrayToString(data_set_settings))
|
||||
txCan(1, GDI_CHANGE_ADDRESS + 3, 1, data_set_settings)
|
||||
setTwoBytesLsb(data_set_settings, 5, pumpPeakCurrent * FIXED_POINT)
|
||||
-- print('Will be sending ' ..arrayToString(data_set_settings))
|
||||
txCan(1, GDI_CHANGE_ADDRESS + 3, 1, data_set_settings)
|
||||
end
|
||||
|
||||
pumpHoldCurrent = getCalibration("mc33_hpfp_i_hold")
|
||||
setTwoBytesLsb(data_set_settings, 1, pumpHoldCurrent * FIXED_POINT)
|
||||
outputCanID = GDI4_BASE_ADDRESS
|
||||
setTwoBytesLsb(data_set_settings, 3, outputCanID)
|
||||
print('Will be sending ' ..arrayToString(data_set_settings))
|
||||
txCan(1, GDI_CHANGE_ADDRESS + 4, 1, data_set_settings)
|
||||
if (counter % packet_kinds) == 4 then
|
||||
pumpHoldCurrent = getCalibration("mc33_hpfp_i_hold")
|
||||
print("To send 4: pumpHoldCurrent " .. pumpHoldCurrent)
|
||||
setTwoBytesLsb(data_set_settings, 1, pumpHoldCurrent * FIXED_POINT)
|
||||
outputCanID = GDI4_BASE_ADDRESS
|
||||
setTwoBytesLsb(data_set_settings, 3, outputCanID)
|
||||
-- print('Will be sending ' ..arrayToString(data_set_settings))
|
||||
txCan(1, GDI_CHANGE_ADDRESS + 4, 1, data_set_settings)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue