About the driveline basics... - Printable Version +- Forums (https://www.vdrift.net/Forum) +-- Forum: Project (https://www.vdrift.net/Forum/forumdisplay.php?fid=4) +--- Forum: Development (https://www.vdrift.net/Forum/forumdisplay.php?fid=9) +--- Thread: About the driveline basics... (/showthread.php?tid=1487) About the driveline basics... - smr597 - 05-24-2011 So i'm a bit confused learning the whole driveline code in Vdrift I'm not sure how the clutch is working in vdrift, but as i can see it sure is working. So could some one tell me if i got it right or what am i missing, since im trying to understand the basics of a driveline in vdrift (obviously). As i understand in Vdrift there are two engine components? One that is calculated from the wheels witch gives us the abiltyto drive the car and other that is freely running, ie if the clutch is unlocked. Well this seems quite understanding and real but how does vdrift exactly get the engine speed so that the clutch torque function works? Okay well, i'l try to quicly write the code in a sort of minimalistic way to keep it super simple, and tell me what have i missed out? Code:```// The overal transmission ratio (gear ratio + final drive ratio)   ratio = GearRatio[gear] * FinalDriveRatio;   // Here I'm doing a quick blocked differential   driveshaft_speed = (LWheelAvel + RWheelAvel)/2;   // Clutch speed, actually this is the transmission angularvelo...   clutch_speed = driveshaft_speed * ratio;   // Crankshaft Speed, is actually the engine angular velocity   // And this is what confuses me, it's not related to wheels   // But it works some how as good as Clutch Speed + sliping   crankshaft_speed = averageAngularVelo;       // This is where the vdrifts clutch sliping magic happens   // It thakes in both sides (engine & transmission) and   // is modifyed by clutch position.       engine_drag = CalcClutchTorque(crankshaft_speed,clutch_speed);   // engine.ComputeForces();   // This is where the torque calculation is done   // I'll Keep it simple for easyer reading   engineTorque = CalcEngineTorque(RPM)* throttle;           engineFrictionTorque = CalcEngineFriction(RPM);       // ApplyClutchTorque(engine_drag, clutch_speed)   // (From Vdrift: apply forces on the engine due to drag from the clutch)   // I'm not sure why it thakes in clutch_speed...   if ( transmission.GetGear() == 0 )        clutchTorque= 0.0 ;   else        clutchTorque= engine_drag;   // Total Engine Torque (motor torque - friction torque - clutch torque)   // To clear this up, engine total torque Is cranckshaft torque   engineTotalTorque = engineTorque+engineFrictionTorque-clutchTorque;   crankshaftTorque = engineTotalTorque;   // CalculateDriveTorque(drive_torque, engine_drag)   // Now i'm getting the torque back to the wheels throught transmission   transmissionTorque=engine_drag * ratio;   // Since i'm using blocked differential, both wheels   // get the same torque split to two   driveshaftTorque=(transmissionTorque / 2) * FinalDriveRatio;   // And now the final torque is added to the wheels...``` Now what confuses me is that, looking at this code, it looks like the engine_drag is transfered to the wheels normally but i stil dont understand where does the difference come in between cranckshaft & driveshaft speed? Could some one tell me what am i missing? I have been learing car physics for years now and i always get to the point where i simply dont understand how the clutch works... It's logical that when the clutch is Locked the engine speed = driveshaft speed, but if the clutch is sliping & unlocked, then i understand the engine has it's own speed mostly a simple timestep calculation, but torque transfer is the question. Thanks for your time, and i hope some one can explaint me how it's done in vdrift, so i could finally understand it. - NaN - 05-24-2011 Quote:confused learning the whole driveline code in Vdrift Code revision? The clutch is a friction coupling. Only torque is transfered. The clutch torque is a friction torque, actually a torque limit. The clutch torque applied to crankshaft is equal to the torque needed to zero the speed difference between clutch plates(engine_inertia*dw/dt) if clutch friction exceeds it. Else it is equal to clutch friction. I think the clutch in vdrift is actually always slipping. The whole thing is additionally complicated by tire friction. - NaN - 05-24-2011 There are some simplifications. Like solving the components separately, ignoring combined inertia. For a more formal(correct) model: http://www.mathworks.com/products/simulink/demos.html?file=/products/demos/shipping/simulink/sldemo_clutch.html - smr597 - 05-25-2011 hmm, i'm not sure about the always slipping part, since when the car drives normally the "clutch.IsLocked" flag is true, but when i tryed to re build the whole simulation driveline in a simpler way, the tag was always false only few times it flashed true. While following the code i understand that the engine angular velocity is some what switching, if the clutch is locked, the engine angular velo=driveline angular velo, if unlocked, the engine angular velo is a "hack" and not related to car actually? I have looked the simulink page, but it seems more confusing. I understand Vdrifts code more, and i understand the clutch.gettorque function to. It finds the difference between engine and driveline speed and does some torque calculations. But as i sayd the engine speed is some what confusing me... Somebody mentioneed in an older post that the crankshaft(engine) calculations are done in rotational frame, but I havent found a logical explanation. Re: About the driveline basics... - joevenzon - 05-26-2011 smr597 Wrote:i stil dont understand where does the difference come in between cranckshaft & driveshaft speed? Could some one tell me what am i missing? If you look at CARDYNAMICS::UpdateDriveline, it's all right there. The clutch.GetTorque is called with arguments representing the speed of the crankshaft and driveshaft. The crankshaft speed is based on the engine RPM and transmission, the driveshaft speed is based on the wheels' RPM and diff. The resulting torque is applied equally and oppositely to the engine and the driveshaft. - smr597 - 05-26-2011 hmmm, so this way the engien speed and transmission speed are always exual? even if the clutch is ulocked? in real life this should not be true... if the clutch is locked then it's suposed to be true... Damn i'm abit confused - joevenzon - 05-26-2011 No, the speeds aren't equal. I repeat: the crankshaft speed is based on the engine RPM and transmission, the driveshaft speed is based on the wheels' RPM and diff. The clutch takes those two speeds and generates equal and opposite forces on both the engine and driveshaft. Force = mass * acceleration, which means acceleration = force/mass, so the rotational acceleration of the engine and driveshaft will change. That means that with the clutch (even partially) engaged, the speed of the engine and driveshaft will tend toward each other over time, depending any other forces acting on the wheels or engine. - joevenzon - 05-26-2011 Here's an example. This will make a lot of sense if you're familiar with driving a manual transmission car. The clutch is just an adjustable friction device between two rotating shafts. That means that the clutch generates a force proportional to the difference in the speeds of the two shafts. For rotation, force is called torque, but I use them interchangeably here to try to make things simpler, don't get confused. That proportional relationship is the friction coefficient, which is adjustable from zero (clutch fully disengaged) to some value representing the maximum force the clutch can exert (clutch fully engaged). Note that I also refer to the crankshaft as the engine's output AFTER it goes through the transmission, and the driveshaft as the shaft BEFORE the differential. Think for a moment about a situation where the car is stopped, the clutch is disengaged, the transmission is is first gear, and the engine is idling at 1000 RPM. Let's run the clutch update function for this timestep. The driveshaft speed is zero and the crankshaft speed is some number that corresponds to 1000 RPM in first gear. The clutch is disengaged, so even though the input speeds are different, the clutch generates zero force. Nothing changes. Some time later, we abruptly let the clutch pedal out half way. That means the clutch is now partially engaged. Let's run the clutch update function for this timestep. The driveshaft speed is still zero and the crankshaft speed is some number that corresponds to 1000 RPM in first gear. Since the clutch is partially engaged and the input speeds are different, it will return some force. We apply the force to the driveshaft, which causes it to accelerate. We apply an equal but opposite force to the crankshaft, which causes it to decelerate. So, the next timestep, the wheels will have started to very slightly rotate. Also, the engine will have started to very slightly decrease in RPM. If you think about what happens for the next several timesteps, you'll see that the clutch will continue to generate force to speed up the driveshaft and slow down the engine. If we give the engine some gas, it'll exert a force that wants to speed the engine up, and depending on how much gas we give it, this might cancel out the force from the clutch that tries to slow the engine down. As time goes on and the speed difference between the driveshaft and crankshaft gets smaller, less force will be generated by the clutch, which means less acceleration. Eventually we'll probably reach a state where the crankshaft speed and driveshaft speed are the same, and now we can let the clutch all the way out (fully engaged). For VDrift the clutch doesn't actually lock (as NaN mentioned); the only thing that happens is since the clutch is fully engaged, any difference between driveshaft and crankshaft speed will cause very large forces that quickly act to bring their speeds to the same value again. So if you step on the gas with the clutch engaged, the engine will get a huge boost in force from the extra gas, the crankshaft will start going faster than the driveshaft, and this speed difference causes a large force to speed up the wheels and (try to) slow down the engine (but because of the huge force from the extra gas, the engine continues to speed up, just not as fast as it would with the clutch disengaged). Make sense?