Help with setting u calculated channel for F/R brake balance
Posted: Mon Dec 10, 2018 9:45 am
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
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