pid demo progress
This commit is contained in:
parent
05820ec92d
commit
5e346e40a3
|
@ -930,14 +930,19 @@ biasCurveIndex = findCurveIndex("bias")
|
||||||
|
|
||||||
canRxAdd(0x600)
|
canRxAdd(0x600)
|
||||||
|
|
||||||
function onCanRx(id, dlc, data)
|
voltageFromCan = nil
|
||||||
print(id .. ' ' .. dlc .. data)
|
canRxAdd(0x600)
|
||||||
|
|
||||||
|
function onCanRx(bus, id, dlc, data)
|
||||||
|
print('got CAN id=' .. id .. ' dlc=' .. dlc)
|
||||||
|
voltageFromCan = data[2] / 256.0 + data[1]
|
||||||
end
|
end
|
||||||
|
|
||||||
function onTick()
|
function onTick()
|
||||||
local targetVoltage = getAuxAnalog(0)
|
local targetVoltage = getAuxAnalog(0)
|
||||||
|
|
||||||
local target = interpolate(1, 0, 3.5, 100, targetVoltage)
|
-- local target = interpolate(1, 0, 3.5, 100, targetVoltage)
|
||||||
|
local target = interpolate(1, 0, 3.5, 100, voltageFromCan)
|
||||||
-- clamp 0 to 100
|
-- clamp 0 to 100
|
||||||
target = math.max(0, target)
|
target = math.max(0, target)
|
||||||
target = math.min(100, target)
|
target = math.min(100, target)
|
||||||
|
|
Loading…
Reference in New Issue