RegisterSearchFAQMemberlistUsergroupsLog in
Reply to topic Page 1 of 1
Script Check - Virtual channels with math
Author Message
Reply with quote
Post Script Check - Virtual channels with math 
Would someone check this script and let me know if it looks right. I am pulling two 1600psi brake pressure senders in via AnalogX and want to create a virtual channel (gauge) that shows the percentage of one against the total of the two (to show brake bias %). thanks, Dave

--Create Virtual Channels:
vfbrakeId = addChannel("vfbrake", 10, 0, 0, 1600, "psi")
vrbrakeId = addChannel("vrbrake", 10, 0, 0, 1600, "psi")
bbsId = addChannel("BrakeBias", 10, 0, 0, 100, "%")

function processCan()
id, ext, data = rxCAN(0)
if id == 935444 then
setChannel(vfbrakeId, data[7], 16, 40, -200)
setChannel(vrbrakeId, data[9], 16, 40, -200)
end

function setChannel()
local a1 = vfbrake()
local a2 = vrbrake()
setChannel(bbsId, (a2 / (a1 + a2)))
end

function onTick()
processCan()
setChannel()
end
end

View user's profile Send private message
Reply with quote
Post  
Hi, this looks like a duplicate of the conversation you have in the AnalogX section? if so we can continue it there.


_________________
Brent Picasso
Founder, Autosport Labs
Facebook | Twitter
View user's profile Send private message Send e-mail
Display posts from previous:
Reply to topic Page 1 of 1
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum