I asked the original question in the general forum area but its become more of a Lua scripting question I think, so wondering if someone can sanity check this for me - I don't have access to the car for a while to check if it works or not, and I'm not 100% sure on the setting up of channels, etc. I'm happy with excel but Lua is a new one on me so I've created this from a few of the examples on the web page - apologies if I've totally screwed it up or got it completely wrong!
The intent is to use two pressure sensor channels (which I've put in as A1 and A2 for the time being - can't remember which channels they're on off the top of my head) and output a value for brake (torque) balance which can be used as a quick sanity check to "rezero" the car after fiddling, or give a close set-up prior to hitting the track. I'm not planning on logging this channel, its purely a reference for set-up, but would be really good if i could have a screen set-up that shows this value either just as a number or as a dial or horizontal bar or something, rather than just using the pressure values and having to calculate. This also helps me hugely with transferring data from the sim rig to the car and vice-versa
I've put what I think below - the ***'s are just to show the start of the script
Things I'm not sure about:-
The basic channel set-up - I'm trying to calculate a percentage (front) brake and not sure if I've created an average of two channels instead?
Can I just use a1 and a2 in a calc? Do i need to do any other processing first?
Things I might like to add:-
Can I do something to effectively smooth out the inputs a bit (like you would do for fuel tank slosh) to A1 and A2 JUST for this calc? I don't want to do it generally for these channels as I log them and want them to remain quick to update, etc., but it might be useful for this calculation specifically
Any help hugely appreciated - hopefully this is something that will be useful to others in the future too
*****************************************************************
--1Hz update
setTickRate(1)
--Create channel: "FrontBrake"
--Sample rate: 1Hz
--Logging precision: 2 decimal points
--min/max: 0/100
--Units: "Front %"
avgId = addChannel("FrontBrake", 1, 2, 0, 100, "Front %")
-- REFERENCE SECTION
-- Brake Torque = 2 * u * (p * A) * r
-- p = Line pressure
-- u = Pad coefficient of friction
-- A = Piston area on one side of caliper
-- r = Centreline of swept pad area
-- pfront = Analogue input 1 (a1)
-- prear = Analogue input 2 (a2)
-- Afront = 4546.72mm^2
-- Arear = 2267.08mm^2
-- ufront = 0.6
-- urear = 0.5
-- rFront = 135.5mm
-- rRear = 125mm
-- REFERENCE CALCS
-- Front Brake Torque = ( 2 * 0.6 * ( a1 * 4546.72 ) * 135.5 )
-- Rear Brake Torque = ( 2 * 0.5 * ( a2 * 2267.08 ) * 125 )
-- Front Brake Bias (%) = Front Brake Torque / (Front Brake Torque + Rear Brake Torque)
function onTick()
local a1 = getAnalog(0)
local a2 = getAnalog(1)
setChannel(FrontBrakeId, (2*0.6*(a1*4546.72)*135.5)/((2*0.6*(a1*4546.72)*135.5)+(2*0.5*(a2*2267.08)*125))
end
Help with setting u calculated channel for F/R brake balance
-
- Posts: 43
- Joined: Mon Nov 30, 2015 1:08 pm
- Location: Leicester, UK
This will read the % of front vs rear.
avgId = addChannel("FwdBrkBias", 10, 0, 0, 100, "%")
function doBias()
local a1 = getAnalog(0)
local a2 = getAnalog(6)
setChannel(avgId, ((a1 / (a1 + a2)) * 100))
end
setTickRate(10)
function onTick()
doBias()
end
in this example: getAnalog(0) is the front press sensor channel. getAnalog(6) is the rear. change these to match yours.
bring up the three screen dash, and put your front press gauge on the left and rear press gauge on the right. select "FwdBrkBias" gauge for the center.
here's a short (and shaky) video.
avgId = addChannel("FwdBrkBias", 10, 0, 0, 100, "%")
function doBias()
local a1 = getAnalog(0)
local a2 = getAnalog(6)
setChannel(avgId, ((a1 / (a1 + a2)) * 100))
end
setTickRate(10)
function onTick()
doBias()
end
in this example: getAnalog(0) is the front press sensor channel. getAnalog(6) is the rear. change these to match yours.
bring up the three screen dash, and put your front press gauge on the left and rear press gauge on the right. select "FwdBrkBias" gauge for the center.
here's a short (and shaky) video.
-
- Posts: 43
- Joined: Mon Nov 30, 2015 1:08 pm
- Location: Leicester, UK
-
- Posts: 43
- Joined: Mon Nov 30, 2015 1:08 pm
- Location: Leicester, UK
I created this based on yours, so thought I'd post it in case anyone else wants to use it
I've included both versions - one uses front vs. rear pressure, the other uses front vs. rear brake torque
Hopefully its useful to someone, I will try and get it working on my car this weekend!
I know there's a lot of comments in there which can be deleted out - I figured I'd leave them in mostly for me for future reference, but also incase someone else comes across this who doesn't understand Lua (like me! ) in the future. Hopefully it will be easy to pick-up and modify for others
Credit to PS14 for the working script
**************************************************
-- THIS SCRIPT WILL CALCULATE % FRONT BRAKE BALANCE
-- Use the three screen dash, set front press on the left gauge, rear press on the right gauge, set "FwdBrkBias" for the center gauge
-- Create channel: "FwdBrkBias"
-- Sample rate: 10Hz
-- Logging precision: 0 decimal points
-- min/max: 0/100
-- Units: "%"
avgId = addChannel("FwdBrkBias", 10, 0, 0, 100, "%")
-- a1 = front brake pressure
-- (0) = analogue channel to use
-- a2 = rear brake pressure
-- (6) = analogue channel to use
function doBias()
local a1 = getAnalog(0)
local a2 = getAnalog(6)
-- REFERENCE SECTION
-- You will need to input your own info for u, A, and r for each of the equations if you want to calculate brake torque
-- Brake Torque = 2 * u * (p * A) * r
-- p = Line pressure (a1 and a2)
-- u = Pad coefficient of friction
-- A = Piston caliper piston area
-- r = Swept radius of centreline of pad area
-- pfront = Analogue input
-- prear = Analogue input
-- example values below are for porsche boxster s front calipers with e46 m3 discs and CL RC8 pads / bmw e46 328i rear calipers and discs and CL RC6 pads
-- Afront = 4546.72mm^2
-- Arear = 2267.08mm^2
-- ufront = 0.6
-- urear = 0.5
-- rFront = 135.5mm
-- rRear = 125mm
-- REFERENCE CALCS
-- Front Brake Torque = (2 * 0.6 * (a1 * 4546.72) * 135.5)
-- Rear Brake Torque = (2 * 0.5 * (a2 * 2267.08) * 125)
-- CALC CHANNEL
-- Comment out depending on the version you want to use
-- BRAKE TORQUE BALANCE
setChannel(avgId, (((2 * 0.6 * (a1 * 4546.72) * 135.5) / ((2 * 0.6 * (a1 * 4546.72) * 135.5) + (2 * 0.5 * (a2 * 2267.08) * 125))) * 100))
-- BRAKE PRESSURE BALANCE
-- setChannel(avgId, ((a1 / (a1 + a2)) * 100))
end
setTickRate(10)
function onTick()
doBias()
end
I've included both versions - one uses front vs. rear pressure, the other uses front vs. rear brake torque
Hopefully its useful to someone, I will try and get it working on my car this weekend!
I know there's a lot of comments in there which can be deleted out - I figured I'd leave them in mostly for me for future reference, but also incase someone else comes across this who doesn't understand Lua (like me! ) in the future. Hopefully it will be easy to pick-up and modify for others
Credit to PS14 for the working script
**************************************************
-- THIS SCRIPT WILL CALCULATE % FRONT BRAKE BALANCE
-- Use the three screen dash, set front press on the left gauge, rear press on the right gauge, set "FwdBrkBias" for the center gauge
-- Create channel: "FwdBrkBias"
-- Sample rate: 10Hz
-- Logging precision: 0 decimal points
-- min/max: 0/100
-- Units: "%"
avgId = addChannel("FwdBrkBias", 10, 0, 0, 100, "%")
-- a1 = front brake pressure
-- (0) = analogue channel to use
-- a2 = rear brake pressure
-- (6) = analogue channel to use
function doBias()
local a1 = getAnalog(0)
local a2 = getAnalog(6)
-- REFERENCE SECTION
-- You will need to input your own info for u, A, and r for each of the equations if you want to calculate brake torque
-- Brake Torque = 2 * u * (p * A) * r
-- p = Line pressure (a1 and a2)
-- u = Pad coefficient of friction
-- A = Piston caliper piston area
-- r = Swept radius of centreline of pad area
-- pfront = Analogue input
-- prear = Analogue input
-- example values below are for porsche boxster s front calipers with e46 m3 discs and CL RC8 pads / bmw e46 328i rear calipers and discs and CL RC6 pads
-- Afront = 4546.72mm^2
-- Arear = 2267.08mm^2
-- ufront = 0.6
-- urear = 0.5
-- rFront = 135.5mm
-- rRear = 125mm
-- REFERENCE CALCS
-- Front Brake Torque = (2 * 0.6 * (a1 * 4546.72) * 135.5)
-- Rear Brake Torque = (2 * 0.5 * (a2 * 2267.08) * 125)
-- CALC CHANNEL
-- Comment out depending on the version you want to use
-- BRAKE TORQUE BALANCE
setChannel(avgId, (((2 * 0.6 * (a1 * 4546.72) * 135.5) / ((2 * 0.6 * (a1 * 4546.72) * 135.5) + (2 * 0.5 * (a2 * 2267.08) * 125))) * 100))
-- BRAKE PRESSURE BALANCE
-- setChannel(avgId, ((a1 / (a1 + a2)) * 100))
end
setTickRate(10)
function onTick()
doBias()
end