B6 would it ever work... :(

This commit is contained in:
rusefillc 2023-01-10 21:27:35 -05:00
parent 382749e03a
commit 43448a7640
1 changed files with 15 additions and 6 deletions

View File

@ -177,10 +177,7 @@ canRxAdd(1, ACC_GRA, onAccGra)
function onMotor1(bus, id, dlc, data)
rpm = getSensor("RPM") or 0
clt = getSensor("CLT") or 0
iat = getSensor("IAT") or 0
tps = getSensor("TPS1") or 0
vbat = getSensor("BatteryVoltage") or 0
fakeTorque = interpolate(0, 6, 100, 60, tps)
@ -205,6 +202,20 @@ function onMotor1(bus, id, dlc, data)
txCan(TCU_BUS, MOTOR_1, 0, motor1Data)
end
function onMotor3(bus, id, dlc, data)
iat = getSensor("IAT") or 0
tps = getSensor("TPS1") or 0
desired_wheel_torque = fakeTorque
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
motorBreCounter = 0
function onMotorBre(bus, id, dlc, data)
motorBreCounter = (motorBreCounter + 1) % 16
@ -296,9 +307,6 @@ function onTick()
counter16 = (counter16 + 1) % 16
rpm = getSensor("RPM") or 0
clt = getSensor("CLT") or 0
iat = getSensor("IAT") or 0
tps = getSensor("TPS1") or 0
vbat = getSensor("BatteryVoltage") or 0
if rpm == 0 then
@ -306,6 +314,7 @@ function onTick()
end
onMotor1(0, 0, 0, nil)
onMotor3(0, 0, 0, nil)
onMotorBre(0, 0, 0, nil)
onMotor2(0, 0, 0, nil)