Hello! I'm using a very simple board with a F405RGT6 cpu, and the rusefi.snapshot.f407-discovery image. Everithing is working good. I wanna try the LUA scripting, but I stucked in the very beginning
I tried to read a sensor value and print it to first test, but I only get nil not a value. I tried clt, Tps1, rpm, but no one working
function onTick()
clt = getSensor("Clt")
print(clt)
end
my queston is: the LUA srcipting all features is available in all the pre compiled images?
Very stupid LAU question
- AndreyB
- Site Admin
- Posts: 14334
- Joined: Wed Aug 28, 2013 1:28 am
- Location: Jersey City
- Github Username: rusefillc
- Slack: Andrey B
Re: Very stupid LAU question
No, Lua is not available in most _debug configurations like f407-discovery_debug but you said f407-discovery?FFG_Garage wrote: ↑Fri Nov 03, 2023 11:18 amthe LUA srcipting all features is available in all the pre compiled images?
Now you have an answer to the question you've asked but how it would help you I have no idea.
There was a defect in small-can-board https://github.com/rusefi/rusefi/commit/66759b1cff096327fb50acfa2c0c3cdba45d969b but that's not the one you are using. Not sure what's broken on your end.
Very limited telepathic abilities - please post logs & tunes where appropriate - http://rusefi.com/s/questions
Always looking for C/C++/Java/PHP developers! Please help us see https://rusefi.com/s/howtocontribute
Always looking for C/C++/Java/PHP developers! Please help us see https://rusefi.com/s/howtocontribute
-
- Posts: 16
- Joined: Tue Jul 11, 2023 8:37 pm
Re: Very stupid LAU question
I use f407-discovery, not the _debug version. But I can try another package.AndreyB wrote: ↑Fri Nov 03, 2023 11:40 amNo, Lua is not available in most _debug configurations like f407-discovery_debug but you said f407-discovery?FFG_Garage wrote: ↑Fri Nov 03, 2023 11:18 amthe LUA srcipting all features is available in all the pre compiled images?
Now you have an answer to the question you've asked but how it would help you I have no idea.
There was a defect in small-can-board https://github.com/rusefi/rusefi/commit/66759b1cff096327fb50acfa2c0c3cdba45d969b but that's not the one you are using. Not sure what's broken on your end.
- AndreyB
- Site Admin
- Posts: 14334
- Joined: Wed Aug 28, 2013 1:28 am
- Location: Jersey City
- Github Username: rusefillc
- Slack: Andrey B
Re: Very stupid LAU question
You are using the right bundle. The problem you are experiencing is about something else.
Very limited telepathic abilities - please post logs & tunes where appropriate - http://rusefi.com/s/questions
Always looking for C/C++/Java/PHP developers! Please help us see https://rusefi.com/s/howtocontribute
Always looking for C/C++/Java/PHP developers! Please help us see https://rusefi.com/s/howtocontribute
-
- Posts: 16
- Joined: Tue Jul 11, 2023 8:37 pm
Re: Very stupid LAU question
I made a full chip erase, reload the firmware, and now everything working good. I don't know what was the problem.
One more question: is there any reason to set the rpm and the throttle target with a lua script from a can broadcasted rpm and pedal terget value?
thank you
- AndreyB
- Site Admin
- Posts: 14334
- Joined: Wed Aug 28, 2013 1:28 am
- Location: Jersey City
- Github Username: rusefillc
- Slack: Andrey B
Re: Very stupid LAU question
TPS target yes https://github.com/rusefi/rusefi/wiki/Lua-Scripting#setetbaddpercent
RPM target not at the moment there is only https://github.com/rusefi/rusefi/wiki/Lua-Scripting#setidleaddpercent
Are you working on a generator or something?
RPM target not at the moment there is only https://github.com/rusefi/rusefi/wiki/Lua-Scripting#setidleaddpercent
Are you working on a generator or something?
Very limited telepathic abilities - please post logs & tunes where appropriate - http://rusefi.com/s/questions
Always looking for C/C++/Java/PHP developers! Please help us see https://rusefi.com/s/howtocontribute
Always looking for C/C++/Java/PHP developers! Please help us see https://rusefi.com/s/howtocontribute
-
- Posts: 16
- Joined: Tue Jul 11, 2023 8:37 pm
Re: Very stupid LAU question
No, I have a stand alone ETB controller. In the LUA script example files I see somebody create the can output script for megasquirt, and I think if the rpm signal and the ETB Position Target can work from the broadcansted can bus massage, my little board will be a fully implemented can bus ETB controller. Right now I use the setetbaddpercent lua script to control the idle with ETB from the ecu pwm idle signalAndreyB wrote: ↑Mon Nov 06, 2023 2:20 pmTPS target yes https://github.com/rusefi/rusefi/wiki/Lua-Scripting#setetbaddpercent
RPM target not at the moment there is only https://github.com/rusefi/rusefi/wiki/Lua-Scripting#setidleaddpercent
Are you working on a generator or something?
-
- Posts: 16
- Joined: Tue Jul 11, 2023 8:37 pm
Re: Very stupid LAU question
the script:
function onTick()
aux2 = getSensor("AuxLinear2")
print(aux2)
setEtbAdd(aux2)
end
The TS menu:
and use this to convert the pwm to analog:
function onTick()
aux2 = getSensor("AuxLinear2")
print(aux2)
setEtbAdd(aux2)
end
The TS menu:
and use this to convert the pwm to analog:
-
- Posts: 16
- Joined: Tue Jul 11, 2023 8:37 pm
Re: Very stupid LAU question
The rpm signal over can bus not working, but if I connect the Rusefi trigger input with the megasquirt tachometer output, and connect each together with can, the megasquirt can work with a full integrated can bus DBW controller, on the DBW controller run RusEfi code.
LUA script:
-- DBW protocol for legacy standalone systems
BASE_CAN_ID = 256
setTickRate(100)
-- MOTOROLA order, MSB (Most Significant Byte/Big Endian) comes first
function setTwoBytesMsb(data, offset, value)
value = math.floor(value)
data[offset + 1] = value >> 8
data[offset + 2] = value & 0xff
end
function getTwoBytesMSB(data, offset, factor)
return (data[offset + 1] * 256 + data[offset + 2]) * factor
end
function printPacket(bus, id, dlc, data)
local TpsTarget = getTwoBytesMSB(data, 0, 1)
TpsTarget = TpsTarget/1024 * 1000
TpsTarget = TpsTarget / 10
local Pedal = getSensor("AcceleratorPedal")
Throttle = TpsTarget - Pedal
setEtbAdd(Throttle)
end
canRxAdd(1, BASE_CAN_ID + 4, printPacket)
protocolPacket = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }
protocolPacket2 = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }
function onTick()
local ppsValue = getSensor("AcceleratorPedal")
ppsValue = (ppsValue == nil and 0 or ppsValue)
local TPS = getSensor("Tps1")
TPS = (TPS == nil and 0 or TPS)
setTwoBytesMsb(protocolPacket, 0, ppsValue / 100 * 1024)
setTwoBytesMsb(protocolPacket, 2, TPS / 100 * 1024)
txCan(1, BASE_CAN_ID + 0, 0, protocolPacket)
local PedalError = getOutput("isPedalError")
local TpsError = getOutput("isTpsError")
PedalError = 1000 - (PedalError * 1000)
TpsError = 1000 - (TpsError * 1000)
if PedalError == 0 then
setTwoBytesMsb(protocolPacket2, 0, 150)
elseif TpsError == 0 then
setTwoBytesMsb(protocolPacket2, 0, 0)
else
setTwoBytesMsb(protocolPacket2, 0, 1000)
end
txCan(1, BASE_CAN_ID + 10, 0, protocolPacket2)
end
LUA script:
-- DBW protocol for legacy standalone systems
BASE_CAN_ID = 256
setTickRate(100)
-- MOTOROLA order, MSB (Most Significant Byte/Big Endian) comes first
function setTwoBytesMsb(data, offset, value)
value = math.floor(value)
data[offset + 1] = value >> 8
data[offset + 2] = value & 0xff
end
function getTwoBytesMSB(data, offset, factor)
return (data[offset + 1] * 256 + data[offset + 2]) * factor
end
function printPacket(bus, id, dlc, data)
local TpsTarget = getTwoBytesMSB(data, 0, 1)
TpsTarget = TpsTarget/1024 * 1000
TpsTarget = TpsTarget / 10
local Pedal = getSensor("AcceleratorPedal")
Throttle = TpsTarget - Pedal
setEtbAdd(Throttle)
end
canRxAdd(1, BASE_CAN_ID + 4, printPacket)
protocolPacket = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }
protocolPacket2 = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }
function onTick()
local ppsValue = getSensor("AcceleratorPedal")
ppsValue = (ppsValue == nil and 0 or ppsValue)
local TPS = getSensor("Tps1")
TPS = (TPS == nil and 0 or TPS)
setTwoBytesMsb(protocolPacket, 0, ppsValue / 100 * 1024)
setTwoBytesMsb(protocolPacket, 2, TPS / 100 * 1024)
txCan(1, BASE_CAN_ID + 0, 0, protocolPacket)
local PedalError = getOutput("isPedalError")
local TpsError = getOutput("isTpsError")
PedalError = 1000 - (PedalError * 1000)
TpsError = 1000 - (TpsError * 1000)
if PedalError == 0 then
setTwoBytesMsb(protocolPacket2, 0, 150)
elseif TpsError == 0 then
setTwoBytesMsb(protocolPacket2, 0, 0)
else
setTwoBytesMsb(protocolPacket2, 0, 1000)
end
txCan(1, BASE_CAN_ID + 10, 0, protocolPacket2)
end