fake motor_2 happy drive in the air
This commit is contained in:
parent
0e4486f4c5
commit
741cf928ca
|
@ -11,9 +11,26 @@
|
|||
|
||||
setTickRate(100)
|
||||
|
||||
canRxAdd(ECU_BUS, MOTOR_1, silentlyRelayFromECU)
|
||||
rpm = 0
|
||||
tps = 0
|
||||
fakeTorque = 0
|
||||
function onMotor1(bus, id, dlc, data)
|
||||
totalEcuMessages = totalEcuMessages + 1
|
||||
rpm = getBitRange(data, 16, 16) * 0.25 or 0
|
||||
if rpm == 0 then
|
||||
canMotorInfoTotalCounter = 0
|
||||
end
|
||||
|
||||
tps = getBitRange(data, 40, 8) * 0.4 or 0
|
||||
|
||||
fakeTorque = interpolate(0, 6, 100, 60, tps)
|
||||
|
||||
txCan(TCU_BUS, MOTOR_1, 0, data)
|
||||
end
|
||||
|
||||
canRxAdd(ECU_BUS, MOTOR_1, onMotor1)
|
||||
canRxAdd(ECU_BUS, MOTOR_BRE, drop)
|
||||
canRxAdd(ECU_BUS, MOTOR_2_648, silentlyRelayFromECU)
|
||||
canRxAdd(ECU_BUS, MOTOR_2_648, sendMotor2)
|
||||
canRxAdd(ECU_BUS, MOTOR_3, silentlyRelayFromECU)
|
||||
canRxAdd(ECU_BUS, MOTOR_5, drop)
|
||||
canRxAdd(ECU_BUS, MOTOR_6, silentlyRelayFromECU)
|
||||
|
@ -76,6 +93,7 @@ function onTick()
|
|||
if everySecondTimer : getElapsedSeconds() > 1 then
|
||||
everySecondTimer : reset()
|
||||
print("Total from ECU " ..totalEcuMessages .. " totalTcuMessages " .. totalTcuMessages)
|
||||
print("tps " .. tps .. " RPM=" .. rpm);
|
||||
|
||||
motor5FuelCounter = motor5FuelCounter + 20
|
||||
|
||||
|
|
|
@ -57,3 +57,24 @@ motor7Data = { 0x1A, 0x66, 0x7E, 0x00, 0x00, 0x00, 0x00, 0x00 }
|
|||
function sendMotor7()
|
||||
txCan(TCU_BUS, MOTOR_7, 0, motor7Data)
|
||||
end
|
||||
|
||||
motor2mux = { 0x8A, 0xE8, 0x2C, 0x64 }
|
||||
motor2Data = { 0x8A, 0x8D, 0x10, 0x04, 0x00, 0x4C, 0xDC, 0x87 }
|
||||
motor2counter = 0
|
||||
function sendMotor2()
|
||||
motor2counter = (motor2counter + 1) % 16
|
||||
|
||||
minTorque = fakeTorque / 2
|
||||
-- todo: add CLT
|
||||
motor2Data[7] = math.floor(minTorque / 0.39)
|
||||
|
||||
--print ( "brake " .. getBitRange(data, 16, 2) .. " " .. rpm)
|
||||
|
||||
brakeBit = rpm < 2000 and 1 or 0
|
||||
setBitRange(motor2Data, 16, 1, brakeBit)
|
||||
|
||||
index = math.floor(motor2counter / 4)
|
||||
motor2Data[1] = motor2mux[1 + index]
|
||||
|
||||
txCan(TCU_BUS, MOTOR_2_648, 0, motor2Data)
|
||||
end
|
Loading…
Reference in New Issue