Engines – Part one

Be they two-stroke, four-stroke, diesel or rotary, internal combustion engines all work on the same principle:  Fuel and air can be made to combust.  Doing so causes rapid expansion of the resulting gasses.  This expansion of gasses is “mechanically contained” in a combustion chamber in such a way that the energy from it is used to turn a crankshaft.

Rotary engines are dissimilar enough to require their own discussion, so if these are of interest to you, then I recommend you look elsewhere.  The other types of engines mentioned, all feature a piston attached to the crankshaft via a conrod travelling up and down inside a cylinder.

When the fuel-air mixture is ignited the piston is at the top of its stroke and the gasses expand, forcing the piston down.  This is the “power stroke”.   The distance the piston travels from the top of its stroke to the bottom, is measured and referred to (rather unimaginatively)  as the engine’s “stroke”.  The diameter of the cylinder in which the piston travels is measured and called the “bore” size.

Together, the bore and stroke of an engine are used to define the engine capacity.  The volume of the cylinder , which has the diameter of the bore, and the height of the stroke, gives you the capacity of a single cylinder.  Multiply this figure by the number of cylinders in the engine and you have the total engine capacity.

If a four cylinder engine has a bore of 74mm and a stroke of 58mm…
For those of you who do not remember:
V = π * r ² * height.
The radius is 3.7cm (half the bore) and the height is 5.8cm.
Using the formula, a single cylinder, has a capacity of 249.45 cubic centimetres (cc).
Multiply this by the number of cylinders and you end up with a 997.8cc engine.

As a piston travels up and down inside a cylinder, it must come to a complete stop and change direction.  Arresting and reversing the piston’s momentum takes energy.  The faster the piston is travelling, and the heavier the piston is, the more energy is required.  This energy is supplied by the momentum of the crankshaft.  This means that some of the engine’s output is spent  in changing the velocity of the piston.  For this reason, there tends to be an optimum speed at which the piston travels.  The longer the stroke of an engine, the further the piston travels.  So, in an engine with a long stroke, the piston travels faster at a given crankshaft speed than in an engine with a short stroke.  As a rule of thumb:  the longer the stroke of an engine, the slower the maximum revolutions per minute (RPM).

There is no ideal size for an engine bore or stroke.  A lot depends on what the engine is powering.   Engines that need to move a lot of weight, require more torque.

Torque is a twisting force applied to an object, like a wheel or a crankshaft.   For our purposes, we will consider that torque is measured in pounds-force feet (lbf-ft) meaning the equivalent of a given force, in pounds, acting on the end of a lever of length in feet. … For example, standing with 180 pounds body weight on a lug wrench one foot long yields 180 lbf-ft of torque.

Work is the application of force over a distance. Unfortunately, the units used are the same (pounds times feet) but we write this as ft-lb just to distinguish it. The real difference is that in this case, the “feet” part means feet of movement.

Power is the application of work within a finite time. 550 ft-lb of work in one second is one horsepower.

From this, we can see that torque and power are related.  In fact:

hp = (torque * RPM) / 5250
(Where torque is measured in lbf-ft)

Another rule of thumb is that: engines with a longer stroke produce more torque.  There are other factors that influence power and torque outputs of an engine.  Cubic capacity never goes astray when you need more power and torque…

A motorcycle does not need to shift a vast amount of mass – but tends to be size constrained.  (unless of course, you are prepared to just jam in a big car engine)

More weight conscious sports bikes tend to concentrate on obtaining a high power figure, over obtaining a high torque figure.  Given the formula above, we can see that to produce more power, we either need more torque or more engine revs.  So, sports bikes tend to concentrate on producing power by spinning quickly, which means they end up having a short stroke.

Getting the fuel-air mixture into the combustion chamber also affects power and torque figures of an engine, but that is a story for another time.

Say “No” to Band-aids!

Sooner or later, there will be a need to fix bugs in whatever software you work on.  How long it takes to fix a bug tends to be non-deterministic.  Some bugs will be easy to fix, and others not so.  Unfortunately, bug fixes on commercial software are often done the wrong way – under the guise of being done quickly.  The “band-aid fix” is the wrong way of fixing a problem.  The metaphor of the “band-aid fix” extends beyond the software industry, but I.T. has turned it into a real art-form.

At the heart of a lot of band-aid fixes is the notion that you can fix a problem without really knowing what the problem is.  Commercial reality may well prevent a code base from being perfect, but the more band-aids that are applied to the code, the worse the software becomes to work on.

There may be a genuine need to apply a band-aid fix to code.  When there is a real financial loss or damage to customers’ data, expediting a fix is understandable.  Removing this kludged fix should be given a high priority.  It is important to recognise that the band-aid won’t continue to hold a large wound together!  If you do not remove the band-aid and perform proper surgery, the wound will rot.  Once you allow the code to start “rotting”, it becomes difficult to arrest this negative momentum.  It damages the maintainability of the code and encourages other programmers to act irresponsibly too.  It is difficult to put enough emphasis on this point.

Depending on the culture in the workplace, it can be easy to dismiss fixing “less than ideal” code.  Studies have shown how counter-productive poorly maintained code is on development productivity.  I have yet to work with someone in the software industry that would disagree with that thought. Yet barriers are still erected that prevent acting upon it.  There is a vicious circle alive and well in parts of the software industry:

  • Code is recognised to be poorly maintained.
  • Poorly maintained code is recognised to hinder productivity
  • People are too busy to fix old code.

I cannot believe people do not see the irony with this!  Allowing software to get in to this vicious circle is the first mistake.  Programmers need to promote the culture that refactoring is not a luxury, but a necessity.  Allowing some refactoring time on all development work can avoid the problem in the first place.  Digging your software out of the hole created by the vicious circle is altogether a more expensive proposition.  Not refactoring the code at all is even worse!
The idea that refactoring time needs to be allocated with development time appears to imply that you will not be able to push out new features as quickly.  At a superficial level, this is true enough.  Over the lifetime of the code base, this argument would not hold up.  The neater and more maintainable the code base, the quicker it is to perform work on.  In other words, good code is easier to add features to.

The biggest problem I see with a “band-aid” fix is simply that it is not a fix at all!  It cures a symptom in rather the same way that pain-killers can stop broken legs from hurting.  It masks the issue – but it does not mean you’re right to walk home! Masking problems in software, just makes them harder to track down.  Software can be complex enough for one bug to be at the root of several problems. If you only mask the problem, you never know where else the bug will show up

Off Road

I have an admission to make.  I have been riding motorcycles for over sixteen years and (at a rough guess) around a quarter of a million kilometres.  I have ridden many different bikes and also raced motorcycles at a club level.  My admission is, until the last few days I had never ridden a dirt bike.  Thanks to my brother-in-laws, this is now something I can add to my riding experiences.

Unlike some other road-riders, I was under no false-illusion as to what I would be like on dirt.  Apart from knowing what controls did what, my experience counted for little when it came to riding dirt.  These days I try to avoid taking road bikes on dirt roads.  I have got all the excuses under the sun as to why, such as: A lot of modern bikes have become too “single-purpose” to do dirt roads well / The big wide tyres of a road bike tend to skate around on a dirt surface / It takes ages to clean them afterward.  Basically, I would rather just try and avoid it.

The one warning I continually got about riding dirt bikes was that you just can’t grab the front brakes to stop.  This well may be true, but used correctly, the front brake is very useful.  Maybe some road riders tend to be more boisterous with front brake application than I am, because after some time I became more relaxed with using the front brake.

As for my actual riding on the dirt, I was predictably crap to start off with.  My road-riding bias meant I was unable to comprehend how the long travelling suspension of the bike could handle the deep ruts in the track as well as they could.  I had a couple of low speed “step-offs” when dealing with steep and rutted four-wheel drive tracks (both uphill and down) In retrospect, it was my lack of speed that got me in trouble far more than going too quickly.  I don’t think I have ever had the attitude of being ten foot tall and bullet-proof and going faster in a situation where I didn’t feel in control was the furthest thing from my mind.

I did see noticeable improvement in my riding as the day wore on and finished the day with some descents and a hill climb that I was proud of – whilst still being acutely aware of how remarkably simple they would be to someone with more riding experience.   Despite slowing them down, my riding companions patiently waited for me and offered encouragement.  I would have loved a few more riding tips, but they probably did the right thing by not overloading me with information to try and apply.

My faithful bike for the day was a Suzuki DRZ400 – complete with electric start. (A feature I was quite thankful for!) The torque of the 400 single cylinder meant it would chug along quite happily when I left it in a gear that was too high for the situation.  More accomplished dirt riders may have found some fault with the bike, but to me it seemed just about perfect!

I doubt my single day’s ride has made me a better road rider.  I don’t think I reached any great levels of competence from my day in the saddle, but it was great fun and a real eye-opener for me.  Whilst I am not about to rush out and buy a trail bike for myself, it has gone on that list of things I want to do again some time.  When “some time” arises, hopefully I will have remembered what little skills I have gained and forgotten how stiff and sore my legs were the next couple of days after the ride!