fake motor_3 happy drive in the air

This commit is contained in:
rusEFI LLC 2024-06-30 19:10:39 -04:00
parent c9d25c4a9c
commit 8def2d24a8
2 changed files with 30 additions and 1 deletions

View File

@ -29,10 +29,26 @@ function onMotor1(bus, id, dlc, data)
sendMotor1() sendMotor1()
end end
iat = 0
pps = 0
tps = 0
motor3counter = 0
function onMotor3(bus, id, dlc, data)
motor3counter = (motor3counter + 1) % 16
totalEcuMessages = totalEcuMessages + 1
iat = getBitRange(data, 8, 8) * 0.75 - 48
pps = getBitRange(data, 16, 8) * 0.40
tps = getBitRange(data, 56, 8) * 0.40
if motor3counter % 70 == 0 then
-- print ('MOTOR_3 pps ' ..pps ..' tps ' ..tps ..' iat ' ..iat)
end
end
canRxAdd(ECU_BUS, MOTOR_1, onMotor1) canRxAdd(ECU_BUS, MOTOR_1, onMotor1)
canRxAdd(ECU_BUS, MOTOR_BRE, drop) canRxAdd(ECU_BUS, MOTOR_BRE, drop)
canRxAdd(ECU_BUS, MOTOR_2_648, sendMotor2) canRxAdd(ECU_BUS, MOTOR_2_648, sendMotor2)
canRxAdd(ECU_BUS, MOTOR_3, silentlyRelayFromECU) canRxAdd(ECU_BUS, MOTOR_3, onMotor3)
canRxAdd(ECU_BUS, MOTOR_5, drop) canRxAdd(ECU_BUS, MOTOR_5, drop)
canRxAdd(ECU_BUS, MOTOR_6, silentlyRelayFromECU) canRxAdd(ECU_BUS, MOTOR_6, silentlyRelayFromECU)
canRxAdd(ECU_BUS, MOTOR_7, drop) canRxAdd(ECU_BUS, MOTOR_7, drop)
@ -106,6 +122,7 @@ function onTick()
_10msPeriodTimer : reset() _10msPeriodTimer : reset()
sendMotorBre() sendMotorBre()
sendAccGra() sendAccGra()
sendMotor3()
sendMotor5() sendMotor5()
sendMotor7() sendMotor7()
end end

View File

@ -94,4 +94,16 @@ function sendMotor1()
motor1Data[8] = requestedTorque / 0.39 motor1Data[8] = requestedTorque / 0.39
txCan(TCU_BUS, MOTOR_1, 0, motor1Data) txCan(TCU_BUS, MOTOR_1, 0, motor1Data)
end
canMotor3 = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }
function sendMotor3()
desired_wheel_torque = fakeTorque
iat = iat or 30
canMotor3[2] = (iat + 48) / 0.75
canMotor3[3] = tps / 0.4
canMotor3[5] = 0x20
setBitRange(canMotor3, 24, 12, math.floor(desired_wheel_torque / 0.39))
canMotor3[8] = tps / 0.4
txCan(TCU_BUS, MOTOR_3, 0, canMotor3)
end end