December 18, 2009

4 - pack ABS - The ones your car has!!

Now that from a few posts we have discussed only "C" I thought this time will get back to some automotive basics.
Topic this time is Vehicle stability and we will towards the end talk a bit about ABS.
The vehicle undergoes various kinds of forces when it is in motion. We will talk about stability when in motion in this post. The simplest to understand is horizontal forces. i.e when the car moves forward then there is Pseudo-Force that acts backwards ( which makes the driver go backwards when the car moves forward). This force acts in the opposite direction on braking. That is the reason the front of the car will dip when we brake hard. Now assuming that you are going on a straight road when you brake the wheels will reduce their speed continuously till they come to stand still. Here there are some concepts that we need to understand.
  1. Why does the car move forward when the wheels turn? - The answer to this lies in friction. If there was no friction, there was no reason for the car to move forward. So who is really driving the car ahead....well it is the friction force. If the wheel moves too fast then it tends to slip. This is because the surface friction cannot keep up. This means when you have low friction, the best thing to do is to let your wheels spin slowly rather than fast. Why Slow?  The force acting at the point of contact is proportional to the wheel speed. So footing the accelerator always doesn't mean more speed.
  2. What happens when we brake ? - The brakes when engaged bring down the speed of the wheel. This means we are reducing the force at the point of contact. In which the surface will offer us lesser friction force. This means that our vehicle will slow down. However, when will we start slipping? This will occur if the rest of the body of the car is still much faster ....and that drags our wheels. This situation worsens when the brakes are jammed hard and the wheels lock. After the lock the friction equation changes. From Rolling friction it changes to sliding friction. This sliding motion will reduce/ remove the steer-ability. Once the steering capability is lost all that will happen is that the vehicle will move in the direction of the force it had when the tires are locked. 
  3. Other Problems ? - The brakes work quite great when we are on a straight road. However, when we brake when we are on a curve we have to worry about other forms of forces apart from horizontal. They are the lateral forces that tend to push the car in other directions than the one intended by the driver. This however, is not controlled by having a ABS.
Yeah, finally we are talking about the ABS. The ABS or the Anti Lock Braking systems will help a lot in number (2) above. It will ensure that the wheels never are locked. This helps in the following ways
  • Wheels are not locked so you can steer the vehicle till the last minute.
  • Wheels are braked and released at very fast rate which means that the wheels are approximately maintained at a point where they get maximum braking efficiency ( approx 20 -30 % slip). This happens because the wheels have more friction when they are rolling then when they are slipping. However, this makes you wonder if slip has lesser resistance then why not make my vehicle slip all the while. That would have been a good idea if the area's of contact while slipping and rolling where the same. Since they are not in effect under normal circumstances the slipping tyre would give you a lot more resistance. Also we got to think about the life of the tyre. However, when we are braking this works better to have the tyre rolling rather than slipping.
  • If you have 4 way ABS system ( lucky you) then each wheel can be individually controlled to ensure best braking force through the 4 wheels so that the vehicle can be stopped easily even on ยต-Split surfaces too. Btw, 4 way ABS means that each tyre has a wheelspeed sensor and has a control valve that can be controlled to lock or unlock the brakes. 3 way ones have front 2 wheels individual and rear wheel both have a single control valve.
Ok i will stop here to take  a breather. More later.
Please leave your comment. You can subscribe to this blog by using the links under "Subscribe" section.


December 5, 2009

Preprocessor -Coding myth 4

There is this classic case which came as a surprise to me when a fairly senior member of my team started arguing with me about a particular implementation that had made....below is the case
#define BusClock ((Crystal_Frequency)/(Prescalar))

Now the argument was ...why was i not calculating manually and typing in the values.
Our Dude Says >> See Macros will be just replaced by the compiler so when you load it into the register like this

BCLK = BusClock;

then there will be more run time due to the division of crystal freq by prescalar.
Well this is totally wrong. There are parts of the statement which are correct and which are wrong.
Correct parts >> Macro's will be dumbly replaced ( not by the compiler but by the preprocessor).
Which means that when my code goes to the compiler it looks like this
BCLK = 600000/12;
where cystal is 6Mhz and Prescalar is 12.
Does that mean it will go to the assembler in the same way....No!! and that is the wrong part.
As a part of basic optimization the compiler will be clever enough to do this division of 600000/12 and feed the appropriate value into BCLK. which means actually it looks like
BCLK = 50000;
before anything meaningful really begins.
In most compilers this cannot be turned off and is a basic optimisation. Infact, I have known a compiler that had a problem when we gave too big numbers. It would just give some gibberish error.

So the basic rule is that ...
If the compiler has all the information that it needs to create a single number ( after as many operations ...like 1+(10000)*12/(53) etc...) it will do it on its own to give a nearest number. Note that these divisions and multiplications are Integer unless you explicitly tell the compiler that they are double. So based on how you choose the values you might end up with varying results.

If anyone knows of a compiler that doesn't do that, please enlighten me...
Please leave your comment. You can subscribe to this blog by using the links under "Subscribe" section.


Powered by ScribeFire.