fake motor_1 happy drive in the air
This commit is contained in:
parent
eb592e21d9
commit
c9d25c4a9c
|
@ -25,7 +25,8 @@ function onMotor1(bus, id, dlc, data)
|
|||
|
||||
fakeTorque = interpolate(0, 6, 100, 60, tps)
|
||||
|
||||
txCan(TCU_BUS, MOTOR_1, 0, data)
|
||||
-- txCan(TCU_BUS, MOTOR_1, 0, motor1Data)
|
||||
sendMotor1()
|
||||
end
|
||||
|
||||
canRxAdd(ECU_BUS, MOTOR_1, onMotor1)
|
||||
|
|
|
@ -77,4 +77,21 @@ function sendMotor2()
|
|||
motor2Data[1] = motor2mux[1 + index]
|
||||
|
||||
txCan(TCU_BUS, MOTOR_2_648, 0, motor2Data)
|
||||
end
|
||||
|
||||
motor1Data = { 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }
|
||||
function sendMotor1()
|
||||
engineTorque = fakeTorque * 0.9
|
||||
innerTorqWithoutExt = fakeTorque
|
||||
torqueLoss = 20
|
||||
requestedTorque = fakeTorque
|
||||
|
||||
motor1Data[2] = engineTorque / 0.39
|
||||
setTwoBytesLsb(motor1Data, 2, rpm / 0.25)
|
||||
motor1Data[5] = innerTorqWithoutExt / 0.4
|
||||
motor1Data[6] = tps / 0.4
|
||||
motor1Data[7] = torqueLoss / 0.39
|
||||
motor1Data[8] = requestedTorque / 0.39
|
||||
|
||||
txCan(TCU_BUS, MOTOR_1, 0, motor1Data)
|
||||
end
|
|
@ -53,6 +53,12 @@ function getBitRange(data, bitIndex, bitWidth)
|
|||
return (value >> shift) & mask
|
||||
end
|
||||
|
||||
function setTwoBytesLsb(data, offset, value)
|
||||
value = math.floor(value)
|
||||
data[offset + 2] = value >> 8
|
||||
data[offset + 1] = value & 0xff
|
||||
end
|
||||
|
||||
function setTwoBytesMsb(data, offset, value)
|
||||
value = math.floor(value)
|
||||
data[offset + 1] = value >> 8
|
||||
|
|
Loading…
Reference in New Issue