#### Archived

This topic is now archived and is closed to further replies.

# RPM and clutches

This topic is 4943 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

How do you calculate the relationship between throttle position and engine speed in neutual (gear(or when clutch is engaged))? As the crank and the wheel are not connected at that state.

##### Share on other sites
Your throttle (along with the current RPMs) sets the engine torque, right? Just have a certain amount of friction in the engine (constant negative torque, with the net torque clipped to zero), and take into account the rotational inertia of the engine, and it''ll automagically sort itself out. Then just tweak your figures until it behaves sorta sensibly.

##### Share on other sites
Without having to step the RPMs as in engine.rpm += 20; How would be the best way to go about it? What I would really like to do is treat it like a tyre and give it an angVel that updates based on throttle, friction and such. However I am relearning math since I''ve been out of school for nearly 10 years now so this is a bit confusing to me.

Sam

##### Share on other sites
ermm... off the top of my head (and not ever actually having done this, so I'm making it up as I go along):
const float ENGINE_DRAG = 30; //Nmconst float ENGINE_IDLE_THROTTLE = 0.1f; //10% of full throttleconst float ENGINE_REVLIMIT = 6500; //RPMconst float ENGINE_REVLIMIT_BOUNCE = 0.05; //5% of max RPMs float NewEngineSpeed(float currentRPM, float maxTorqueAtCurrentRPM,          float engineRotationalInertia, float throttle, float timestep){    Clip(throttle, ENGINE_IDLE_THROTTLE, 1.0f);    float curTorque = maxTorqueAtCurrentRPM * throttle;    float curAngularVel = curRPM * TWOPI / 60; //radians/sec    //subtract engine drag from current torque.    curTorque -= ENGINE_DRAG;    //accelerate engine using the current torque    curAngularVel += curTorque / engineRotationalInertia * timestep;    //make sure our drag didn't make our engine start to go backwards :)    if (curAngularVel < 0) curAngularVel = 0;    //return the new value    curRPM = curAngularVel * 60 / TWOPI; //RPM    if (curRPM > ENGINE_REVLIMIT)        curRPM = ENGINE_REVLIMIT - ((float)rand() / MAX_RAND)            * ENGINE_REVLIMIT * ENGINE_REVLIMIT_BOUNCE;    return curRPM;}

Hmm... is 1.0f a magic number, since it's not an int?

[edit: added in rev limiter (with throttle bouncing off revlimiter quasirealistically) and fixed some formatting. Oh wonderful staff people, can we please have the crlf-to-<br> automagic conversion work for all crlfs in source? otherwise extra lines get omitted]

[edit again: ok, cut that, can we just have a 'preview' button? ]

[edited by - fractoid on May 29, 2004 5:28:02 AM]

##### Share on other sites
I wish I were as knowledgeable as you at this stuff, you rock! Now all I must do is take the curRPM and apply it to the rest of the drive train once I shift into gear.

##### Share on other sites
this looks like a good idea

http://www.gamedev.net/community/forums/topic.asp?topic_id=224910

implementing the engine and drive train+wheels as separate flywheel bodies, and the clutch connection would pass only a fraction of the torque to and from the engine.

##### Share on other sites
There is a trick in simulating drivetrain in this way oliii.
Firstly, your clutch may be engaged, and then this all work as if would be one rotating object, but when the clutch slips, it''s two rotating object. This should be solved properly.

In my new model I am working on I will inculde this too.
Obtainchi: if you haven''t tried my carsim yet, then see my profile for the URL if you are interested in it.

##### Share on other sites
Ok, so in order for me to get the total rpms of the car, I'll need the angVel of the engine, the angVel of the drive wheels and get the sum of those two values fading from one to another based on clutch factor?

*edit*
Ok, Im just plain ignorant I suppose and I can find anything on how the two should go together to get the final rpm.

@ szinkopa
I tried your sim a while back, things seem in order but I dont think tyre traction feels right..

[edited by - Obtainchi on May 30, 2004 3:52:51 AM]

##### Share on other sites
quote:
Ok, so in order for me to get the total rpms of the car, I''ll need the angVel of the engine, the angVel of the drive wheels and get the sum of those two values fading from one to another based on clutch factor?

I guess that would be a simple solution. Well worth a try.
Unless you want to go into detailed physics, with modelling the clutch/drivetrain with proper dynamics, like for tyres (clutch slip, friction forces, maybe even hydraulics pressure . very complex in my opinion for what it''s worth, but you''d get things like engine struggling to keep the revs up and transmission rattles more accurately).

If you think about it, that''s what a clutch is for. to ease the transition between the transmission and the engine, so they all sing the same song. you can then model the limited slip differentials in a sort of similar way. It can be as complex as you want, and I think the integration to do it that way would have to be very accurate (not just a simple euler).

I''d have a look at www.racer.nl, they must have something in their tech documents about that sort of stuff, since they strive on producing a very accurate, very complex car model.

##### Share on other sites
Yeah, I have been in and out of the source there just to get an idea of how Rudd is doing it but the code is so messy lol..

The only real reason I need a clutch is for rev'ing at the start of the race and switching into gear at the high rpm and being able to convert the rpms from the rev to engine torque. Im not looking for super real physics but a real enough feel to get by with since its only drag racing.

[edited by - Obtainchi on May 30, 2004 6:12:21 AM]

##### Share on other sites
Yes, Obtainchi, the traction is not the best, I think my car setup is not too good, and that is the main reason of the car's behaviour. Now I have increased the inertia of the car, and it's a lot better. And the tyres are quite sensitive for any steering, like in reality, so the best way would be to use steering wheel, not keyboard. IMO it would be even better then.

And do you have something demolike stuff?

[edited by - szinkopa on May 30, 2004 10:19:17 AM]

##### Share on other sites
quote:
Original post by Obtainchi
Yeah, I have been in and out of the source there just to get an idea of how Rudd is doing it but the code is so messy lol..

The only real reason I need a clutch is for rev''ing at the start of the race and switching into gear at the high rpm and being able to convert the rpms from the rev to engine torque. Im not looking for super real physics but a real enough feel to get by with since its only drag racing.

in that case, I''d really try out a simple solution like discussed here. apply a percentage of the torque from the engine to the gear box, and return a fraction of the gear box RPM to the engine, then blend that RPM with a computed RPM for the engine, like when it''s in neutral and you are revving the car. That would be a simple friction_torque/engine_torque -> angular acceleration -> angular velocity. Or simply set a target RPM from the throttle input, and increase/decrease the current RPM to achieve that target RPM.

##### Share on other sites
Well the game I am working on is using the Torque Engine (www.garagegames.com) so it already has rigid bodies and suspension in there I am just going through it all and attempting to make it better. As soon as I find a modeler to start on the cars and a soul to do interior objects I'll start releasing some beta versions.

[edited by - Obtainchi on May 30, 2004 10:01:15 PM]

##### Share on other sites
I think that besides the mechanical friction in the engine, there are two other things involved in determining RPM for a certain throttle position.

Firstly, as the engine is revving up, it will be more and more difficult for the engine to suck in all the air (through the air intake manifold). So more and more energy will be spent trying to get the air in.
iirc the camshafts also have something to do with this, because the valves cannot open and close fast enough anymore at high revs.

Second, as a consequence of the above, as the revs get higher the fill rate (not talking about 3d hardware here... lol) of the engine gets lower. Because it cannot suck in all the air it wants anymore. So this means less mixture will be burned -> less torque.

These things combined:
- mechanical friction
- "aerodynamical friction" (getting the air into the engine)
- drop in torque as result of less mixture in engine
probably determine the relationship between throttle position and revs.
I''m not sure how each one should be calculated. I think mechanical friction is linear ??
The aerodynamical maybe quadratic ?? (like air drag)
And for the torque, you can look up torque graphs for real life cars. (alot of cars have them in there technical specifications).

##### Share on other sites
Modelling the air intake into the engine would not only be complicated, but probably wouldnt even give you the results you wanted.
I've been thinking of attempting something like it, but I dont even know if I'll get a satisfactory result for all the effort I would have to put in.
Some of the things that have floated through my mind include:
mechanical friction is effected by the velocity of the piston, so you would need the stroke and RPM to determine this. There is also friction in the valve train, which could be made linear with RPM.
Friction in the (air) system (say inlet, and exhaust) is determined by
a) smoothness of the surfaces
b) velocity of the air
velocity of the air is determined by the volumetric flow rate of air and the diameter of the piping.
There is pressure outside (atmospheric, 14.7psi) and a low pressure in the pistons, nearly 0 psi. You can then use the energy equation to find a flow rate through the pipe and into the engine. Hopefully it works out somewhere around 80-95% volumetric efficiency.
Note that there is an interesting problem, in the cfm depends on friction, and friction depends on cfm.
The actual air in the engine determines power made. You need ~14:1 ratio of air and fuel. I don't know enough chemistry to figure out the pressure of the air in the cyclinder after it is ingited, and therefor the force on the piston, and torque on the crank.
I guess you could model the fuel system as well, so a lean mixture makes it heat up, and a rich one makes it so the engine needs to move a fluid with a higher specific weight out the exhaust portion (unburnt fuel).

The point of my rambling? Make your own torque curve and scale it by throttle %.

Some basic equations if anyone really wants to try this:
hf = f(Le * V^2)/(D * 2gravity)
hf is the head lost in a fluid system due to friction and its in feet, or meters, etc. (as in feet of water, or inches of mercury) f is a coeff which comes from Renaulds number and a 'roughness factor' of the pipe. Re = Diamter*velocity / viscosity (i think dynamic)
the roughness factor is e/d, the e you find on a chart for different materials, and the d is the diamter. Once you have RE and e/d you look up 'f' on a chart.
the 'Le' is equivalent length. It means the length of the whole system if it were straight pipe. Things like elbows, sharp edges, valves, etc, may be 10ft of pipe even though they occupy only a few inches of space. V^2 is velocity^2.

So..yeah... its ALOT of things.

[edited by - CombatWombat on May 30, 2004 11:42:32 PM]

##### Share on other sites
Obtainchi:
Has Torque Engine only suspension model from car dynamics? Nothing else, like tyre model?
And I tried to get a demo from a car sim example on their site, but I could not find a link to get it. Is it available? I am interested
Anyway based on the rating it does not seem very good.

[edited by - szinkopa on May 31, 2004 9:09:10 AM]

##### Share on other sites
Now I know why I always drive automatics.

##### Share on other sites
Etnu:
How doyou mean that?

##### Share on other sites
@ szinkopa,
Yes the vehicles in the engine are complete and work very well, they are using a rigid body system too, and RK4 collision I believe. The demo can be found here.
http://www.garagegames.com/pg/demo.php?id=1

##### Share on other sites
Obtainchi:
The engine seem to be very good. I played a while with their carsim, and I have to say that only the suspension is acceptable. But I suspect there are a lot of simplification in it, for example I did not notice that the camber angle changed. However this is true for such a McPherson. So it''s rather spectacular than accurate, I think. But it can be fun to use

##### Share on other sites
Take a seat (or glare at me and walk out of the thread) - Professor Fractoid is about to lecture.

If your next bit is getting it all working when you change into gear, I''d say a little logical reorganization is in order (unless you got there ahead of me, of course).

The way I''d do it is break up the system logically into a set of components. Each component has an input shaft and an output shaft. The output shaft of one component is connected to the input shaft of the next by a coupling, which has various parameters (maximum torque transmitted before slippage, maximum RPM, etc.) which determine how the input energy is transferred. Then you simply build the drivetrain of your car, in software. Like:

(engine) -> (clutch coupling) -> (gearbox) -> (simple coupling) -> (differential) -> (simple coupling) -> (wheels)

So your engine is a free standing unit. All it knows about is its inputs (throttle, manifold pressure, fuel pressure, as complex or simple as you like) and its output (a single shaft, spinning at X rpm). For the simulation to be physically realistic I''d model the engine as a rotating mass attached to its output shaft, with some drag on it to simulate internal friction and a magical torque force applied to simulate actual engine power generation. The clutch is a simple system that transmits x% of its input torque to its output torque, and vice versa - you probably don''t have to worry about modelling clutch rotating mass etc. because clutches don''t weigh that much. The gearbox converts input torque to output torque based on its current gear ratio.

When you get to the wheels, that''s when it gets interesting. You need to calculate the torque on the wheels by taking into account (a) the torque applied by the axles, and (b) the frictional force on the road. It''d probably be wise to get someone who''s done engineering dynamics more recently than I to help you out from this point on...

Best way to learn how to do this stuff is get a kinematics/dynamics textbook out of a library and work through it. Learn how to use free body diagrams, and every problem becomes the simple (heh right) matter of dividing the system up into appropriate free bodies.

##### Share on other sites
The complicated part in the system above..is that the wheels send a torque opposite the engine output back through the system.
This is a problem because if you just send torques to each coupling, the RPM will not match what it should. (IE: if your gearbox has a 3:1 ratio, you want the input shaft spinning 3x the output shaft). If you send your 400lbf-ft from the engine, and -300lbf-ft from the wheels, suddenly you''ll find your transmission output is spinning backwards, the engine is going forewards, and everything eventually goes haywire.
Moral of the story: you need to find some way to take RPM or angular momentum into account.

• ### Forum Statistics

• Total Topics
628694
• Total Posts
2984253

• 16
• 13
• 13
• 10
• 10