<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:blogger='http://schemas.google.com/blogger/2008' xmlns:georss='http://www.georss.org/georss' xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-1907071224335910840</id><updated>2024-10-24T15:07:33.394+05:30</updated><category term="Info"/><category term="Automotive"/><category term="Embedded Software"/><category term="funda"/><category term="Basic"/><category term="Intermediate"/><category term="C coding"/><category term="Powertrain"/><category term="Gadget"/><category term="Geek"/><category term="Embedded Hardware"/><category term="Technology"/><category term="Images"/><category term="Matlab"/><category term="Tools"/><category term="Transmission"/><category term="Trucks"/><category term="Wow"/><title type='text'>Electronica</title><subtitle type='html'>An attempt to provide some embedded systems concepts for newbies and techies alike</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://embeddedlive.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1907071224335910840/posts/default'/><link rel='alternate' type='text/html' href='http://embeddedlive.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><link rel='next' type='application/atom+xml' href='http://www.blogger.com/feeds/1907071224335910840/posts/default?start-index=26&amp;max-results=25'/><author><name>Deepz</name><uri>http://www.blogger.com/profile/16543298327846220464</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>37</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-1907071224335910840.post-7698958887993397187</id><published>2014-09-14T15:53:00.000+05:30</published><updated>2014-09-14T15:53:00.010+05:30</updated><title type='text'>Perils of the start stop system</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;span style=&quot;font-family: Trebuchet MS, sans-serif;&quot;&gt;Today after a long time i am posting on this blog. The reason is simple...I just noticed that the number of visits to the technical blog have been far more compared to the other &quot;time pass&quot; blog that i write even though the technical one has had just &amp;nbsp;30 odd blog posts. I thought, let me rekindle the technical fire and write a few things about software, automotive and sorts.&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Trebuchet MS, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Trebuchet MS, sans-serif;&quot;&gt;I also thought that it would be quite a joke if i re-write what is already written in numerous websites and re-iterate the same story again. However, i would still do it if i think i can explain things in a simpler or shorter way. In the meanwhile, for those of who who do not follow my other &quot;timepass&quot; blog, i just moved to Germany, the land of innovation. This would also give me with some more additional time to do stuff which i would have missed because of lack of time and interest when i was in India. However, there are also quite a big bunch of new responsiblities that one has to take into consideration when he moves to a new country. This is not just doing all kinds of registrations and getting your papers in order but also adjusting to the culture and lifestyle of the place.&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Trebuchet MS, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Trebuchet MS, sans-serif;&quot;&gt;Today, i would be talking a bit about engine start-stop or MSS as Merc&#39;s would call it. In India most of us would have experienced that the bus drivers and the auto-rickshaw drivers turn of the engine at the red traffic lights when they have to wait. Normally this is done in order to save fuel and get better milage figures. In Europe most premium cars do offer start-stop as a default fitting. At BMW all cars come with an automatic start stop. How does this work?&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: Trebuchet MS, sans-serif;&quot;&gt;In a manual transmission you would stop the car, switch to neutral and brake. This would be then used by the software as the trigger to cut off the engine. In an auto transmission though you would have to keep the brake depressed while the transmission is still set to &quot;D&quot; position. Although to the user this would seem quite a simple function because even an uneducated indian autodriver can do this, for the software it is quite a challenge.&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Trebuchet MS, sans-serif;&quot;&gt;The challenge poses itself as two questions:&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Trebuchet MS, sans-serif;&quot;&gt;1. When should the engine be cut off ?&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Trebuchet MS, sans-serif;&quot;&gt;2. When should the engine be started again ?&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Trebuchet MS, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Trebuchet MS, sans-serif;&quot;&gt;The first question translates to a list of sub questions the answers of which are evaluated by the software to decide if the engine can really be switched off. Some of them are here...you could think of some more and leave them in the comments.&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;&lt;span style=&quot;font-family: Trebuchet MS, sans-serif;&quot;&gt;In an automatic, is the brake depressed above a threshold?&amp;nbsp;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style=&quot;font-family: Trebuchet MS, sans-serif;&quot;&gt;Is the gear still in &quot;D&quot; when the driver stopped the car. i.e. He stopped it when it was running.&amp;nbsp;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style=&quot;font-family: Trebuchet MS, sans-serif;&quot;&gt;Is the door closed? . If the door is opened, mostly the driver wants to get out and in that case it is better to turn on the engine and let him know that he should safely lock the vehicle before he exits.&amp;nbsp;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style=&quot;font-family: Trebuchet MS, sans-serif;&quot;&gt;Is the engine too warm or too cold? In which case it would either need the coolant pump to cool the engine and if too cold would need to run to reach operational temperature. Especially with turbocharged engines, it would still make sense to run the oil pump a couple of more seconds to ensure that the bearings are still lubricated as the turbo charger speed drops down. Note that unlike the engine, the turbocharger may quickly reach rpm&#39;s in 30,000 and above range. Some of the high end turbo&#39;s may be spinning at 60,000 and above at higher loads.&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Trebuchet MS, sans-serif;&quot;&gt;The second question is not just the opposite of the first one though in some cases it is . Again, this translates into its set of sub questions.&amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;&lt;span style=&quot;font-family: Trebuchet MS, sans-serif;&quot;&gt;Has the passenger compartment temperature dropped too low or is it too high, in which case the air conditioning might need to be turned on which would need the engine to run in some cases.&amp;nbsp;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style=&quot;font-family: Trebuchet MS, sans-serif;&quot;&gt;Is the brake booster pressure too low, in which case the engine needs to be turned on to generate the pressure.&amp;nbsp;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style=&quot;font-family: Trebuchet MS, sans-serif;&quot;&gt;Has the driver changed the gear lever position from &quot;D&quot; to say &quot; R&quot;. In which case the engine needs to be started to change the solenoid positions in the gearbox.&amp;nbsp;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style=&quot;font-family: Trebuchet MS, sans-serif;&quot;&gt;Has the brake been released?&amp;nbsp;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style=&quot;font-family: Trebuchet MS, sans-serif;&quot;&gt;Is there a demand by the battery with a charging request.&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Trebuchet MS, sans-serif;&quot;&gt;In the end what looks like a very simple functionality to the driver and most likely for which he isn&#39;t going to pay a lot...the software really has to work a lot to be able to give the right kind of user experience. You wouldn&#39;t want the car to start when you honk for example and at the same time, you would want the car to start as soon as possible when you step on the gas after the red goes orange.&amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Trebuchet MS, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: Trebuchet MS, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Trebuchet MS, sans-serif;&quot;&gt;Please leave your comment if you have one. You can subscribe to this blog by using the links under &quot;Subscribe to&quot;&lt;/span&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://embeddedlive.blogspot.com/feeds/7698958887993397187/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://embeddedlive.blogspot.com/2014/09/perils-of-start-stop-system.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1907071224335910840/posts/default/7698958887993397187'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1907071224335910840/posts/default/7698958887993397187'/><link rel='alternate' type='text/html' href='http://embeddedlive.blogspot.com/2014/09/perils-of-start-stop-system.html' title='Perils of the start stop system'/><author><name>Deepz</name><uri>http://www.blogger.com/profile/16543298327846220464</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1907071224335910840.post-6492669747961778884</id><published>2010-05-10T20:46:00.001+05:30</published><updated>2010-05-10T20:46:53.905+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="Automotive"/><category scheme="http://www.blogger.com/atom/ns#" term="Basic"/><category scheme="http://www.blogger.com/atom/ns#" term="funda"/><category scheme="http://www.blogger.com/atom/ns#" term="Info"/><category scheme="http://www.blogger.com/atom/ns#" term="Transmission"/><title type='text'>Auto Transmission - I</title><content type='html'>&lt;div xmlns=&#39;http://www.w3.org/1999/xhtml&#39;&gt;&lt;div align=&#39;justify&#39;&gt;With the advent of technology man has always asked for better systems to lower his efforts in doing things. The same story goes for Transmissions. Manual transmission served the purpose very well. However, soon the customer demands became higher and he wanted a system that could change gears on its own. No one wanted the clutch anymore!! Well atleast not the folks who always tended to over the engine by downshifting too early or lead the vehicle to stall by upshifting too early. This lead designers to come up with a system in which the clutch pedal could be totally eliminated. There were lot of solutions and some have been described here. Unfortunately, i dont know the order of their evolution but guess that that is not really all that interesting...&lt;br/&gt;Lets take the case of the simple Hero puch or the TVS 50.....Can we call it an automatic transmission....? &lt;br/&gt;Not really...however to some extent yes. &lt;br/&gt;&lt;b&gt;How does based on throttle the vehicle start moving?&lt;/b&gt;&lt;br/&gt;This is because of a clutch that engages as the RPM increases. Such a clutch is called Centrifugal Clutch. Normally the clutch is disengaged. Which means that no power from the engine will be fed to the chain drive. However as the RPM increases a certain threshold the clutch engages. With the clutch engaging the power is transferred to the wheels. This is a very basic of how we can eliminate the manual clutch ( our initial aim ....). As it is clear that the centrifugal clutch will wear out with time and that means RPM points at which the power will get transferred to you chain drive will vary with time. The second disadvantage is that this method cannot transfer huge amount of torque from the engine shaft to the output shaft. I am not really using the term Transmission shaft because this is not a &quot;Transmisison&quot; in classical sense.&lt;br/&gt;&lt;b&gt;What are the other methods?&lt;/b&gt;&lt;br/&gt;How about Kinetic Honda that has been ruling the roads since i was a kid?&lt;br/&gt;Well a Kinetic Honda uses a different mechanism. It uses what is known as a belt drive...( atleast that is what i was told. I am not 100% sure!!). This is fed to a Stepped pulley or Coned Pulley. This coned pulley will be able to provided different Pulley Ratios based on which point of the pulley is used to Tap the output. A the most broad end of the pulley the Torque transmission will be less and a the thinnest end of the pulley the Torque transmission maximum. Centrifugal clutch is still used here. &lt;br/&gt;&lt;b&gt;Does that mean CVT ( The stuff we talk ed about...Continuous Variable Transmission) is a cheap and dirty technology?&lt;/b&gt;&lt;br/&gt;No absolutely not. Like any other technology based on how much complexity is added one can make the system very sophisticated. The commonly used CVT&#39;s in bikes like Honda Activa, Honda Dio, Kinetec etc are fairly simple. However, some really complicated stuff from &lt;a href=&#39;http://www.audiworld.com/news/99/multitronic/content.shtml&#39; target=&#39;_blank&#39;&gt;Audi can be found here &lt;/a&gt;and remember the core is still same....a coned pulley...&lt;br/&gt;&lt;br/&gt;After taking care of these two aspects...i.e. some kind of autoclutch and a automatically shifting gearbox the other biggest challenge was to ensure that high amounts of torques are transmitted through the shafts. When you talk of cars like Mercedes, BMW&#39;s and high end Maybach&#39;s Torque can touch much more than 100 Nm&#39;s. 12 cylinders V&#39;s could not be &quot;Auto-Transmitted&quot; using a simple or complicated CVT...&lt;br/&gt;&lt;br/&gt;Something new was needed...and that will be apart of the next blog ofcourse :P&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;&lt;/div&gt;&lt;br/&gt;&lt;br/&gt;&lt;div class=&#39;zemanta-pixie&#39;&gt;&lt;img src=&#39;http://img.zemanta.com/pixy.gif?x-id=899d8498-9505-881c-9cbb-be4512f7cc45&#39; alt=&#39;&#39; class=&#39;zemanta-pixie-img&#39;/&gt;&lt;/div&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://embeddedlive.blogspot.com/feeds/6492669747961778884/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://embeddedlive.blogspot.com/2010/05/auto-transmission-i.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1907071224335910840/posts/default/6492669747961778884'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1907071224335910840/posts/default/6492669747961778884'/><link rel='alternate' type='text/html' href='http://embeddedlive.blogspot.com/2010/05/auto-transmission-i.html' title='Auto Transmission - I'/><author><name>Deepz</name><uri>http://www.blogger.com/profile/16543298327846220464</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1907071224335910840.post-6683359289537588805</id><published>2010-04-11T15:27:00.001+05:30</published><updated>2010-04-11T15:27:50.367+05:30</updated><title type='text'>Tansmissions &amp;amp; Gears</title><content type='html'>&lt;div xmlns=&#39;http://www.w3.org/1999/xhtml&#39;&gt;Well long break i would say before i wrote something on my this blog....the other one still gets my attention at times. However, the reason for that was lack of time and also lack of interest i could garner from my readers. However, looks like i want to try again and give it one more shot to make this blog useful enough to folks in order to get some interest from them. &lt;br/&gt;The topic for today is &quot;Transmissions&quot;&lt;br/&gt;&lt;b&gt;Why do we need a transmission...or do we need one?&lt;/b&gt;&lt;br/&gt;Frankly we would not need one, we could simply control the speed of a motor the same way we control the speed in our ceiling fan. However, unfortunately our automobiles use motors which are not electricity powered. They are IC&#39;s or Internal combustion engines which run most efficiently in a fixed narrow range of RPM. They are not able to produce the same amount of torque at all the RPM&#39;s and of course are not efficient at all RPM ranges. At very low RPM the engines suffer from lower dynamic torque and hence we need to somehow use the same RPM to get the needed torque demands. At cruising speeds we require lesser torque as compared to when we are climbing a hill. All these means that the IC engine has to meet various requirements of torque, speed and efficient operation. This can be achieved very easily using a Transmission. A transmission ensure that the Engine can be run in a narrow band of RPM where it runs most efficiently and uses gears to meet the driver request of torque or speed. &lt;br/&gt;&lt;b&gt;How does it do it?&lt;/b&gt;&lt;br/&gt;A simple transmission &quot;conceptually&quot; is a set of gears with different gear ratio&#39;s. If the engine is running at x RPM using a gear ration you can get y RPM at you transmission shaft based on the following formula:&lt;br/&gt;X * GR = Y&lt;br/&gt;GR = Gear Ratio&lt;br/&gt;X =   Engine RPM&lt;br/&gt;Y =   Transmission Shaft RPM&lt;br/&gt;However, this is an ideal case....losses will come into picture like in any system. &lt;br/&gt;if GR&amp;gt;1 then Y is greater than X. This is rarely done since this means that Transmission shaft RPM is higher than engine RPM. This basically means that your car is completely free. This condition is called Overdrive and mostly seen in higher end car with ECU&#39;s and TCU&#39;s which keep monitoring if everything is still under control. &lt;br/&gt;&lt;b&gt;What are gears and gear ratio&#39;s?&lt;/b&gt;&lt;br/&gt;A picture speaks more than words...so here is the picture&lt;br/&gt;&lt;img src=&#39;http://blog.hemmings.com/wp-content/uploads/2007/10/gear%20ratio.gif&#39; style=&#39;max-width: 800px;&#39;/&gt;&lt;br/&gt;Ever wondered why the car or bike will not climb a steep incline when we are on a higher gear as compared to a lower gear? At a higher gear the transmission transfers most of the engine speed to the tires as compared to the torque. If we consider power delivered by engine constant then either we can have higher torque or angular velocity. Hence at the higher gear ( more angular velocity) we need to really rev the engine hard to make the vehicle climb ( more revs more power output) in order to meet the higher torque requirement. &lt;br/&gt;&lt;br/&gt;In coming blogs it will try to explain what different transmission can do and how they do it. But basics are these...&lt;br/&gt;1. For a constant power by the engine i.e. constant RPM on engine shaft we should be able to get different torques and output speeds.&lt;br/&gt;2. Gears are one of the mechanism&#39;s for doing what we need in point (1). There are other methods like use of pulleys, belts and electro mechanical couplings. &lt;br/&gt;&lt;br/&gt;&lt;br/&gt;&lt;div class=&#39;zemanta-pixie&#39;&gt;&lt;img src=&#39;http://img.zemanta.com/pixy.gif?x-id=6da7fefd-a11b-8b60-b380-d2c4df71b38a&#39; alt=&#39;&#39; class=&#39;zemanta-pixie-img&#39;/&gt;&lt;/div&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://embeddedlive.blogspot.com/feeds/6683359289537588805/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://embeddedlive.blogspot.com/2010/04/tansmissions-gears.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1907071224335910840/posts/default/6683359289537588805'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1907071224335910840/posts/default/6683359289537588805'/><link rel='alternate' type='text/html' href='http://embeddedlive.blogspot.com/2010/04/tansmissions-gears.html' title='Tansmissions &amp;amp; Gears'/><author><name>Deepz</name><uri>http://www.blogger.com/profile/16543298327846220464</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1907071224335910840.post-5496118899149513646</id><published>2009-12-18T15:07:00.001+05:30</published><updated>2009-12-18T15:07:45.715+05:30</updated><title type='text'>4 - pack ABS - The ones your car has!!</title><content type='html'>&lt;div xmlns=&#39;http://www.w3.org/1999/xhtml&#39;&gt;Now that from a few posts we have discussed only &quot;C&quot; I thought this time will get back to some automotive basics. &lt;br/&gt;Topic this time is Vehicle stability and we will towards the end talk a bit about ABS. &lt;br/&gt;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.&lt;br/&gt;&lt;ol&gt;&lt;li&gt;&lt;b&gt;Why does the car move forward when the wheels turn?&lt;/b&gt; - 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&#39;t mean more speed. &lt;br/&gt;&lt;/li&gt;&lt;li&gt;&lt;b&gt;What happens when we brake ?&lt;/b&gt; - 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. &lt;/li&gt;&lt;li&gt;&lt;b&gt;Other Problems&lt;/b&gt; ? - 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.&lt;/li&gt;&lt;/ol&gt;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&lt;br/&gt;&lt;ul&gt;&lt;li&gt;Wheels are not locked so you can steer the vehicle till the last minute.&lt;/li&gt;&lt;li&gt;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&#39;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. &lt;br/&gt;&lt;/li&gt;&lt;li&gt;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.&lt;/li&gt;&lt;/ul&gt;Ok i will stop here to take  a breather. More later. &lt;br/&gt;&lt;small style=&#39;font-family: georgia; color: rgb(51, 102, 255);&#39;&gt;Please leave your comment. You can subscribe to this blog by using the links under &quot;Subscribe&quot; section.&lt;/small&gt; &lt;br/&gt;&lt;br/&gt;&lt;br/&gt;&lt;div class=&#39;zemanta-pixie&#39;&gt;&lt;img src=&#39;http://img.zemanta.com/pixy.gif?x-id=0949e14a-5b50-8fdf-b3bb-13104ac4cbf2&#39; alt=&#39;&#39; class=&#39;zemanta-pixie-img&#39;/&gt;&lt;/div&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://embeddedlive.blogspot.com/feeds/5496118899149513646/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://embeddedlive.blogspot.com/2009/12/4-pack-abs-ones-your-car-has.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1907071224335910840/posts/default/5496118899149513646'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1907071224335910840/posts/default/5496118899149513646'/><link rel='alternate' type='text/html' href='http://embeddedlive.blogspot.com/2009/12/4-pack-abs-ones-your-car-has.html' title='4 - pack ABS - The ones your car has!!'/><author><name>Deepz</name><uri>http://www.blogger.com/profile/16543298327846220464</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1907071224335910840.post-4256520630569999615</id><published>2009-12-05T21:16:00.001+05:30</published><updated>2009-12-05T21:17:16.885+05:30</updated><title type='text'>Preprocessor -Coding myth 4</title><content type='html'>&lt;div xmlns=&#39;http://www.w3.org/1999/xhtml&#39;&gt;&lt;div style=&#39;text-align: justify;&#39;&gt;&lt;span style=&#39;font-family: tahoma;&#39;&gt;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&lt;/span&gt;&lt;br/&gt;&lt;/div&gt;&lt;span style=&#39;font-family: Courier New;&#39;&gt;#define BusClock ((Crystal_Frequency)/(Prescalar))&lt;/span&gt;&lt;br/&gt;&lt;br/&gt;&lt;span style=&#39;font-family: tahoma;&#39;&gt;Now the argument was ...why was i not calculating manually and typing in the values. &lt;/span&gt;&lt;br style=&#39;font-family: tahoma;&#39;/&gt;&lt;span style=&#39;font-weight: bold; font-family: tahoma;&#39;&gt;Our Dude Says&lt;/span&gt;&lt;span style=&#39;font-family: tahoma;&#39;&gt; &amp;gt;&amp;gt; See Macros will be just replaced by the compiler so when you load it into the register like this&lt;br/&gt;&lt;br/&gt;&lt;/span&gt;&lt;span style=&#39;font-family: Courier New;&#39;&gt;BCLK = BusClock; &lt;/span&gt;&lt;br/&gt;&lt;br/&gt;&lt;div style=&#39;text-align: justify;&#39;&gt;&lt;span style=&#39;font-family: tahoma;&#39;&gt;then there will be more run time due to the division of crystal freq by prescalar.&lt;/span&gt;&lt;br/&gt;&lt;span style=&#39;font-family: tahoma;&#39;&gt;Well this is totally wrong. There are parts of the statement which are correct and which are wrong. &lt;/span&gt;&lt;br style=&#39;font-family: tahoma;&#39;/&gt;&lt;span style=&#39;font-family: tahoma;&#39;&gt;Correct parts &amp;gt;&amp;gt; Macro&#39;s will be dumbly replaced ( not by the compiler but by the preprocessor).&lt;/span&gt;&lt;br style=&#39;font-family: tahoma;&#39;/&gt;&lt;span style=&#39;font-family: tahoma;&#39;&gt;Which means that when my code goes to the compiler it looks like this&lt;/span&gt;&lt;br/&gt;&lt;/div&gt;&lt;span style=&#39;font-family: Courier New;&#39;&gt;BCLK = 600000/12;&lt;/span&gt; &lt;br/&gt;where cystal is 6Mhz and Prescalar is 12. &lt;br/&gt;&lt;span style=&#39;font-family: tahoma;&#39;&gt;Does that mean it will go to the assembler in the same way....No!! and that is the wrong part. &lt;/span&gt;&lt;br style=&#39;font-family: tahoma;&#39;/&gt;&lt;div style=&#39;text-align: justify;&#39;&gt;&lt;span style=&#39;font-family: tahoma;&#39;&gt;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&lt;/span&gt;&lt;br/&gt;&lt;/div&gt;&lt;span style=&#39;font-family: Courier New;&#39;&gt;BCLK = 50000; &lt;br/&gt;&lt;/span&gt;&lt;div style=&#39;text-align: justify;&#39;&gt;&lt;span style=&#39;font-family: tahoma;&#39;&gt;before anything meaningful really begins. &lt;/span&gt;&lt;br style=&#39;font-family: tahoma;&#39;/&gt;&lt;span style=&#39;font-family: tahoma;&#39;&gt;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. &lt;/span&gt;&lt;br style=&#39;font-family: tahoma;&#39;/&gt;&lt;/div&gt;&lt;br/&gt;&lt;div style=&#39;text-align: justify;&#39;&gt;&lt;span style=&#39;font-family: tahoma;&#39;&gt;So the basic rule is that ...&lt;/span&gt;&lt;br style=&#39;font-family: tahoma;&#39;/&gt;&lt;span style=&#39;font-family: tahoma;&#39;&gt;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 &lt;/span&gt;&lt;span style=&#39;font-weight: bold; font-family: tahoma;&#39;&gt;Integer&lt;/span&gt;&lt;span style=&#39;font-family: tahoma;&#39;&gt; 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. &lt;/span&gt;&lt;br/&gt;&lt;/div&gt;&lt;br/&gt;If anyone knows of a compiler that doesn&#39;t do that, please enlighten me...&lt;br/&gt;&lt;small style=&#39;font-family: georgia; color: rgb(51, 102, 255);&#39;&gt;Please leave your comment. You can subscribe to this blog by using the links under &quot;Subscribe&quot; section.&lt;/small&gt;&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;&lt;p class=&#39;scribefire-powered&#39;&gt;Powered by &lt;a href=&#39;http://www.scribefire.com/&#39;&gt;ScribeFire&lt;/a&gt;.&lt;/p&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1907071224335910840/posts/default/4256520630569999615'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1907071224335910840/posts/default/4256520630569999615'/><link rel='alternate' type='text/html' href='http://embeddedlive.blogspot.com/2009/12/preprocessor-coding-myth-4.html' title='Preprocessor -Coding myth 4'/><author><name>Deepz</name><uri>http://www.blogger.com/profile/16543298327846220464</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author></entry><entry><id>tag:blogger.com,1999:blog-1907071224335910840.post-3622030616281507304</id><published>2009-11-09T21:18:00.001+05:30</published><updated>2009-11-09T21:18:24.725+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="Automotive"/><category scheme="http://www.blogger.com/atom/ns#" term="C coding"/><category scheme="http://www.blogger.com/atom/ns#" term="Embedded Hardware"/><category scheme="http://www.blogger.com/atom/ns#" term="funda"/><title type='text'>Eeprom and Flash Emulated Eeprom</title><content type='html'>&lt;div xmlns=&#39;http://www.w3.org/1999/xhtml&#39;&gt;This post talks about some basics of &lt;span style=&#39;font-weight: bold;&#39;&gt;EEPROM &lt;/span&gt;and &lt;span style=&#39;font-weight: bold;&#39;&gt;FEE&lt;/span&gt;. &lt;br/&gt;To start with the discussion it is necessary to know what &lt;span style=&#39;font-weight: bold;&#39;&gt;EEPROM &lt;/span&gt;stands for. &lt;span style=&#39;font-weight: bold;&#39;&gt;EEPROM &lt;/span&gt;stands for Electrically Erasable PROM. Where &lt;span style=&#39;font-weight: bold;&#39;&gt;PROM &lt;/span&gt;means Programmable Read only memory. The very fact that we are highlighting the Electrically Erasable means that there are other methods to erase the PROM. I leave it to the reader to find out what these are and leave as a comment. &lt;br/&gt;&lt;span style=&#39;font-weight: bold;&#39;&gt;Why do we need it?&lt;/span&gt;&lt;br/&gt;In any system there are some set of parameters that need to be remembered through power cycles and can/may change between power cycles. An example....Well Your monitor settings ( i.e. the brightness contrast etc that you do on your monitor) is remembered through power cycles even if you connect the monitor to another PC or whatever. One of the places to store this could be the &lt;span style=&#39;font-weight: bold;&#39;&gt;EEPROM&lt;/span&gt;. &lt;br/&gt;&lt;span style=&#39;font-weight: bold;&#39;&gt;What does this mean?&lt;/span&gt;&lt;br/&gt;To write to the &lt;span style=&#39;font-weight: bold;&#39;&gt;EEPROM &lt;/span&gt;i should be able to erase it and then rewrite it. Also it should be capable of being written several times ( maybe a few lakh times). Also, it should have data retention capacity. i.e if i write it today and check after say some 10 years the data should be same in the absence of any power. &lt;br/&gt;&lt;span style=&#39;font-weight: bold;&#39;&gt;What is FEE then?&lt;/span&gt;&lt;br/&gt;As you can see some of the properties of &lt;span style=&#39;font-weight: bold;&#39;&gt;EEPROM &lt;/span&gt;are held by the flash memory also. Like i can write into the Flash memory electrically, it can retain information across power cycles, it can be written multiple times. However, the biggest different is that the flash technology ensures that it can be written only in huge chunks like 64 or 128 bytes. Also, the life of the Flash memory is much lesser than the &lt;span style=&#39;font-weight: bold;&#39;&gt;EEPROM&lt;/span&gt;. On the other hand the best part is that it costs much less than the &lt;span style=&#39;font-weight: bold;&#39;&gt;EEPROM&lt;/span&gt;. &lt;br/&gt;So &lt;span style=&#39;font-weight: bold;&#39;&gt;FEE &lt;/span&gt;which stands for Flash Emulated &lt;span style=&#39;font-weight: bold;&#39;&gt;EEPROM &lt;/span&gt;is basically a method of emulating the behaviour of the &lt;span style=&#39;font-weight: bold;&#39;&gt;EEPROM &lt;/span&gt;using the Flash memory. This means if a Flash memory has 10000 write cyles, i should make it some how work as if it is 100,000 write cycles ( like in case of &lt;span style=&#39;font-weight: bold;&#39;&gt;EEPROM&lt;/span&gt;). Also, i should provide somehow the capability of writing a single word/ single byte as available in the &lt;span style=&#39;font-weight: bold;&#39;&gt;EEPROM&lt;/span&gt;. &lt;br/&gt;In short if i have &lt;span style=&#39;font-weight: bold;&#39;&gt;FEE &lt;/span&gt;then the application should feel as if it is having &lt;span style=&#39;font-weight: bold;&#39;&gt;EEPROM&lt;/span&gt;....&lt;br/&gt;&lt;span style=&#39;font-weight: bold;&#39;&gt;How to do this ? Well that is for another post....&lt;/span&gt;&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;&lt;small style=&#39;font-family: georgia; color: rgb(51, 102, 255);&#39;&gt;Please leave your comment. You can subscribe to this blog by using the links under &quot;Subscribe&quot; section.&lt;/small&gt;&lt;br/&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=&#39;scribefire-powered&#39;&gt;Powered by &lt;a href=&#39;http://www.scribefire.com/&#39;&gt;ScribeFire&lt;/a&gt;.&lt;/p&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1907071224335910840/posts/default/3622030616281507304'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1907071224335910840/posts/default/3622030616281507304'/><link rel='alternate' type='text/html' href='http://embeddedlive.blogspot.com/2009/11/eeprom-and-flash-emulated-eeprom.html' title='Eeprom and Flash Emulated Eeprom'/><author><name>Deepz</name><uri>http://www.blogger.com/profile/16543298327846220464</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author></entry><entry><id>tag:blogger.com,1999:blog-1907071224335910840.post-1523214800577004046</id><published>2009-10-17T13:22:00.001+05:30</published><updated>2009-10-17T13:22:51.943+05:30</updated><title type='text'>Sign language</title><content type='html'>&lt;div xmlns=&#39;http://www.w3.org/1999/xhtml&#39;&gt;I have been assigned the painful job of taking interview for my team in company. Why is it painful? Because i am the junior interviewer in the panel and I have to put through the bullshit that the senior interviewer gives to the candidate.... Anyway, this post is just about a couple of things i found people where not aware of !!&lt;br/&gt;&lt;br/&gt;&lt;span style=&#39;font-weight: bold;&#39;&gt;Signed arithmetic in C?&lt;/span&gt;&lt;br/&gt;First thing we should know that most C compilers and µC&#39;s use 2&#39;s complement method to do signed arithmetic. If you are wondering hey that is the only way....&lt;span style=&#39;font-weight: bold;&#39;&gt;Wait!!&lt;/span&gt; Another way of representation is by using the first bit for sign and rest of the data. &lt;br/&gt;Which means &lt;br/&gt;-5 = 0x1101&lt;br/&gt;-7 = 0x1111&lt;br/&gt;This representation is good and simple. However, it was not so good for the chip manufacturers who had a problem with zero. &lt;br/&gt;0 = 0x0000 or 0 = 0x1000. Which meant that on the number line the same number could be represented by two symbols. &lt;br/&gt;This problem was solved by introduction of the 2&#39;s complement. Which is nothing but 1&#39;s complement + 1. &lt;br/&gt;which means &lt;br/&gt;-5 = 0x1011&lt;br/&gt;-7 = 0x1001 and 0 = 0x0000.&lt;br/&gt;There was no concept of negative zero. This effectively ensured that for n bits one could represent 2^(n) values. So for 4 bits we should have 16 values. 8+tive and 8 negative. However, we have 8 negative -1 to -8 (0x1000). And 7 positive (1-7). Zero is actually neither positive nor negative and takes the middle position (without a sign bit so really it is a positive...what say?). &lt;br/&gt;One question that i sometimes ask is why was 0x1000 not chosen as +8? Technically it is correct!!. There are two problems. 1) we would kill a advantage which we have with 2&#39;s complement ( i.e. MSB is 1 if the number is less than zero). 2) I forgot!!...&lt;br/&gt;&lt;br/&gt;Anyway, It is necessary that we understand how signed arithmetic works to understand concepts like &lt;span style=&#39;font-weight: bold;&#39;&gt;add through overflow&lt;/span&gt; ( used in Targetlink), Usage (or avoiding!!) of saturation blocks ( in Targetlink and RTW). You can do intelligent coding if you understand how the signed numbers are understood by the compiler you are using. &lt;br/&gt;&lt;br/&gt;&lt;small style=&#39;font-family: georgia; color: rgb(51, 102, 255);&#39;&gt;Please leave your comment. You can subscribe to this blog by using the links under &quot;Subscribe&quot; section.&lt;/small&gt;&lt;br/&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=&#39;scribefire-powered&#39;&gt;Powered by &lt;a href=&#39;http://www.scribefire.com/&#39;&gt;ScribeFire&lt;/a&gt;.&lt;/p&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1907071224335910840/posts/default/1523214800577004046'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1907071224335910840/posts/default/1523214800577004046'/><link rel='alternate' type='text/html' href='http://embeddedlive.blogspot.com/2009/10/sign-language.html' title='Sign language'/><author><name>Deepz</name><uri>http://www.blogger.com/profile/16543298327846220464</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author></entry><entry><id>tag:blogger.com,1999:blog-1907071224335910840.post-1267225499135985443</id><published>2009-09-18T21:27:00.001+05:30</published><updated>2009-09-18T21:27:41.791+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="Automotive"/><category scheme="http://www.blogger.com/atom/ns#" term="Embedded Software"/><category scheme="http://www.blogger.com/atom/ns#" term="Info"/><category scheme="http://www.blogger.com/atom/ns#" term="Intermediate"/><title type='text'>The Early Fuel Pulse</title><content type='html'>&lt;div xmlns=&#39;http://www.w3.org/1999/xhtml&#39;&gt;&lt;div style=&#39;text-align: justify;&#39;&gt;This post again goes back to the &lt;span style=&#39;font-weight: bold;&#39;&gt;EMS &lt;/span&gt;basics that i have been writing about in the previous posts.&lt;br/&gt;Early systems when started to use the Gasoline Fuel injection ( Manifold injection) only controlled the &lt;span style=&#39;font-weight: bold;&#39;&gt;Fuel pulse&lt;/span&gt;. &lt;span style=&#39;font-weight: bold;&#39;&gt;Fuel pulse&lt;/span&gt; is the industry term that has evolved for the duration for which the Fuel Injector electrical signal is enabled. How does the Fuel Pulse help us to control the fuel?&lt;br/&gt;The fuel line is maintained at a specific pressure. This pressure is usually created by a pump either in Fuel tank or outside of it. The Fuel is maintained at a fairly high pressure. The Injectors are &lt;span style=&#39;font-weight: bold;&#39;&gt;solenoid &lt;/span&gt;based valves. A electric signal running through the solenoid opens the valve. The valve closed back with the help of a spring. This spring ensures that once the fuel pulse is cut off the valve closes immediately. However, this is not true and there is adjustment added in the EMS software to take care of this variation. &lt;br/&gt;As in the earlier discussions the Fuel pulse directly depends on the engine load and the engine rpm. Now i explain in some bulleted points why some sensors are needed and how they contribute to calculation of the fuel pulse.&lt;br/&gt;&lt;span style=&#39;font-weight: bold;&#39;&gt;Intake Air Temperature Sensor&lt;/span&gt; : The density of air depends temperature hence the temperature sensor is used to indirectly calculate the density of air. Warm air is less dense while cold air is more dense.&lt;br/&gt;&lt;span style=&#39;font-weight: bold;&#39;&gt;Air Flow Sensor:&lt;/span&gt; In systems which use the Air-Flow to determine the intake air mass a Air Flow Sensor is used. This is basically done using a simple logic. 1) Calculate the volume of air that has passed the flow sensor. 2) Use a Lookup table based approach to get the density of the air based on the temperature 3) use the density and volume/sec to get the mass air flow into the manifold.&lt;br/&gt;&lt;span style=&#39;font-weight: bold;&#39;&gt;Manifold Absolute Pressure &lt;/span&gt;: Not all systems use the Air Flow Sensor, some ( like the &lt;span style=&#39;font-weight: bold;&#39;&gt;Bosch D-Jetronic&lt;/span&gt;) use the pressure in the Manifold to calculate the Mass air flow into the manifold. This system has a drawback because as the engine revs up the pressure fluctuations inside the manifold are immense ( Because at the other end of the manifold we have the engine which is acting like a pump!!). Using the Gas equation it is easy to derive the Volume of the air using the Pressure and the temperature information. &lt;br/&gt;&lt;br/&gt;Just a small deviation here.....Air Flow Sensors come in two type....&lt;span style=&#39;font-weight: bold;&#39;&gt;1) Vane Type 2) Heating element type.&lt;/span&gt;&lt;br/&gt;&lt;/div&gt;&lt;ul style=&#39;text-align: justify;&#39;&gt;&lt;li&gt; The vane type is pretty straight forward....you put a piece of thin metal in the path of the air flow....faster the flow more the vane will be pushed. The other end of the vane is connected to a potentiometer which will show variation of resistance to the ECU.&lt;/li&gt;&lt;li&gt;The Heating element uses a small coil and maintains it at a particular temperature using a small current. The air flowing over this coil cools it down changing its resistance and thus varying the current. &lt;br/&gt;&lt;/li&gt;&lt;/ul&gt;&lt;div style=&#39;text-align: justify;&#39;&gt;The RPM of the engine is detected easily by a&lt;span style=&#39;font-weight: bold;&#39;&gt; magnetic pick up and a gear&lt;/span&gt;. Note that early systems did not control the &lt;span style=&#39;font-weight: bold;&#39;&gt;Ignition&lt;/span&gt; &lt;span style=&#39;font-weight: bold;&#39;&gt;Timing&lt;/span&gt;. It was fully controlled using the Camshafts and a Distributor. However, LE- Jetronic systems from Bosch implemented Electronic spark distribution, However even in these systems there was very little control on the Ignition timing which still heavily depended on the Camshaft. &lt;br/&gt;&lt;br/&gt;&lt;span style=&#39;font-weight: bold;&#39;&gt;Corrections and Compensations&lt;/span&gt;&lt;br/&gt;Though the base Fuel pulse width was calculated using Lookup-Table ( i.e FuelPulse = f(rpm,engineload)) there are some special diets for the engine based on some special conditions.&lt;br/&gt;&lt;/div&gt;&lt;ol style=&#39;text-align: justify;&#39;&gt;&lt;li&gt;&lt;span style=&#39;font-weight: bold;&#39;&gt;Startup &lt;/span&gt;: The mixture leaning effect is seen in a cold engine. What does this mean? When the engine is cold ( manifold and other portions also) then the mixture formation is not at its best...Which means that all the fuel that is injected is not going to burn. Hence to achieve the same behaviour more fuel needs to be added. &lt;span style=&#39;font-weight: bold;&#39;&gt;Conclusion : Increase in PW&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&#39;font-weight: bold;&#39;&gt;&lt;span style=&#39;font-weight: bold;&#39;&gt;Low Battery: &lt;/span&gt;&lt;/span&gt;This means that the battery voltage has dropped below a specific value. This directly translates to insufficient current supplied to Injectors. Since there is lesser current on the injector solenoids the do not open so well hence we need to elongate the pulse to ensure that the same quantity of fuel is delivered as we intended to.&lt;span style=&#39;font-weight: bold;&#39;&gt; Conclusion : Increase in PW&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&#39;font-weight: bold;&#39;&gt;Idling &lt;/span&gt;: The engine needs a certain RPM to be maintained to that in can overcome its self resistance and continue to function. However, if the throttle position supplied by the driver is taken into consideration....there is none...i.e the driver doesn&#39;t push accelerator to keep the engine idling. Hence the EMS should understand this condition and automatically provide a finite amount fuel.  Usually a special switch is incorporated in the Throttle pedal assembly which detects a no throttle press condition.&lt;/li&gt;&lt;li&gt;&lt;span style=&#39;font-weight: bold;&#39;&gt;Acceleration Enrichment&lt;/span&gt;: This sudden demand for power occurs when the driver floors the throttle. This sudden flooring of the throttle can cause the mixture to lean out instantly making the engine under go a &quot;lean stumble&quot;. This is avoided by providing a throttle floor switch which is activated when the throttle is floored and indicates the ECU about a sudden power demand. &lt;span style=&#39;font-weight: bold;&#39;&gt;Conclusion : Increase in PW&lt;/span&gt;&lt;/li&gt;&lt;/ol&gt;&lt;div style=&#39;text-align: justify;&#39;&gt;In my current project there have been fierce discussion about which one is a correction and which one is a compensation....I say does it matter ? If you understand how we can classify these please let me know too !!&lt;br/&gt;&lt;span style=&#39;color: rgb(204, 102, 0);&#39;&gt;[Note: The above is just the beginning and talks only about early Manifold injection system, Next post will contain how other signals were added to this base system to improve the performance!!]&lt;/span&gt;&lt;br style=&#39;color: rgb(204, 102, 0);&#39;/&gt;&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=&#39;scribefire-powered&#39;&gt;Powered by &lt;a href=&#39;http://www.scribefire.com/&#39;&gt;ScribeFire&lt;/a&gt;.&lt;/p&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1907071224335910840/posts/default/1267225499135985443'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1907071224335910840/posts/default/1267225499135985443'/><link rel='alternate' type='text/html' href='http://embeddedlive.blogspot.com/2009/09/early-fuel-pulse.html' title='The Early Fuel Pulse'/><author><name>Deepz</name><uri>http://www.blogger.com/profile/16543298327846220464</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author></entry><entry><id>tag:blogger.com,1999:blog-1907071224335910840.post-5636903805543785213</id><published>2009-09-07T11:59:00.001+05:30</published><updated>2009-09-07T11:59:59.958+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="Automotive"/><category scheme="http://www.blogger.com/atom/ns#" term="Images"/><category scheme="http://www.blogger.com/atom/ns#" term="Info"/><category scheme="http://www.blogger.com/atom/ns#" term="Trucks"/><title type='text'>The torture that a Suspension undergoes!!</title><content type='html'>&lt;div xmlns=&#39;http://www.w3.org/1999/xhtml&#39;&gt;&lt;div style=&#39;text-align: center;&#39;&gt;&lt;img src=&#39;http://lh5.ggpht.com/_wcH0kSX1dHw/SqSk6BWAmfI/AAAAAAAAAHI/tEKBOYG7y9U/%5BUNSET%5D.jpg?imgmax=800&#39; style=&#39;max-width: 800px; width: 367px; height: 320px;&#39;/&gt;&lt;br/&gt;&lt;div style=&#39;text-align: justify;&#39;&gt;The pic should tell you why we need a good suspension in trucks. The pic is from a test track however the roads in India keep in store worst conditions for the truck. The suspension design for heavy duty trucks is a extremely challenging task. There are some very strict rules that need to be followed to ensure that the weight of the suspension is low ( so that in effect the Truck&#39;s unladen weight is less) and also provide the right amount of stiffness to ensure good drive-ability. The design should consider worst case scenario&#39;s to ensure that the truck suspension holds even under heavy load conditions. Usually a factor of safety of 2.5 to 3 is considered in designs. &lt;br/&gt;&lt;/div&gt;&lt;br/&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=&#39;scribefire-powered&#39;&gt;Powered by &lt;a href=&#39;http://www.scribefire.com/&#39;&gt;ScribeFire&lt;/a&gt;.&lt;/p&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1907071224335910840/posts/default/5636903805543785213'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1907071224335910840/posts/default/5636903805543785213'/><link rel='alternate' type='text/html' href='http://embeddedlive.blogspot.com/2009/09/torture-that-suspension-undergoes.html' title='The torture that a Suspension undergoes!!'/><author><name>Deepz</name><uri>http://www.blogger.com/profile/16543298327846220464</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://lh5.ggpht.com/_wcH0kSX1dHw/SqSk6BWAmfI/AAAAAAAAAHI/tEKBOYG7y9U/s72-c/%5BUNSET%5D.jpg?imgmax=800" height="72" width="72"/></entry><entry><id>tag:blogger.com,1999:blog-1907071224335910840.post-1884744559486143588</id><published>2009-09-04T16:20:00.000+05:30</published><updated>2009-09-04T16:21:09.277+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="Automotive"/><category scheme="http://www.blogger.com/atom/ns#" term="Basic"/><category scheme="http://www.blogger.com/atom/ns#" term="Powertrain"/><title type='text'>Glossary of EMS terms -part 1</title><content type='html'>&lt;div xmlns=&#39;http://www.w3.org/1999/xhtml&#39;&gt;&lt;div style=&#39;text-align: justify;&#39;&gt;This article just introduces a few terms that are very frequently used when we talk about Powertrain. I would say this is just some kind of a glossary of terms &lt;br/&gt;&lt;br/&gt;&lt;span style=&#39;font-weight: bold;&#39;&gt;Lean &amp;amp; Rich Mixtures&lt;/span&gt;: Both terms talk about air-fuel ratio. A Lean mixture is one in which the air (oxygen) is more than what is needed to burn the fuel. Obviously Rich mixture is the other way round ( though opposite of lean is fat!!). The stoichiometric ratio or the right ratio is about 14.7:1 ( for pure octane). Which means, to burn 1 part of fuel we would need about fifteen parts of air. Note, that when i talk of air it is actually the oxygen that i am really interested. One very big misconception is that all 14.7:1 is the universal ratio which is false because this depends on the fuel ( its octane number + if there are any additives like anti-knock).&lt;br/&gt;&lt;br/&gt;&lt;span style=&#39;font-weight: bold;&#39;&gt;Lambda &lt;/span&gt;: For a long time i could not understand this value and people told me all kinds of things. for starters &quot;λ&quot; is not the air-fuel ratio but it is a measure of the air-fuel ratio. The best of understanding λ is that it is &quot;Excess air factor&quot;. So if λ is 1 that means there is no extra air and we are running at stoich ratio. If λ is greater than 1 that means we are running Lean because we have extra air in the mixture. Similarly, λ &amp;lt;1 means that our mixture is rich, there is less air than needed to burn the entire volume of fuel that we have. &lt;br/&gt;&lt;br/&gt;&lt;span style=&#39;font-weight: bold;&#39;&gt;Lambda Sensor&lt;/span&gt;: This is also called O2 sensor. Again this was a very confusing term for me ( still is!!). Why do we call this λ sensor? what does it measure? &amp;amp;Lamda sensor is actually a 0xygen sensor. This give out a voltage output based on the oxygen content in the stream. There is a platinum probe one side of which is exposed to exhaust gases while the other side is exposed to atmospheric gases. This works pretty much on the same principle as a electrolytic cell. The voltage output is used by the ECU to do other calculations about which we shall talk in future. In modern vehicle i would expect atleast 2 such sensors.&lt;br/&gt;&lt;br/&gt;&lt;span style=&#39;font-weight: bold;&#39;&gt;58x Signal: &lt;/span&gt;This is basically the term that has evolved for the cranktooth signal. For ECU controlled engines, with individual cylinder control it is necessary to know when to fire which cylinder and for this it should know which cylinder is at &lt;span style=&#39;font-weight: bold;&#39;&gt;TDC&lt;/span&gt; and which at &lt;span style=&#39;font-weight: bold;&#39;&gt;BDC&lt;/span&gt;. This information is available to the ECU via a toothed wheel which is connect to the crankrod of the engine. For a lot of reasons, including ease of software computations, 60 tooth where chose on the wheel with 2 teeth missing. The missing teeth helps the ECU recognize where the cylinders are. Some manufacturers are more comfortable using the 28x signal. i.e 30 teeth with 2 teeth missing.&lt;br/&gt;&lt;br/&gt;&lt;small style=&#39;font-family: georgia; color: rgb(51, 102, 255);&#39;&gt;Please leave your comment. You can subscribe to this blog by using the links under &quot;Subscribe&quot; section.&lt;/small&gt;&lt;br/&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=&#39;scribefire-powered&#39;&gt;Powered by &lt;a href=&#39;http://www.scribefire.com/&#39;&gt;ScribeFire&lt;/a&gt;.&lt;/p&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1907071224335910840/posts/default/1884744559486143588'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1907071224335910840/posts/default/1884744559486143588'/><link rel='alternate' type='text/html' href='http://embeddedlive.blogspot.com/2009/09/glossary-of-ems-terms-part-1.html' title='Glossary of EMS terms -part 1'/><author><name>Deepz</name><uri>http://www.blogger.com/profile/16543298327846220464</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author></entry><entry><id>tag:blogger.com,1999:blog-1907071224335910840.post-6805791193754946021</id><published>2009-08-20T14:51:00.001+05:30</published><updated>2009-08-20T14:51:59.527+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="Basic"/><category scheme="http://www.blogger.com/atom/ns#" term="Embedded Software"/><category scheme="http://www.blogger.com/atom/ns#" term="funda"/><category scheme="http://www.blogger.com/atom/ns#" term="Info"/><title type='text'>Throughput funda&amp;#39;s</title><content type='html'>&lt;div xmlns=&#39;http://www.w3.org/1999/xhtml&#39;&gt;&lt;div style=&#39;text-align: justify;&#39;&gt;I have been quite inconsistent in updating the information presented on this blog. The one things that discourages me like any other new blogger is that very little traffic is seen here and since this is a technical blog, unless i get feedback it is difficult for me to judge if something is good or bad. However, for now i have considered that no feedback is negative feedback. Nevertheless i continue to write.&lt;br/&gt;&lt;span style=&#39;font-weight: bold;&#39;&gt;What is Throughput...This is the weeks question. &lt;/span&gt;&lt;br/&gt;Wordweb tells me&lt;br/&gt;&lt;blockquote&gt;Output relative to input; the amount passing through a system from input to output (especially of a computer program over a period of time)&lt;/blockquote&gt;&lt;blockquote&gt;&lt;br/&gt;&lt;/blockquote&gt;The Throughput that i am talking is the one that embedded engineers often talk about. In simple terms this value is a measure of the &lt;span style=&#39;font-weight: bold;&#39;&gt;CPU &lt;/span&gt;load under the worst conditions. What could be the worst conditions? These are basically situations which demand more processing power. For example, Image Stabilization, Red Eye Detection, Smile Detection, Ambient light detection along with Click detection or auto timer ( and image post processing) in a Camera perhaps put a great deal of performance demands on the &lt;span style=&#39;font-weight: bold;&#39;&gt;CPU &lt;/span&gt;in a Digital camera and this also determines it worst case performance. &lt;br/&gt;Unfortunately like many other engineering terms a higher value of throughput means that your system is more loaded. Often under some conditions the throughput reaches 100% in systems which means the CPU has almost no idle time and is being utilized all the time to its maximum capacity. &lt;br/&gt;If i look at it from an EMS perspective then startup is the when there is very high &lt;span style=&#39;font-weight: bold;&#39;&gt;CPU &lt;/span&gt;loads that are encountered. In an OS based system there are methods to determine for how much time the &lt;span style=&#39;font-weight: bold;&#39;&gt;CPU &lt;/span&gt;is free. Usually, some background tasks which are not necessary to be done all the time are done in this free time. ( Example, &lt;span style=&#39;font-weight: bold;&#39;&gt;CRC &lt;/span&gt;calculation or &lt;span style=&#39;font-weight: bold;&#39;&gt;RAM &lt;/span&gt;Checks etc). In simple scheduler based systems the throughput is just the time remaining in the baseloop after all the tasks have been finished. One more parameter that influences the throughput to a great extent is the Interrupt Rate. A very high interrupt rate will ensure that the CPU loses a lot of time in context switches which are really an overhead and do not contribute in anyway to the functionality of the system. &lt;br/&gt;[ This was my understanding of Throughput. After looking into wiki i think the origin of is term comes from the CPU bandwidth utilization. The term is primarily used for parametrization of Communication channel bandwidths]&lt;br/&gt;&lt;br/&gt;&lt;span style=&#39;font-weight: bold;&#39;&gt;How Do we ensure that we never reach 100% throughput? &lt;/span&gt;&lt;br/&gt;&lt;ul&gt;&lt;li&gt;Plan your interrupts and their sources well. You should know the worst case rate of an interrupt beforehand. Example, the Door lock engage interrupt cannot come at say more than 1-2 times a second ( Due to the inertia of the lock).&lt;/li&gt;&lt;li&gt;Write your code with throughput in mind. E.g if possible use binary search in place of linear search. Use macros instead of functions judiciously&lt;/li&gt;&lt;li&gt;Overuns should be detected in software using some special variables or debug variables. Over-Runs occurs when the throughput goes more than 100%. Which means that you have asked the CPU to more than it is capable of handling in the given time. &lt;/li&gt;&lt;/ul&gt;This is very brief and windowed perspective of Throughput. If you have some other inputs as to how this is related to your domain then do put a few lines of comments.&lt;br/&gt; &lt;small style=&#39;font-family: georgia; color: rgb(51, 102, 255);&#39;&gt;Please leave your comment. You can subscribe to this blog by using the links under &quot;Subscribe&quot; section.&lt;/small&gt;&lt;/div&gt;&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=&#39;scribefire-powered&#39;&gt;Powered by &lt;a href=&#39;http://www.scribefire.com/&#39;&gt;ScribeFire&lt;/a&gt;.&lt;/p&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1907071224335910840/posts/default/6805791193754946021'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1907071224335910840/posts/default/6805791193754946021'/><link rel='alternate' type='text/html' href='http://embeddedlive.blogspot.com/2009/08/throughput-funda.html' title='Throughput funda&amp;#39;s'/><author><name>Deepz</name><uri>http://www.blogger.com/profile/16543298327846220464</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author></entry><entry><id>tag:blogger.com,1999:blog-1907071224335910840.post-3919915872560752538</id><published>2009-07-25T21:29:00.001+05:30</published><updated>2009-07-25T21:29:17.737+05:30</updated><title type='text'>The IDE and The Compiler</title><content type='html'>&lt;div xmlns=&#39;http://www.w3.org/1999/xhtml&#39;&gt;&lt;div style=&#39;text-align: justify;&#39;&gt;This is a very basic article. I would say for newbie&#39;s or for those who are misguided. Also, I was asked this question by some one recently. The question or rather statement &quot;&lt;span style=&#39;font-weight: bold;&#39;&gt;Tourbo C is a nice compiler for it has a very nice gui. Gcc gui is not good.&quot;&lt;/span&gt;&lt;br/&gt;&lt;br/&gt;Well the problem here is that we are getting confused with the compiler and the &lt;span style=&#39;font-weight: bold;&#39;&gt;IDE &lt;/span&gt;(Integrated Development Environment). The compiler is usually a parser ( Text paser for simplicity) that runs through a text file ( which we typically name with extensions like .c, .h etc) and feed it to this parser. The job of the parser ( or compiler hence forth) is to parse the file and output another file based on certain rules which should be adhered to by the writer of the text ( or code henceforth ). The other file that is usually output is object file. Note that as intermediate step the compiler generates assembly code which usally not output ( unless you tell the compiler to show you this specifically by a commandline option -S for gcc) . The object code which can be linked to form the executable. &lt;a href=&#39;http://en.wikipedia.org/wiki/COFF&#39; target=&#39;_blank&#39;&gt;&lt;span style=&#39;font-weight: bold;&#39;&gt;COFF &lt;/span&gt;&lt;/a&gt;&amp;amp; &lt;a href=&#39;http://en.wikipedia.org/wiki/Executable_and_Linkable_Format&#39; target=&#39;_blank&#39; style=&#39;font-weight: bold;&#39;&gt;ELF &lt;/a&gt;are common object file formats, however compiler writers are free to choose what the want. &lt;br/&gt;&lt;br/&gt;Now coming to the &lt;span style=&#39;font-weight: bold;&#39;&gt;IDE&lt;/span&gt;. IDE has really got nothing to do with your compiler. The key words are explained here&lt;br/&gt;&lt;span style=&#39;font-weight: bold;&#39;&gt;Integrated&lt;/span&gt;: Usually every compiler vendor comes up with his/her own Editor to help the coder to write his code. Why a specific editor? Typically, each compiler provides it own set of special key words etc which the editor can highlight is specific colors and other features like codesense are provided for the ease of the coder. &lt;br/&gt;&lt;span style=&#39;font-weight: bold;&#39;&gt;Development &lt;/span&gt;: Yeah! we all write code to do something or develop something&lt;br/&gt;&lt;span style=&#39;font-weight: bold;&#39;&gt;Environment &lt;/span&gt;: This is the key term. The IDE provides an environment for the coder where he doesn&#39;t need to know the intricacies of compiler and more low level details of how to use it. You can can just take the IDE and start writing your code without bothering about what are the command line arguments that need to be passed to compiler. Also, you need not worry about feeding the include paths etc ( not all IDE&#39;s have this feature). &lt;br/&gt;&lt;br/&gt;Now i try to defend &lt;span style=&#39;font-weight: bold;&#39;&gt;gcc&lt;/span&gt;. I have used gcc with two ( or three??) IDE&#39;s and it works great. The simple ones are dev-ccp &amp;amp; code::Blocks. The difficult ones are actually extinct now....codewright.  Note that the best part about gcc is that it is a single compiler that will allow you to compiler with a whole lot of customizations through the command line arguments. I remember a project where i was using gcc only for creating dependency files which used to get fed to a embedded compiler which unfortunately did not have the capability to make dependency files ( Folks at my previous firm will know about this!!).&lt;br/&gt;Why we need dependency file will be explained in another post soon.  Bis dan.....&lt;br/&gt; &lt;small style=&#39;font-family: georgia; color: rgb(51, 102, 255);&#39;&gt;Please leave your comment. You can subscribe to this blog by using the links under &quot;Subscribe&quot; section.&lt;/small&gt;&lt;/div&gt;&lt;br/&gt;&lt;br/&gt;&lt;div class=&#39;zemanta-pixie&#39;&gt;&lt;img src=&#39;http://img.zemanta.com/pixy.gif?x-id=36dedb24-d174-8304-9d6c-94b92fe12046&#39; alt=&#39;&#39; class=&#39;zemanta-pixie-img&#39;/&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=&#39;scribefire-powered&#39;&gt;Powered by &lt;a href=&#39;http://www.scribefire.com/&#39;&gt;ScribeFire&lt;/a&gt;.&lt;/p&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1907071224335910840/posts/default/3919915872560752538'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1907071224335910840/posts/default/3919915872560752538'/><link rel='alternate' type='text/html' href='http://embeddedlive.blogspot.com/2009/07/ide-and-compiler.html' title='The IDE and The Compiler'/><author><name>Deepz</name><uri>http://www.blogger.com/profile/16543298327846220464</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author></entry><entry><id>tag:blogger.com,1999:blog-1907071224335910840.post-1889718732694694931</id><published>2009-07-19T18:12:00.001+05:30</published><updated>2010-04-19T20:03:53.897+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="Automotive"/><category scheme="http://www.blogger.com/atom/ns#" term="Basic"/><category scheme="http://www.blogger.com/atom/ns#" term="funda"/><category scheme="http://www.blogger.com/atom/ns#" term="Info"/><category scheme="http://www.blogger.com/atom/ns#" term="Powertrain"/><title type='text'>Engine basics - Knocking</title><content type='html'>&lt;div xmlns=&#39;http://www.w3.org/1999/xhtml&#39;&gt;&lt;div style=&#39;text-align: justify; font-family: tahoma;&#39;&gt;This post talks a bit about a concept called &quot;Knocking&quot; which is very common in Spark Ignition Engines having very high compression ratio.&lt;br/&gt;&lt;span style=&#39;font-weight: bold;&#39;&gt;The question we need to answer first is what is Knocking?&lt;/span&gt;&lt;br/&gt;&quot;Knocking&quot; is a metallic pinging sound that is caused inside the engine cylinder &amp;amp; leads to high intensity vibrations in the Engine block ( usually causing metal fatigue in the cylinder walls). If the engine knocks for very long duration then this might have serious impact on the usability of the engine and on the engine life. &lt;br/&gt;&lt;span style=&#39;font-weight: bold;&#39;&gt;What causes &quot;Knocking&quot;?&lt;/span&gt;&lt;br/&gt;&lt;span style=&#39;font-weight: bold;&#39;&gt;Flame front&lt;/span&gt;:&lt;br/&gt;The power inside the cylinder which is generated when a spark ignites the air-fuel mixture leading to a flame front. The flame front is a high velocity pressure wave that travels, after originating near the spark plug, downwards to push the piston head and ensure that our engine keeps running. &lt;br/&gt;Now, what happens is that based on the fuel quality among many other factors there are certain spots inside the cylinder with some carbon deposits.If the cylinder temperature keeps rising due to ignitions then at some point of time these hot spots reach a temperature where they are capable to ignite the air fuel mixture or the yet unburnt gases (also called End gas). Simply put there is sufficient heat accumulation at certain points that these act as potential spark plugs. &lt;br/&gt;&lt;span style=&#39;font-weight: bold;&#39;&gt;The Problem&lt;/span&gt;:&lt;br/&gt;This causes a problem because we do not have any control over these spontaneously created spark plugs ( so to say). This means that they can ignite the end gas at any point of time. In homogeneous operation of engine ( more about this mode in future posts), the mixture is fairly rich and these hot spots have energy sufficient to create a ignition of the air-fuel mixture.  This phenomenon  is often known as &quot;&lt;span style=&#39;font-weight: bold;&#39;&gt;Detonation&lt;/span&gt;&quot;.This ignition causes a pressure wave to travel from the spot towards the periphery. This Flame-Front if collides with the flame front travelling from the spark plug will result  in wo very high pressure waves to bang into each other. This leads to very high pressure peaks which put extreme amounts of stress on the cylinder walls. Continuous &lt;span style=&#39;font-weight: bold;&#39;&gt;Knocking&lt;/span&gt; might lead to permanent stresses getting formed in the cylinder walls &amp;amp; the piston head which eventually will lead to their failure. &lt;br/&gt;&lt;span style=&#39;font-weight: bold;&#39;&gt;How to Avoid it &lt;/span&gt;?&lt;br/&gt;A few years back when &lt;span style=&#39;font-weight: bold;&#39;&gt;&quot;leaded Petrol&quot;&lt;/span&gt; used to rule the market the folks added something known as Anti-Knock in the petrol to ensure that it did not knock. This however, lead to higher amount of particulate matter in the exhaust and also was not good for the cylinder walls.The anti knock was a Lead compound which i cannot remember at this point of time.&lt;br/&gt;These days we use more of &quot;&lt;span style=&#39;font-weight: bold;&#39;&gt;Unleaded Petrol&quot;&lt;/span&gt; and there has to be  different mechanism to control the &lt;span style=&#39;font-weight: bold;&#39;&gt;&quot;Knocking&quot;&lt;/span&gt;. This is done these days by ensuring that the engine temperature doesn&#39;t reach very high ( then there is lesser chance of hot spots getting created). One of the methods employed to do this is EGR. Exhaust Gas Recirculation, ensures that he temperature of the engine come down apart from having benefits like enhanced fuel efficiency and reduced NOx in the exhaust. However, that is a different topic and will be dealt a little later. The other method used in conjunction with the EGR is spark retard. Spark retard will ensure that you ignite the air-fuel mixture late enough that there will be no pressure peaks. When we do not have pressure peaks the chances of knocking are lesser. &lt;br/&gt;Finally, use of high octane fuel will result in better combustion of the fuel and lesser hot spot contribution because of poor fuel quality. The reduction of hot-spots will result in reduced &lt;span style=&#39;font-weight: bold;&#39;&gt;Knocking&lt;/span&gt; even at higher engine temperatures. &lt;br/&gt;Some links that give more info on how it is detected etc&lt;a target=&#39;_blank&#39; href=&#39;http://www.streetdirectory.com/travel_guide/52987/mileage_and_fuel/what_is_engine_knocking.html&#39;&gt;&lt;br/&gt;[1]&lt;/a&gt;&lt;br/&gt;&lt;/div&gt;&lt;small style=&#39;font-family: georgia; color: rgb(51, 102, 255);&#39;&gt;Please leave your comment. You can subscribe to this blog by using the links under &quot;Subscribe&quot; section.&lt;/small&gt;&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;&lt;p class=&#39;scribefire-powered&#39;&gt;Powered by &lt;a href=&#39;http://www.scribefire.com/&#39;&gt;ScribeFire&lt;/a&gt;.&lt;/p&gt;&lt;br/&gt;&lt;br/&gt;&lt;div class=&#39;zemanta-pixie&#39;&gt;&lt;img src=&#39;http://img.zemanta.com/pixy.gif?x-id=1ac5ba00-55bc-8ed1-bf6b-41d2d1005446&#39; alt=&#39;&#39; class=&#39;zemanta-pixie-img&#39;/&gt;&lt;/div&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1907071224335910840/posts/default/1889718732694694931'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1907071224335910840/posts/default/1889718732694694931'/><link rel='alternate' type='text/html' href='http://embeddedlive.blogspot.com/2009/07/engine-basics-knocking.html' title='Engine basics - Knocking'/><author><name>Deepz</name><uri>http://www.blogger.com/profile/16543298327846220464</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author></entry><entry><id>tag:blogger.com,1999:blog-1907071224335910840.post-3591971416476707134</id><published>2009-07-17T16:42:00.001+05:30</published><updated>2009-07-17T16:42:20.245+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="Info"/><title type='text'>No Posts for some time</title><content type='html'>&lt;div xmlns=&#39;http://www.w3.org/1999/xhtml&#39;&gt;&lt;div style=&#39;text-align: justify; font-family: tahoma;&#39;&gt;I have been busy with my Targetlink &amp;amp; Simulink Modelling activity &amp;amp; also a bit held up with the Income Tax Filing process ( Though this time it is quite simple &amp;amp; i love it !!). There have been some sawtooth waveforms formed by the BSE Sensex index of late &amp;amp; this is giving me some sleepless nights....Hope to put in some interesting stuff soon....&lt;br/&gt;&lt;/div&gt;&lt;span style=&#39;font-family: tahoma;&#39;&gt;&lt;br style=&#39;font-family: tahoma;&#39;/&gt;&lt;br/&gt;&lt;/span&gt;&lt;br/&gt;&lt;br/&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=&#39;scribefire-powered&#39;&gt;Powered by &lt;a href=&#39;http://www.scribefire.com/&#39;&gt;ScribeFire&lt;/a&gt;.&lt;/p&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1907071224335910840/posts/default/3591971416476707134'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1907071224335910840/posts/default/3591971416476707134'/><link rel='alternate' type='text/html' href='http://embeddedlive.blogspot.com/2009/07/no-posts-for-some-time.html' title='No Posts for some time'/><author><name>Deepz</name><uri>http://www.blogger.com/profile/16543298327846220464</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author></entry><entry><id>tag:blogger.com,1999:blog-1907071224335910840.post-1611264606719844773</id><published>2009-07-03T14:38:00.000+05:30</published><updated>2009-07-03T14:39:13.336+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="Basic"/><category scheme="http://www.blogger.com/atom/ns#" term="C coding"/><category scheme="http://www.blogger.com/atom/ns#" term="Embedded Software"/><category scheme="http://www.blogger.com/atom/ns#" term="funda"/><title type='text'>Const Keyword - Coding Myth 3</title><content type='html'>&lt;div xmlns=&#39;http://www.w3.org/1999/xhtml&#39;&gt;&lt;span style=&#39;font-family: sans-serif;&#39;&gt;&lt;span style=&#39;font-family: tahoma;&#39;&gt;This post talks about the &quot;C&quot; keyword &quot;const&quot;. It is very often thought that making a variable &quot;const&quot; ensures that it gets placed in the non-volatile memory (ROM or flash). But how true is this?&lt;/span&gt;&lt;br style=&#39;font-family: tahoma;&#39;/&gt;&lt;br style=&#39;font-family: tahoma;&#39;/&gt;&lt;span style=&#39;font-family: tahoma;&#39;&gt;Well to start with w.r.t the ansi &quot;C&quot; compiler, the &quot;const&quot; keyword just tells the compiler that the user doesn&#39;t intend to modify the variable. &lt;/span&gt;&lt;br style=&#39;font-family: tahoma;&#39;/&gt;&lt;span style=&#39;font-family: tahoma;&#39;&gt;E.g.&lt;/span&gt;&lt;br/&gt;&lt;span style=&#39;font-family: Courier New;&#39;&gt;           const unsigned int Gctrl_NoOfGears= 10;&lt;/span&gt;&lt;br/&gt;&lt;span style=&#39;font-family: tahoma;&#39;&gt;so if i try to do this&lt;/span&gt;&lt;br/&gt;&lt;span style=&#39;font-family: Courier New;&#39;&gt;           Gctrl_NoOfGears +=1;&lt;/span&gt;&lt;br/&gt;&lt;span style=&#39;font-family: tahoma;&#39;&gt;I can either except a warning or an error. something like this&lt;/span&gt;&lt;br style=&#39;font-family: tahoma;&#39;/&gt;&lt;span style=&#39;font-family: tahoma;&#39;&gt;error: assignment of read-only variable `Gctrl_NoOfGears&#39;&lt;/span&gt; &lt;br style=&#39;font-family: tahoma;&#39;/&gt;&lt;span style=&#39;font-family: tahoma;&#39;&gt;However, does this warrant me that the variable is now placed inside the memory in an non-volatile area.&lt;/span&gt;&lt;br style=&#39;font-family: tahoma;&#39;/&gt;&lt;span style=&#39;font-family: tahoma;&#39;&gt;Well, the answer is it is compiler (settings) dependent. &lt;/span&gt;&lt;br style=&#39;font-family: tahoma;&#39;/&gt;&lt;span style=&#39;font-weight: bold; font-family: tahoma;&#39;&gt;Why?&lt;/span&gt;&lt;br style=&#39;font-family: tahoma;&#39;/&gt;&lt;span style=&#39;font-family: tahoma;&#39;&gt;Most embedded compilers are very smart and automatically place the constants in the ROM/ flash area. However, some times the flash or ROM is used only as program memory and &lt;/span&gt;&lt;span style=&#39;font-weight: bold; font-family: tahoma;&#39;&gt;NOT &lt;/span&gt;&lt;span style=&#39;font-family: tahoma;&#39;&gt;as data memory. In which case there is no way (directly) that the compiler can place this in the program memory. Also In these processors the program memory is not directly accesible because the program &amp;amp; data are stored in differrent memory location &amp;amp; have different busses to access.  In such processors writing &lt;/span&gt;&lt;br/&gt;&lt;/span&gt;&lt;div style=&#39;text-align: center;&#39;&gt;&lt;span style=&#39;font-family: sans-serif;&#39;&gt;&lt;span style=&#39;font-family: Courier New;&#39;&gt;const char DisplayStr[] = &quot;Welcome&quot;;&lt;/span&gt;&lt;/span&gt;&lt;br/&gt;&lt;span style=&#39;font-family: sans-serif;&#39;/&gt;&lt;/div&gt;&lt;span style=&#39;font-family: sans-serif;&#39;&gt;&lt;span style=&#39;font-family: tahoma;&#39;&gt;will not cause DisplayStr to go into the ROM area. &lt;/span&gt;&lt;br style=&#39;font-family: tahoma;&#39;/&gt;&lt;span style=&#39;font-family: tahoma;&#39;&gt;You will have to do this via some compiler pragma&#39;s like&lt;/span&gt;&lt;br/&gt;&lt;/span&gt;&lt;div style=&#39;text-align: center;&#39;&gt;&lt;span style=&#39;font-family: sans-serif;&#39;&gt;&lt;span style=&#39;font-family: Courier New;&#39;&gt;#pragma section start ROM&lt;/span&gt;&lt;/span&gt;&lt;br style=&#39;font-family: Courier New;&#39;/&gt;&lt;span style=&#39;font-family: sans-serif;&#39;/&gt;&lt;span style=&#39;font-family: Courier New;&#39;&gt;const char DisplayStr[] = &quot;Welcome&quot;;&lt;/span&gt;&lt;br style=&#39;font-family: Courier New;&#39;/&gt;&lt;span style=&#39;font-family: Courier New;&#39;&gt;#pragma section end ROM&lt;/span&gt;&lt;br/&gt;&lt;/div&gt;&lt;span style=&#39;font-family: tahoma;&#39;&gt;to make the compiler understand that it has to place the value in ROM &amp;amp; not in the RAM area.&lt;/span&gt;&lt;br style=&#39;font-family: tahoma;&#39;/&gt;&lt;span style=&#39;font-weight: bold; font-family: tahoma;&#39;&gt;Do I have to worry?&lt;/span&gt;&lt;br style=&#39;font-family: tahoma;&#39;/&gt;&lt;span style=&#39;font-family: sans-serif;&#39;&gt;&lt;span style=&#39;font-family: tahoma;&#39;&gt;As a novice or some one programming for a simple system &lt;/span&gt;&lt;span style=&#39;font-weight: bold; font-family: tahoma;&#39;&gt;NO. &lt;/span&gt;&lt;span style=&#39;font-family: tahoma;&#39;&gt;However, when you are running low on resources and for various other reasons it makes sense to have a look at what the compilers is doing when you say &quot;const&quot;. I repeat &lt;/span&gt;&lt;span style=&#39;font-weight: bold; font-family: tahoma;&#39;&gt;MOST &lt;/span&gt;&lt;span style=&#39;font-family: tahoma;&#39;&gt;compilers are clever enough to put the data into the &lt;/span&gt;&lt;span style=&#39;font-weight: bold; font-family: tahoma;&#39;&gt;ROM &lt;/span&gt;&lt;span style=&#39;font-family: tahoma;&#39;&gt;automatically. &lt;/span&gt;&lt;br/&gt;The best practice is always to have a glance into the map file to ensure that you have everything at the right places. &lt;br/&gt;Also, in one of the future posts i will be talking about another usages of const and how some constants are present even without your knowledge ( also little talk about const volatile...the common question in any interview on &quot;C&quot;).&lt;br/&gt;&lt;br/&gt;&lt;/span&gt;&lt;small style=&#39;font-family: georgia; color: rgb(51, 102, 255);&#39;&gt;Please leave your comment. You can subscribe to this blog by using the links under &quot;Subscribe&quot; section. &lt;/small&gt;&lt;br/&gt;&lt;span style=&#39;font-family: sans-serif;&#39;&gt;&lt;br/&gt;Previous coding myths here {&lt;a href=&#39;http://embeddedlive.blogspot.com/2009/06/when-size-does-matter-coding-myth-1.html&#39; target=&#39;_blank&#39;&gt;1&lt;/a&gt;} ,{&lt;a href=&#39;http://embeddedlive.blogspot.com/2009/06/inlining-code-coding-myth-2.html&#39; target=&#39;_blank&#39;&gt;2&lt;/a&gt;}&lt;br/&gt;&lt;/span&gt;&lt;br/&gt;&lt;br/&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=&#39;scribefire-powered&#39;&gt;Powered by &lt;a href=&#39;http://www.scribefire.com/&#39;&gt;ScribeFire&lt;/a&gt;.&lt;/p&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1907071224335910840/posts/default/1611264606719844773'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1907071224335910840/posts/default/1611264606719844773'/><link rel='alternate' type='text/html' href='http://embeddedlive.blogspot.com/2009/07/const-keyword-coding-myth-3.html' title='Const Keyword - Coding Myth 3'/><author><name>Deepz</name><uri>http://www.blogger.com/profile/16543298327846220464</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author></entry><entry><id>tag:blogger.com,1999:blog-1907071224335910840.post-8221676091370694934</id><published>2009-06-18T21:28:00.001+05:30</published><updated>2009-06-18T21:28:05.102+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="Automotive"/><category scheme="http://www.blogger.com/atom/ns#" term="Info"/><category scheme="http://www.blogger.com/atom/ns#" term="Powertrain"/><title type='text'>Which came first 2-stroke or 4-stroke?</title><content type='html'>&lt;div xmlns=&#39;http://www.w3.org/1999/xhtml&#39;&gt;&lt;div style=&#39;text-align: justify;&#39;&gt;We all know this and it has been told to us again and again...&lt;br/&gt;4-stroke engines are better than 2-stroke engines. They are more efficient, less polluting etc. Also we know that 2 stroke engines make more power ( Because they have a power stroke every crank cycle!!). However, did any of you think &lt;span style=&#39;font-weight: bold;&#39;&gt;why was there a 2-stroke engine in the first place if 4-stroke engines are so good.&lt;/span&gt;&lt;br/&gt;Infact i just &lt;a href=&#39;http://en.wikipedia.org/wiki/Two-stroke&#39; target=&#39;_blank&#39;&gt;wikied&lt;/a&gt; this&lt;br/&gt;&lt;/div&gt;&lt;blockquote&gt;Invention of the two-stroke cycle is attributed to Scottish engineer Dugald Clerk who in 1881 patented his design, his engine having a separate charging cylinder.&lt;br/&gt;&lt;/blockquote&gt;Now also &lt;a href=&#39;http://en.wikipedia.org/wiki/Four-stroke_engine&#39; target=&#39;_blank&#39;&gt;wiki &lt;/a&gt;says&lt;br/&gt;&lt;blockquote&gt;The four-stroke engine was first patented by Eugenio Barsanti and Felice Matteucci in &lt;span style=&#39;font-weight: bold;&#39;&gt;1854&lt;/span&gt;, followed by a first prototype in 1860. It was also conceptualized by French engineer, Alphonse Beau de Rochas in 1862.&lt;br/&gt;&lt;/blockquote&gt;&lt;div style=&#39;text-align: justify;&#39;&gt;As it is clear 1854 is before 1881, why did some one build an apparently less efficient version of the engine?&lt;br/&gt;I believe the answer is as follows&lt;br/&gt;&lt;/div&gt;&lt;ul style=&#39;text-align: justify;&#39;&gt;&lt;li style=&#39;text-align: justify;&#39;&gt;The 2-stroke engine is much lighter than its 4-stroke counterpart. It has no valves (intake or exhaust) hence no Camshafts &amp;amp; Cams. This also translates to lesser needs of lubrication. You can just add the lubricant to your fuel and you should be good.&lt;/li&gt;&lt;li style=&#39;text-align: justify;&#39;&gt;They could be constructed in lesser space because of lesser number of components, making them a good option for lawn mowers, power saw&#39;s etc. &lt;br/&gt;&lt;/li&gt;&lt;/ul&gt;Due to the above factors it made the 2-stoke engines much cheaper than the 4-stroke versions. Modern 2-stroke engines have started employing &lt;a href=&#39;http://en.wikipedia.org/wiki/Gasoline_Direct_Injection#In_two-stroke_engines&#39; target=&#39;_blank&#39;&gt;Gasoline direct Injection&lt;/a&gt;. &lt;br/&gt;The 2-stroke has come a long way and still remain favourites among hard core bikers who drool at the power produced by these machines ( Remember the Rx-100). They have their issues when it comes to thermal handling ( they get heated faster and need to be cooled more) but that can be handled by having bigger engine cooling fins ( Greater the surface area of the fins better cooling!!). So next time you ride a RX...remember that they came after the 4-stroke versions.&lt;br/&gt;&lt;br/&gt;&lt;small style=&#39;font-family: georgia; color: rgb(51, 102, 255);&#39;&gt;Please leave your comment if you have one. You can subscribe to this blog by using the links under &quot;Subscribe&quot; section.&lt;/small&gt;&lt;br/&gt;&lt;br/&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=&#39;scribefire-powered&#39;&gt;Powered by &lt;a href=&#39;http://www.scribefire.com/&#39;&gt;ScribeFire&lt;/a&gt;.&lt;/p&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1907071224335910840/posts/default/8221676091370694934'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1907071224335910840/posts/default/8221676091370694934'/><link rel='alternate' type='text/html' href='http://embeddedlive.blogspot.com/2009/06/which-came-first-2-stroke-or-4-stroke.html' title='Which came first 2-stroke or 4-stroke?'/><author><name>Deepz</name><uri>http://www.blogger.com/profile/16543298327846220464</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author></entry><entry><id>tag:blogger.com,1999:blog-1907071224335910840.post-2375405098037915034</id><published>2009-06-14T15:12:00.002+05:30</published><updated>2009-06-14T15:18:52.842+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="Automotive"/><category scheme="http://www.blogger.com/atom/ns#" term="funda"/><category scheme="http://www.blogger.com/atom/ns#" term="Info"/><category scheme="http://www.blogger.com/atom/ns#" term="Powertrain"/><title type='text'>Fuel Injection - Evolution Journey-II</title><content type='html'>&lt;div xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;&lt;span style=&quot;font-family:tahoma;&quot;&gt;This is a fully automotive powertrain article.&lt;br /&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;Disclaimer&lt;/span&gt;: I am a novice in this area. If experts read this kindly correct...&lt;br /&gt;&lt;/span&gt;&lt;a onblur=&quot;try {parent.deselectBloggerImageGracefully();} catch(e) {}&quot; href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj1EPTZd8BYeU9l3efQ9pDaf_MGWxxK8IYu5jYrT_o4dFBeZx2ynO6h2y2Mp0ZatpaBuu7Kr-iYlKmEslNVrqUAh_jUJnJgWJ2wkG9KS1KFWRinjT5g0Zf96ZKdjo8h2jPn8RnO1j0MXbE/s1600-h/temp.png&quot;&gt;&lt;img style=&quot;margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 276px; height: 49px;&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj1EPTZd8BYeU9l3efQ9pDaf_MGWxxK8IYu5jYrT_o4dFBeZx2ynO6h2y2Mp0ZatpaBuu7Kr-iYlKmEslNVrqUAh_jUJnJgWJ2wkG9KS1KFWRinjT5g0Zf96ZKdjo8h2jPn8RnO1j0MXbE/s320/temp.png&quot; alt=&quot;&quot; id=&quot;BLOGGER_PHOTO_ID_5347117860443229490&quot; border=&quot;0&quot; /&gt;&lt;/a&gt;&lt;br /&gt;&lt;span style=&quot;font-family:tahoma;&quot;&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;Q: &lt;span style=&quot;font-weight: bold;&quot;&gt;What are the different fuel injection methods used?&lt;/span&gt;&lt;br /&gt;Fuel injection systems evolved over the years from being a simple Manifold injection to DI ( Direct injection). The injection of the fuel into the Intake Manifold based on the Air Mass that is currently sucked into the cylinder is controlled either electronically or by mechanical methods. This is typically a function of the engine load. The engine load can roughly be determined by the throttle opening. The terms &quot;Full-Load&quot; ( i.e. Throttle valve is fully open) and &quot;Idle&quot; (i.e. when the Throttle valve is closed &amp;amp;amp; the vehicle is stationary) are very frequently used in the discussions further.&lt;br /&gt;After the SPFI ( Single point fuel injection) where the fuel was sprayed into the manifold the next thing that became very popular was multi point fule injection (MPFI). Here multiple injectors were placed at suitable positions in the intake manifold to get finer control over the air-fuel mixture. Also having multiple injectors ensured that the injector closest to the cylinder going into suction stroke could be activated. In some cases this is called Port Fuel Injection (PFI). This provided also the following benefits:&lt;span style=&quot;font-weight: bold;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;ul style=&quot;text-align: justify;&quot;&gt;&lt;li&gt; Fuel going into each cylinder could be precicely controlled.&lt;/li&gt;&lt;li&gt;Air &amp;amp; fuel would get mixed just before inlet into the cylinder. This ensured that the atomised fuel did not have condensation problems. i.e. in manifold injection with single injector the air-fuel mixture when suddenly expanded in the cylinder under cold start conditions the fuel would condense &amp;amp; form larger particles inside the cylinder which led to higher emissions&lt;/li&gt;&lt;/ul&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;The &lt;span style=&quot;font-weight: bold;&quot;&gt;MPFI&lt;/span&gt; injection systems came in two variants, though this is not really something great !!..&lt;br /&gt;&lt;/div&gt;&lt;ul style=&quot;text-align: justify;&quot;&gt;&lt;li&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;Batch Fired&lt;/span&gt; : In this all the injectors for one bank of cylinders where activated in one shot. i.e. for a 4 cylinder engine, injectors for cylinder 1 &amp;amp; 4 were activated together similarly 2 &amp;amp;3.&lt;/li&gt;&lt;li&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;Sequentially fired:&lt;/span&gt; Here the injectors where activated sequentially based on which cylinder was going into suction stroke.&lt;/li&gt;&lt;/ul&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;Finally came the Direct injection. The direction injection opened up new domains of controlling the air fuel mixture because now only air would enter the cylinder and it could be the &lt;span style=&quot;font-weight: bold;&quot;&gt;ECU&lt;/span&gt; that would control the fuel being injected into the cylinder. This ensured that by injecting at different points inside the cylinder &amp;amp; by different cylinder head profile one would achive higher spread of the atomized fuel. This lead to better flame front propagation, ensuring higher power output.&lt;br /&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;Why did we not go for Direct Injection to start with ?&lt;/span&gt;&lt;br /&gt;The  manufacturing processes in earlier days did not provide us with methods to have injectors that could bear the very high pressures generated inside the cylinder. Also, the fuel injector tip has to bear extreme temperatures which are generated inside the cylinder. Also, the pump which pumps fuel into the injector needs to generate very high pressures because if fuel is injected in the later stages of compression ( like it is done in Stratified mode of operation).  The injector nozzel design also has undergone many design changes to ensure that a extremly fine spray with precise control on droplet size could be created. &lt;span style=&quot;font-weight: bold;&quot;&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=&quot;scribefire-powered&quot;&gt;Powered by &lt;a href=&quot;http://www.scribefire.com/&quot;&gt;ScribeFire&lt;/a&gt;.&lt;/p&gt;&lt;/span&gt;  &lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1907071224335910840/posts/default/2375405098037915034'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1907071224335910840/posts/default/2375405098037915034'/><link rel='alternate' type='text/html' href='http://embeddedlive.blogspot.com/2009/06/fuel-injection-evolution-journey-ii.html' title='Fuel Injection - Evolution Journey-II'/><author><name>Deepz</name><uri>http://www.blogger.com/profile/16543298327846220464</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj1EPTZd8BYeU9l3efQ9pDaf_MGWxxK8IYu5jYrT_o4dFBeZx2ynO6h2y2Mp0ZatpaBuu7Kr-iYlKmEslNVrqUAh_jUJnJgWJ2wkG9KS1KFWRinjT5g0Zf96ZKdjo8h2jPn8RnO1j0MXbE/s72-c/temp.png" height="72" width="72"/></entry><entry><id>tag:blogger.com,1999:blog-1907071224335910840.post-1780488389625176076</id><published>2009-06-09T22:51:00.001+05:30</published><updated>2009-06-09T22:51:41.627+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="C coding"/><category scheme="http://www.blogger.com/atom/ns#" term="Embedded Software"/><category scheme="http://www.blogger.com/atom/ns#" term="Geek"/><category scheme="http://www.blogger.com/atom/ns#" term="Intermediate"/><title type='text'>Inlining code - Coding Myth 2</title><content type='html'>&lt;div xmlns=&#39;http://www.w3.org/1999/xhtml&#39;&gt;&lt;span style=&#39;font-family: tahoma;&#39;&gt;This post is regarding the inline keyword. &lt;/span&gt;&lt;br style=&#39;font-family: tahoma;&#39;/&gt;&lt;span style=&#39;font-family: tahoma;&#39;&gt;Very often we learn C &amp;amp; C++ together and end up mixing one language with the other. I learnt this the hard way when i found out in some debate that the &quot;inline&quot; keyword doesn&#39;t belong to the C language.....Boohooo!!..&lt;/span&gt;&lt;br style=&#39;font-family: tahoma;&#39;/&gt;&lt;span style=&#39;font-family: tahoma;&#39;&gt;Inline keyword natively belongs to C++.  It serves the purpose of just ensuring that the function is pasted inline instead of having a call to the function at every instance of the function call.&lt;/span&gt;&lt;br style=&#39;font-family: tahoma;&#39;/&gt;&lt;span style=&#39;font-family: tahoma;&#39;&gt;It was not a part of C. In &quot;C&quot; we achive similar functionality by using what are termed as &quot;Function Like Macro&#39;s&quot;.&lt;/span&gt;&lt;br/&gt;E.g. &lt;br/&gt;&lt;span style=&#39;font-family: Courier New;&#39;&gt;#define Max(a,b)  ((a)&amp;gt;(b)?(a):(b))&lt;/span&gt;&lt;br/&gt;&lt;span style=&#39;font-family: tahoma;&#39;&gt;The funciton like macros have a major disadvantage over Inline functions and that is the blindness to the compiler. &lt;/span&gt;&lt;br style=&#39;font-family: tahoma;&#39;/&gt;&lt;span style=&#39;font-family: tahoma;&#39;&gt;#define macro&#39;s are processed by what is known as the &quot;C Preprocessor&quot;. The preprocessor looks for the macros and does a macro pasting operation. Which means that where ever in the above example Max is used the equivalent code is pasted. &lt;/span&gt;&lt;br/&gt;E.g &lt;br/&gt;&lt;span style=&#39;font-family: Courier New;&#39;&gt;y = Max(5,6); is equivalent to y = ((5)&amp;gt;(6)?(5):(6));&lt;/span&gt;&lt;br/&gt;&lt;span style=&#39;font-weight: bold;&#39;&gt;Then what is this blindness funda?&lt;/span&gt;&lt;br/&gt;Well if iwrote this code&lt;br/&gt;&lt;span style=&#39;font-family: Courier New;&#39;&gt;int *ptr;&lt;/span&gt;&lt;br style=&#39;font-family: Courier New;&#39;/&gt;&lt;span style=&#39;font-family: Courier New;&#39;&gt;y = Max(ptr,&#39;5&#39;). &lt;br/&gt;&lt;/span&gt;&lt;span style=&#39;font-family: tahoma;&#39;&gt;Then even this would work as for the Macro-Processor. Infact in this particular example even the compiler will not complain. However, if this was a inline function then the compiler would have been flag an error.  So it is easy to see that the inline key word has benifits over the #define macro.&lt;/span&gt;&lt;br/&gt;&lt;span style=&#39;font-weight: bold;&#39;&gt;Now some interesting stuff&lt;/span&gt;&lt;br/&gt;&lt;ul&gt;&lt;li&gt;-&lt;span style=&#39;font-family: tahoma;&#39;&gt; Did you know that the inline keyword is just a request to the compiler. The compiler might choose to ignore you fully and would just make the function a normal function if it feels that by making it inline it is losing out on optimization.This is in contrast with #define function like macro&#39;s which are outside of the compiler&#39;s control. &lt;/span&gt;&lt;br style=&#39;font-family: tahoma;&#39;/&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ul style=&#39;font-family: tahoma;&#39;&gt;&lt;li&gt;- Modern&lt;span style=&#39;font-weight: bold;&#39;&gt; C &lt;/span&gt;compilers provide you various methods of inlining function by compiler extensions. E.g some compilers provide pragma&#39;s &lt;/li&gt;&lt;/ul&gt;&lt;span style=&#39;font-family: Courier New;&#39;&gt;#pragma InlineStart &lt;/span&gt;&lt;br style=&#39;font-family: Courier New;&#39;/&gt;&lt;span style=&#39;font-family: Courier New;&#39;&gt;void Inlinefunction(void)&lt;/span&gt;&lt;br style=&#39;font-family: Courier New;&#39;/&gt;&lt;span style=&#39;font-family: Courier New;&#39;&gt;#pragma InlineEnd&lt;/span&gt;&lt;br style=&#39;font-family: Courier New;&#39;/&gt;&lt;span style=&#39;font-family: tahoma;&#39;&gt;or things like&lt;/span&gt;&lt;br style=&#39;font-family: Courier New;&#39;/&gt;&lt;span style=&#39;font-family: Courier New;&#39;&gt;@inline void Inlinefunction(void)&lt;/span&gt;&lt;br/&gt;&lt;ul style=&#39;font-family: tahoma;&#39;&gt;&lt;li&gt;Inlining is very useful to ensure modularity &amp;amp; keep your code clean. However, In &quot;C&quot; if this was natively available then we embedded users would not have resorted to function like macro&#39;s.&lt;/li&gt;&lt;li&gt;Evils of the keyword &quot;inline&quot;.....Well it is difficult to debug your inline function because there is no call to the function and also it is not really visible to your debugger:-(. &lt;br/&gt;&lt;/li&gt;&lt;/ul&gt;&lt;span style=&#39;font-family: tahoma;&#39;&gt;Now that we have some idea of the keyword &quot;Inline&quot;, you can try to check out the statements made above using our good old &lt;/span&gt;&lt;span style=&#39;font-weight: bold; font-family: tahoma;&#39;&gt;GCC&lt;/span&gt;&lt;span style=&#39;font-family: tahoma;&#39;&gt; compiler with &lt;/span&gt;&lt;span style=&#39;font-weight: bold; font-family: tahoma;&#39;&gt;&quot;-S&quot;&lt;/span&gt;&lt;span style=&#39;font-family: tahoma;&#39;&gt; option and have a look at the generated assembly code. &lt;/span&gt;&lt;br style=&#39;font-family: tahoma;&#39;/&gt;&lt;small style=&#39;font-family: georgia; color: rgb(51, 102, 255);&#39;&gt;Please leave your comment. You can subscribe to this blog by using the links under &quot;Subscribe&quot; section. &lt;/small&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=&#39;scribefire-powered&#39;&gt;Powered by &lt;a href=&#39;http://www.scribefire.com/&#39;&gt;ScribeFire&lt;/a&gt;.&lt;/p&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://embeddedlive.blogspot.com/feeds/1780488389625176076/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://embeddedlive.blogspot.com/2009/06/inlining-code-coding-myth-2.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1907071224335910840/posts/default/1780488389625176076'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1907071224335910840/posts/default/1780488389625176076'/><link rel='alternate' type='text/html' href='http://embeddedlive.blogspot.com/2009/06/inlining-code-coding-myth-2.html' title='Inlining code - Coding Myth 2'/><author><name>Deepz</name><uri>http://www.blogger.com/profile/16543298327846220464</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1907071224335910840.post-6751108674342394364</id><published>2009-06-06T11:19:00.001+05:30</published><updated>2009-06-06T11:19:03.372+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="Automotive"/><category scheme="http://www.blogger.com/atom/ns#" term="funda"/><category scheme="http://www.blogger.com/atom/ns#" term="Info"/><category scheme="http://www.blogger.com/atom/ns#" term="Powertrain"/><title type='text'>Fuel Injection - Evolution Journey</title><content type='html'>&lt;div xmlns=&#39;http://www.w3.org/1999/xhtml&#39;&gt;&lt;div style=&#39;text-align: justify;&#39;&gt;This is a fully automotive powertrain article. &lt;br/&gt;&lt;span style=&#39;font-weight: bold;&#39;&gt;Disclaimer&lt;/span&gt;: I am a novice in this area. If experts read this kindly correct...&lt;br/&gt;&lt;br/&gt;Q: &lt;span style=&#39;font-weight: bold;&#39;&gt;Why &amp;amp; How did FI ( Fuel Injection) systems evolve?&lt;/span&gt;&lt;br/&gt;For a long time carburetor based engines dominated the automotive world. The were good and could make your car run smoothly. However, increasing emission norms &amp;amp; better systems being used by the air planes eventually led to their extinction  in the four-wheeler world ( Though my XCD-135 bike still uses a carburetor for managing the air-fuel mixture). The major things that led to the death of carburetor engines are :&lt;br/&gt;&lt;/div&gt;&lt;ul style=&#39;text-align: justify;&#39;&gt;&lt;li&gt;Too many compensations where needed making the design look like spaghetti code. The were compensations for idling, for cold start among other things.&lt;/li&gt;&lt;li&gt;Carburetor icing had plagued high altitude flying machines, this led to development of what we today know as &lt;span style=&#39;font-weight: bold;&#39;&gt;EFI&lt;/span&gt; systems ( Electronic Fuel Injection). They started off as &lt;span style=&#39;font-weight: bold;&#39;&gt;SPFI  (&lt;/span&gt;Single Point Fuel Injection) &amp;amp; then evolved into &lt;span style=&#39;font-weight: bold;&#39;&gt;MPFI&lt;/span&gt; ( Multi Point Fuel Injection)&lt;/li&gt;&lt;/ul&gt;&lt;div style=&#39;text-align: justify;&#39;&gt;With the new &lt;span style=&#39;font-weight: bold;&#39;&gt;FI&lt;/span&gt; systems it was necessary to have electronics to control the fuel injection. This was done by having solenoid controlled fuel injectors. These injectors could be actuated by providing what is generally called the &quot;&lt;span style=&#39;font-weight: bold;&#39;&gt;Fuel Pulse&quot;&lt;/span&gt; and the timing &amp;amp; the duration (pulse width) of the pulse could control the amount of fuel sprayed into the manifold. The Advantages of  the new Fuel Injection system ( Now of course its quite old) were :&lt;br/&gt;&lt;/div&gt;&lt;ul style=&#39;text-align: justify;&#39;&gt;&lt;li&gt;Better efficiency due to the fact that the fuel-air mixture could be made &lt;span style=&#39;font-weight: bold;&#39;&gt;LEAN&lt;/span&gt; or &lt;span style=&#39;font-weight: bold;&#39;&gt;RICH&lt;/span&gt; ( not fat for god sake !!). &lt;br/&gt;&lt;/li&gt;&lt;li&gt;No carburetor icing wherever it was applicable. Just in case you are wondering what is Carburetor icing, it is the basically formation of ice in the carb&#39;s venturi due to condensation of humid cold air (due to further drop in the venturi). This is often accompanied re-conversion of the fuel from its atomized format to more liquid format.&lt;/li&gt;&lt;li&gt;EFI systems will also help in reduction of NOx emissions due to which it is better complaince with emission norms is possible.  &lt;/li&gt;&lt;/ul&gt;&lt;div style=&#39;text-align: justify;&#39;&gt;The story is more compilicated than what has happened so far because soon a need was felt to control the ignition, Cams, valves and what not. There was also emergence of the EGR concept ( which was present even the carb engine days). The compensations &amp;amp; corrections that were needed to the various parameters based on vehicle parameters like Engine RPM, AC ( air conditioning), vehicle speed  ABS etc has transformed the electronic control systems into a work of art.&lt;br/&gt;In the next post on this topic, I will be going into the various systems that influence a engine &amp;amp; how the EMS ( Engine management system) handles them. &lt;br/&gt;more on....&lt;br/&gt;&lt;a href=&#39;http://en.wikipedia.org/wiki/Carburetor_icing&#39; target=&#39;_blank&#39;&gt;carb icing&lt;/a&gt;&lt;br/&gt;&lt;a href=&#39;http://www.hdtalking.com/diagnostics_and_fuel_injection_related/1210-efi_tutorial.html&#39; target=&#39;_blank&#39;&gt;EFI&lt;/a&gt;&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;&lt;small style=&#39;font-family: georgia; color: rgb(51, 102, 255);&#39;&gt;Please leave your comment if you have one. You can subscribe to this blog by using the links under &quot;Subscribe&quot; section. &lt;/small&gt;&lt;br/&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=&#39;scribefire-powered&#39;&gt;Powered by &lt;a href=&#39;http://www.scribefire.com/&#39;&gt;ScribeFire&lt;/a&gt;.&lt;/p&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://embeddedlive.blogspot.com/feeds/6751108674342394364/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://embeddedlive.blogspot.com/2009/06/fuel-injection-evolution-journey.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1907071224335910840/posts/default/6751108674342394364'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1907071224335910840/posts/default/6751108674342394364'/><link rel='alternate' type='text/html' href='http://embeddedlive.blogspot.com/2009/06/fuel-injection-evolution-journey.html' title='Fuel Injection - Evolution Journey'/><author><name>Deepz</name><uri>http://www.blogger.com/profile/16543298327846220464</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1907071224335910840.post-3682746103810270637</id><published>2009-06-04T21:24:00.001+05:30</published><updated>2009-06-04T21:24:49.637+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="C coding"/><category scheme="http://www.blogger.com/atom/ns#" term="Embedded Software"/><category scheme="http://www.blogger.com/atom/ns#" term="funda"/><category scheme="http://www.blogger.com/atom/ns#" term="Geek"/><category scheme="http://www.blogger.com/atom/ns#" term="Intermediate"/><title type='text'>When Size does matter - Coding Myth 1</title><content type='html'>&lt;div xmlns=&#39;http://www.w3.org/1999/xhtml&#39;&gt;&lt;span style=&#39;font-family: tahoma;&#39;&gt;Again i am slow in updating this blog and this time it is really because I was busy with some GUI building activity on Matlab. I will write more about in another post. However, today the topic is more about &quot;C&quot; coding myths.&lt;/span&gt;&lt;br/&gt;&lt;br style=&#39;font-family: tahoma;&#39;/&gt;&lt;span style=&#39;font-family: tahoma;&#39;&gt;Some dudes I have met write really write complicated code like the one below stating that it will be more efficient. Some how they seem to feel that compact code ( in terms of number of lines &amp;amp; characters used) translates directly into lesser code volume in the microcontroller. I just tried this....&lt;/span&gt;&lt;br/&gt;&lt;br/&gt;&lt;span style=&#39;font-weight: bold;&#39;&gt;Code:&lt;/span&gt;&lt;br/&gt;&lt;div style=&#39;text-align: justify;&#39;&gt;&lt;span style=&#39;font-family: Courier New;&#39;&gt;unsigned char alt2(void)&lt;/span&gt;&lt;br style=&#39;font-family: Courier New;&#39;/&gt;&lt;span style=&#39;font-family: Courier New;&#39;&gt;{&lt;/span&gt;&lt;br style=&#39;font-family: Courier New;&#39;/&gt;&lt;span style=&#39;font-family: Courier New;&#39;&gt;    unsigned char var=10;&lt;/span&gt;&lt;br style=&#39;font-family: Courier New;&#39;/&gt;&lt;span style=&#39;font-family: Courier New;&#39;&gt;    unsigned char output;&lt;/span&gt;&lt;br style=&#39;font-family: Courier New;&#39;/&gt;&lt;span style=&#39;font-family: Courier New;&#39;&gt;    if(var==1)&lt;/span&gt;&lt;br style=&#39;font-family: Courier New;&#39;/&gt;&lt;span style=&#39;font-family: Courier New;&#39;&gt;        output=3;&lt;/span&gt;&lt;br style=&#39;font-family: Courier New;&#39;/&gt;&lt;span style=&#39;font-family: Courier New;&#39;&gt;    else if(var==2)&lt;/span&gt;&lt;br style=&#39;font-family: Courier New;&#39;/&gt;&lt;span style=&#39;font-family: Courier New;&#39;&gt;        output = 2;&lt;/span&gt;&lt;br style=&#39;font-family: Courier New;&#39;/&gt;&lt;span style=&#39;font-family: Courier New;&#39;&gt;    else&lt;/span&gt;&lt;br style=&#39;font-family: Courier New;&#39;/&gt;&lt;span style=&#39;font-family: Courier New;&#39;&gt;        output =1;&lt;/span&gt;&lt;br style=&#39;font-family: Courier New;&#39;/&gt;&lt;span style=&#39;font-family: Courier New;&#39;&gt;    return output;        &lt;/span&gt;&lt;br style=&#39;font-family: Courier New;&#39;/&gt;&lt;span style=&#39;font-family: Courier New;&#39;&gt;}&lt;/span&gt;&lt;br style=&#39;font-family: Courier New;&#39;/&gt;&lt;span style=&#39;font-family: Courier New;&#39;&gt;unsigned char Alt(void)&lt;/span&gt;&lt;br style=&#39;font-family: Courier New;&#39;/&gt;&lt;span style=&#39;font-family: Courier New;&#39;&gt;{&lt;/span&gt;&lt;br style=&#39;font-family: Courier New;&#39;/&gt;&lt;span style=&#39;font-family: Courier New;&#39;&gt;    unsigned char var= 10;&lt;/span&gt;&lt;br style=&#39;font-family: Courier New;&#39;/&gt;&lt;span style=&#39;font-family: Courier New;&#39;&gt;    unsigned char output;&lt;/span&gt;&lt;br style=&#39;font-family: Courier New;&#39;/&gt;&lt;span style=&#39;font-family: Courier New;&#39;&gt;    output = (var==1)?(3):((var==2)?(2):(1));&lt;/span&gt;&lt;br style=&#39;font-family: Courier New;&#39;/&gt;&lt;span style=&#39;font-family: Courier New;&#39;&gt;    return output;&lt;/span&gt;&lt;br style=&#39;font-family: Courier New;&#39;/&gt;&lt;span style=&#39;font-family: Courier New;&#39;&gt;}&lt;/span&gt;&lt;br style=&#39;font-family: Courier New;&#39;/&gt;&lt;span style=&#39;font-family: Courier New;&#39;&gt;void main(void)&lt;/span&gt;&lt;br style=&#39;font-family: Courier New;&#39;/&gt;&lt;span style=&#39;font-family: Courier New;&#39;&gt;{&lt;/span&gt;&lt;br style=&#39;font-family: Courier New;&#39;/&gt;&lt;span style=&#39;font-family: Courier New;&#39;&gt;    int x;&lt;/span&gt;&lt;br style=&#39;font-family: Courier New;&#39;/&gt;&lt;span style=&#39;font-family: Courier New;&#39;&gt;    x = alt();&lt;/span&gt;&lt;br style=&#39;font-family: Courier New;&#39;/&gt;&lt;span style=&#39;font-family: Courier New;&#39;&gt;    x = alt2();&lt;/span&gt;&lt;br style=&#39;font-family: Courier New;&#39;/&gt;&lt;span style=&#39;font-family: Courier New;&#39;&gt;}&lt;/span&gt;&lt;br/&gt;&lt;span style=&#39;font-family: tahoma;&#39;&gt;Now on compiling this with avr-gcc with -S option you should be able to get the assembly code output also. Let us compare the functions Alt and Alt2 which have same functionalities. &lt;/span&gt;&lt;br/&gt;alt2:&lt;br/&gt;   &lt;span style=&#39;font-family: Courier New;&#39;&gt; push r29&lt;/span&gt;&lt;br style=&#39;font-family: Courier New;&#39;/&gt;&lt;span style=&#39;font-family: Courier New;&#39;&gt;    push r28&lt;/span&gt;&lt;br style=&#39;font-family: Courier New;&#39;/&gt;&lt;span style=&#39;font-family: Courier New;&#39;&gt;    rcall .&lt;/span&gt;&lt;br style=&#39;font-family: Courier New;&#39;/&gt;&lt;span style=&#39;font-family: Courier New;&#39;&gt;    in r28,__SP_L__&lt;/span&gt;&lt;br style=&#39;font-family: Courier New;&#39;/&gt;&lt;span style=&#39;font-family: Courier New;&#39;&gt;    in r29,__SP_H__&lt;/span&gt;&lt;br style=&#39;font-family: Courier New;&#39;/&gt;&lt;span style=&#39;font-family: Courier New;&#39;&gt;/* prologue: function */&lt;/span&gt;&lt;br style=&#39;font-family: Courier New;&#39;/&gt;&lt;span style=&#39;font-family: Courier New;&#39;&gt;/* frame size = 2 */&lt;/span&gt;&lt;br style=&#39;font-family: Courier New;&#39;/&gt;&lt;span style=&#39;font-family: Courier New;&#39;&gt;    ldi r24,lo8(10)&lt;/span&gt;&lt;br style=&#39;font-family: Courier New;&#39;/&gt;&lt;span style=&#39;font-family: Courier New;&#39;&gt;    std Y+2,r24&lt;/span&gt;&lt;br style=&#39;font-family: Courier New;&#39;/&gt;&lt;span style=&#39;font-family: Courier New;&#39;&gt;    ldd r24,Y+2&lt;/span&gt;&lt;br style=&#39;font-family: Courier New;&#39;/&gt;&lt;span style=&#39;font-family: Courier New;&#39;&gt;    cpi r24,lo8(1)&lt;/span&gt;&lt;br style=&#39;font-family: Courier New;&#39;/&gt;&lt;span style=&#39;font-family: Courier New;&#39;&gt;    brne .L2&lt;/span&gt;&lt;br style=&#39;font-family: Courier New;&#39;/&gt;&lt;span style=&#39;font-family: Courier New;&#39;&gt;    ldi r24,lo8(3)&lt;/span&gt;&lt;br style=&#39;font-family: Courier New;&#39;/&gt;&lt;span style=&#39;font-family: Courier New;&#39;&gt;    std Y+1,r24&lt;/span&gt;&lt;br style=&#39;font-family: Courier New;&#39;/&gt;&lt;span style=&#39;font-family: Courier New;&#39;&gt;    rjmp .L3&lt;/span&gt;&lt;br style=&#39;font-family: Courier New;&#39;/&gt;&lt;span style=&#39;font-family: Courier New;&#39;&gt;.L2:&lt;/span&gt;&lt;br style=&#39;font-family: Courier New;&#39;/&gt;&lt;span style=&#39;font-family: Courier New;&#39;&gt;    ldd r24,Y+2&lt;/span&gt;&lt;br style=&#39;font-family: Courier New;&#39;/&gt;&lt;span style=&#39;font-family: Courier New;&#39;&gt;    cpi r24,lo8(2)&lt;/span&gt;&lt;br style=&#39;font-family: Courier New;&#39;/&gt;&lt;span style=&#39;font-family: Courier New;&#39;&gt;    brne .L4&lt;/span&gt;&lt;br style=&#39;font-family: Courier New;&#39;/&gt;&lt;span style=&#39;font-family: Courier New;&#39;&gt;    ldi r24,lo8(2)&lt;/span&gt;&lt;br style=&#39;font-family: Courier New;&#39;/&gt;&lt;span style=&#39;font-family: Courier New;&#39;&gt;    std Y+1,r24&lt;/span&gt;&lt;br style=&#39;font-family: Courier New;&#39;/&gt;&lt;span style=&#39;font-family: Courier New;&#39;&gt;    rjmp .L3&lt;/span&gt;&lt;br style=&#39;font-family: Courier New;&#39;/&gt;&lt;span style=&#39;font-family: Courier New;&#39;&gt;.L4:&lt;/span&gt;&lt;br style=&#39;font-family: Courier New;&#39;/&gt;&lt;span style=&#39;font-family: Courier New;&#39;&gt;    ldi r24,lo8(1)&lt;/span&gt;&lt;br style=&#39;font-family: Courier New;&#39;/&gt;&lt;span style=&#39;font-family: Courier New;&#39;&gt;    std Y+1,r24&lt;/span&gt;&lt;br style=&#39;font-family: Courier New;&#39;/&gt;&lt;span style=&#39;font-family: Courier New;&#39;&gt;.L3:&lt;/span&gt;&lt;br style=&#39;font-family: Courier New;&#39;/&gt;&lt;span style=&#39;font-family: Courier New;&#39;&gt;    ldd r24,Y+1&lt;/span&gt;&lt;br/&gt;/* epilogue start */&lt;br/&gt;&lt;span style=&#39;font-family: tahoma;&#39;&gt;Alt2 takes a stack frame of 2 bytes and the code is readable to a great extent. I am sure it is more maintainable compared to Alt. However, Alt generates a stack frame of 4 bytes. &lt;/span&gt;&lt;br/&gt;Alt:&lt;br/&gt;   &lt;span style=&#39;font-family: Courier New;&#39;&gt; push r29&lt;/span&gt;&lt;br style=&#39;font-family: Courier New;&#39;/&gt;&lt;span style=&#39;font-family: Courier New;&#39;&gt;    push r28&lt;/span&gt;&lt;br style=&#39;font-family: Courier New;&#39;/&gt;&lt;span style=&#39;font-family: Courier New;&#39;&gt;    rcall .&lt;/span&gt;&lt;br style=&#39;font-family: Courier New;&#39;/&gt;&lt;span style=&#39;font-family: Courier New;&#39;&gt;    rcall .&lt;/span&gt;&lt;br style=&#39;font-family: Courier New;&#39;/&gt;&lt;span style=&#39;font-family: Courier New;&#39;&gt;    in r28,__SP_L__&lt;/span&gt;&lt;br style=&#39;font-family: Courier New;&#39;/&gt;&lt;span style=&#39;font-family: Courier New;&#39;&gt;    in r29,__SP_H__&lt;/span&gt;&lt;br style=&#39;font-family: Courier New;&#39;/&gt;&lt;span style=&#39;font-family: Courier New;&#39;&gt;/* prologue: function */&lt;/span&gt;&lt;br style=&#39;font-family: Courier New;&#39;/&gt;&lt;span style=&#39;font-family: Courier New;&#39;&gt;/* frame size = 4 */&lt;/span&gt;&lt;br style=&#39;font-family: Courier New;&#39;/&gt;&lt;span style=&#39;font-family: Courier New;&#39;&gt;    ldi r24,lo8(10)&lt;/span&gt;&lt;br style=&#39;font-family: Courier New;&#39;/&gt;&lt;span style=&#39;font-family: Courier New;&#39;&gt;    std Y+2,r24&lt;/span&gt;&lt;br style=&#39;font-family: Courier New;&#39;/&gt;&lt;span style=&#39;font-family: Courier New;&#39;&gt;    ldd r24,Y+2&lt;/span&gt;&lt;br style=&#39;font-family: Courier New;&#39;/&gt;&lt;span style=&#39;font-family: Courier New;&#39;&gt;    cpi r24,lo8(1)&lt;/span&gt;&lt;br style=&#39;font-family: Courier New;&#39;/&gt;&lt;span style=&#39;font-family: Courier New;&#39;&gt;    breq .L7&lt;/span&gt;&lt;br style=&#39;font-family: Courier New;&#39;/&gt;&lt;span style=&#39;font-family: Courier New;&#39;&gt;    ldd r24,Y+2&lt;/span&gt;&lt;br style=&#39;font-family: Courier New;&#39;/&gt;&lt;span style=&#39;font-family: Courier New;&#39;&gt;    cpi r24,lo8(2)&lt;/span&gt;&lt;br style=&#39;font-family: Courier New;&#39;/&gt;&lt;span style=&#39;font-family: Courier New;&#39;&gt;    brne .L8&lt;/span&gt;&lt;br style=&#39;font-family: Courier New;&#39;/&gt;&lt;span style=&#39;font-family: Courier New;&#39;&gt;    ldi r24,lo8(2)&lt;/span&gt;&lt;br style=&#39;font-family: Courier New;&#39;/&gt;&lt;span style=&#39;font-family: Courier New;&#39;&gt;    std Y+3,r24&lt;/span&gt;&lt;br style=&#39;font-family: Courier New;&#39;/&gt;&lt;span style=&#39;font-family: Courier New;&#39;&gt;    rjmp .L9&lt;/span&gt;&lt;br style=&#39;font-family: Courier New;&#39;/&gt;&lt;span style=&#39;font-family: Courier New;&#39;&gt;.L8:&lt;/span&gt;&lt;br style=&#39;font-family: Courier New;&#39;/&gt;&lt;span style=&#39;font-family: Courier New;&#39;&gt;    ldi r24,lo8(1)&lt;/span&gt;&lt;br style=&#39;font-family: Courier New;&#39;/&gt;&lt;span style=&#39;font-family: Courier New;&#39;&gt;    std Y+3,r24&lt;/span&gt;&lt;br style=&#39;font-family: Courier New;&#39;/&gt;&lt;span style=&#39;font-family: Courier New;&#39;&gt;.L9:&lt;/span&gt;&lt;br style=&#39;font-family: Courier New;&#39;/&gt;&lt;span style=&#39;font-family: Courier New;&#39;&gt;    ldd r24,Y+3&lt;/span&gt;&lt;br style=&#39;font-family: Courier New;&#39;/&gt;&lt;span style=&#39;font-family: Courier New;&#39;&gt;    std Y+4,r24&lt;/span&gt;&lt;br style=&#39;font-family: Courier New;&#39;/&gt;&lt;span style=&#39;font-family: Courier New;&#39;&gt;    rjmp .L10&lt;/span&gt;&lt;br style=&#39;font-family: Courier New;&#39;/&gt;&lt;span style=&#39;font-family: Courier New;&#39;&gt;.L7:&lt;/span&gt;&lt;br style=&#39;font-family: Courier New;&#39;/&gt;&lt;span style=&#39;font-family: Courier New;&#39;&gt;    ldi r24,lo8(3)&lt;/span&gt;&lt;br style=&#39;font-family: Courier New;&#39;/&gt;&lt;span style=&#39;font-family: Courier New;&#39;&gt;    std Y+4,r24&lt;/span&gt;&lt;br style=&#39;font-family: Courier New;&#39;/&gt;&lt;span style=&#39;font-family: Courier New;&#39;&gt;.L10:&lt;/span&gt;&lt;br style=&#39;font-family: Courier New;&#39;/&gt;&lt;span style=&#39;font-family: Courier New;&#39;&gt;    ldd r24,Y+4&lt;/span&gt;&lt;br style=&#39;font-family: Courier New;&#39;/&gt;&lt;span style=&#39;font-family: Courier New;&#39;&gt;    std Y+1,r24&lt;/span&gt;&lt;br style=&#39;font-family: Courier New;&#39;/&gt;&lt;span style=&#39;font-family: Courier New;&#39;&gt;    ldd r24,Y+1&lt;/span&gt;&lt;br/&gt;&lt;/div&gt;&lt;span style=&#39;font-family: tahoma;&#39;&gt;We see that now the stack frame is 4 bytes &amp;amp; to  add to the woes the code is not so much readable as well. &lt;/span&gt;&lt;br style=&#39;font-family: tahoma;&#39;/&gt;&lt;span style=&#39;font-family: tahoma;&#39;&gt;Thus, we break a myth that complicated &amp;amp; compressed &quot;C&quot; files give compressed code. More often that not modern compilers are clever enough to do everything that is needed for optimisation. So please spare yourself the troubel and let the compiler do its job. &lt;/span&gt;&lt;br style=&#39;font-family: tahoma;&#39;/&gt;&lt;span style=&#39;font-family: tahoma;&#39;&gt;However, that doesn&#39;t mean that we should write inefficient code. What it means is that -  &quot;Dont think you have optimized the code by just changing some &quot;if&quot; statements to &quot;ternary&quot;  operators. It is more than that and quite usually compiler dependent&quot;. The best way to optimize is to read the compiler manual and try to understand the compiler and its capability. Then you can use tricks in &quot;C&quot; to optimize the code.&lt;/span&gt;&lt;br style=&#39;font-family: tahoma;&#39;/&gt;&lt;span style=&#39;font-family: tahoma;&#39;&gt; &lt;/span&gt;&lt;br/&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=&#39;scribefire-powered&#39;&gt;Powered by &lt;a href=&#39;http://www.scribefire.com/&#39;&gt;ScribeFire&lt;/a&gt;.&lt;/p&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://embeddedlive.blogspot.com/feeds/3682746103810270637/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://embeddedlive.blogspot.com/2009/06/when-size-does-matter-coding-myth-1.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1907071224335910840/posts/default/3682746103810270637'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1907071224335910840/posts/default/3682746103810270637'/><link rel='alternate' type='text/html' href='http://embeddedlive.blogspot.com/2009/06/when-size-does-matter-coding-myth-1.html' title='When Size does matter - Coding Myth 1'/><author><name>Deepz</name><uri>http://www.blogger.com/profile/16543298327846220464</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1907071224335910840.post-1898498051618950663</id><published>2009-05-30T12:28:00.001+05:30</published><updated>2009-05-30T12:28:24.218+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="Basic"/><category scheme="http://www.blogger.com/atom/ns#" term="Matlab"/><title type='text'>Some fun with matlab</title><content type='html'>&lt;div xmlns=&#39;http://www.w3.org/1999/xhtml&#39;&gt;I have not been able to do a lot of blogging on this site of late. Procrastination is the reason. Also, I was a bit busy with my project-work ( or the lack of it!!). Here I write about a small script i wrote to convert from mat files to csv files. I searched a lot for existing solutions but alas none was available though csv to mat converters exit in bulk.  While i wrote the script i realized the reason for non existance of such a script. &lt;br/&gt;In Matlab you can store different types of information into a Mat file and some of it might not be easy to represent directly in a CSV file. for example structures cannot logically be put in a CSV file but arrays are easy to convert into csv. &lt;br/&gt;So i wrote a script which can convert mat to csv but with a restriction. The MAT file should not contain any structures or row array&#39;s. It can have only column array&#39;s. Ofcourse, i know it is simple to change the column to row. &lt;br/&gt;&lt;br style=&#39;color: rgb(255, 204, 0);&#39;/&gt;&lt;span style=&#39;color: rgb(255, 204, 0);&#39;&gt;I dont think i can upload a file on to this blog, so till i can put the stuff on esnips this is the only way to share it.&lt;/span&gt;:-(&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;&lt;span style=&#39;font-family: Courier New;&#39;&gt;function mat2csv(fname,target)&lt;/span&gt;&lt;br style=&#39;font-family: Courier New;&#39;/&gt;&lt;span style=&#39;font-family: Courier New;&#39;&gt;% MAT2CSV convert a mat file to csv file&lt;br/&gt;&lt;/span&gt;&lt;span style=&#39;font-family: Courier New;&#39;&gt;% MAT2CSV(&#39;matfilename.mat&#39;,&#39;csvfilename.csv&#39;)&lt;/span&gt;&lt;br/&gt;&lt;span style=&#39;font-family: Courier New;&#39;&gt;% Output is generated using the data provided in the matfile ( one col per&lt;/span&gt;&lt;span style=&#39;font-family: Courier New;&#39;&gt; data element)&lt;/span&gt;&lt;span style=&#39;font-family: Courier New;&#39;&gt; &lt;/span&gt;&lt;br style=&#39;font-family: Courier New;&#39;/&gt;&lt;span style=&#39;font-family: Courier New;&#39;&gt;% Unused cells will be filled with zero&#39;s&lt;/span&gt;&lt;br/&gt;&lt;span style=&#39;font-family: Courier New;&#39;&gt;% TODO: Currently the CSV file does not have column names, this will be&lt;/span&gt;&lt;br/&gt;&lt;span style=&#39;font-family: Courier New;&#39;&gt;% added in next version&lt;/span&gt;&lt;br/&gt;&lt;span style=&#39;font-family: Courier New;&#39;&gt;if(nargin&amp;lt;2)&lt;/span&gt;&lt;br style=&#39;font-family: Courier New;&#39;/&gt;&lt;span style=&#39;font-family: Courier New;&#39;&gt;    error &#39;Incorrect Number of inputs. Refer to usage by using &quot;help mat2csv&quot;&#39;&lt;/span&gt;&lt;br style=&#39;font-family: Courier New;&#39;/&gt;&lt;span style=&#39;font-family: Courier New;&#39;&gt;end&lt;/span&gt;&lt;br style=&#39;font-family: Courier New;&#39;/&gt;&lt;span style=&#39;font-family: Courier New;&#39;&gt;y = open (fname);&lt;/span&gt;&lt;br style=&#39;font-family: Courier New;&#39;/&gt;&lt;span style=&#39;font-family: Courier New;&#39;&gt;largest_entry =0;&lt;/span&gt;&lt;br style=&#39;font-family: Courier New;&#39;/&gt;&lt;span style=&#39;font-family: Courier New;&#39;&gt;flds = fieldnames(y);&lt;/span&gt;&lt;br style=&#39;font-family: Courier New;&#39;/&gt;&lt;span style=&#39;font-family: Courier New;&#39;&gt;for idx=1:size(flds)&lt;/span&gt;&lt;br style=&#39;font-family: Courier New;&#39;/&gt;&lt;span style=&#39;font-family: Courier New;&#39;&gt;    eval ( strcat(&#39;if(size(y.&#39;,char(flds(idx)),&#39;,2)&amp;gt; largest_entry)largest_entry = size(y.&#39;,char(flds(idx)),&#39;,2); end&#39;));&lt;/span&gt;&lt;br style=&#39;font-family: Courier New;&#39;/&gt;&lt;span style=&#39;font-family: Courier New;&#39;&gt;end&lt;/span&gt;&lt;br style=&#39;font-family: Courier New;&#39;/&gt;&lt;span style=&#39;font-family: Courier New;&#39;&gt;eval (&#39;outmatrix = zeros(largest_entry,size(flds,1));&#39;);&lt;/span&gt;&lt;br style=&#39;font-family: Courier New;&#39;/&gt;&lt;span style=&#39;font-family: Courier New;&#39;&gt;for idx=1:size(flds)&lt;/span&gt;&lt;br style=&#39;font-family: Courier New;&#39;/&gt;&lt;span style=&#39;font-family: Courier New;&#39;&gt;    eval ( strcat(&#39;outmatrix(1:size(y.&#39;,   char(flds(idx)),  &#39;,2),&#39;, int2str(idx) ,&#39;) = (y.&#39;, char(flds(idx)), &#39;);&#39;)  );&lt;/span&gt;&lt;br style=&#39;font-family: Courier New;&#39;/&gt;&lt;span style=&#39;font-family: Courier New;&#39;&gt;end&lt;/span&gt;&lt;br style=&#39;font-family: Courier New;&#39;/&gt;&lt;span style=&#39;font-family: Courier New;&#39;&gt;fl =&#39;&#39;;&lt;/span&gt;&lt;br style=&#39;font-family: Courier New;&#39;/&gt;&lt;span style=&#39;font-family: Courier New;&#39;&gt;for idx=1:size(flds)&lt;/span&gt;&lt;br style=&#39;font-family: Courier New;&#39;/&gt;&lt;span style=&#39;font-family: Courier New;&#39;&gt;    fl = strcat(fl,char(flds(idx)),&#39;,&#39;);&lt;/span&gt;&lt;br style=&#39;font-family: Courier New;&#39;/&gt;&lt;span style=&#39;font-family: Courier New;&#39;&gt;end&lt;/span&gt;&lt;br style=&#39;font-family: Courier New;&#39;/&gt;&lt;span style=&#39;font-family: Courier New;&#39;&gt;[rc,cc] = size(outmatrix);&lt;/span&gt;&lt;br style=&#39;font-family: Courier New;&#39;/&gt;&lt;span style=&#39;font-family: Courier New;&#39;&gt;fid=fopen(target,&#39;wt&#39;);&lt;/span&gt;&lt;br style=&#39;font-family: Courier New;&#39;/&gt;&lt;span style=&#39;font-family: Courier New;&#39;&gt;fprintf(fid,&#39;%s\n&#39;,fl);&lt;/span&gt;&lt;br style=&#39;font-family: Courier New;&#39;/&gt;&lt;span style=&#39;font-family: Courier New;&#39;&gt;for idx=1:rc&lt;/span&gt;&lt;br style=&#39;font-family: Courier New;&#39;/&gt;&lt;span style=&#39;font-family: Courier New;&#39;&gt;   for jdx=1:cc-1&lt;/span&gt;&lt;br style=&#39;font-family: Courier New;&#39;/&gt;&lt;span style=&#39;font-family: Courier New;&#39;&gt;        fprintf(fid,&#39;%d,&#39;,outmatrix(idx,jdx));&lt;/span&gt;&lt;br style=&#39;font-family: Courier New;&#39;/&gt;&lt;span style=&#39;font-family: Courier New;&#39;&gt;    end&lt;/span&gt;&lt;br style=&#39;font-family: Courier New;&#39;/&gt;&lt;span style=&#39;font-family: Courier New;&#39;&gt;    fprintf(fid,&#39;%d\n&#39;,outmatrix(idx,jdx+1));&lt;/span&gt;&lt;br style=&#39;font-family: Courier New;&#39;/&gt;&lt;span style=&#39;font-family: Courier New;&#39;&gt;end&lt;/span&gt;&lt;br style=&#39;font-family: Courier New;&#39;/&gt;&lt;span style=&#39;font-family: Courier New;&#39;&gt;fclose(fid);&lt;/span&gt;&lt;br style=&#39;font-family: Courier New;&#39;/&gt;&lt;span style=&#39;font-family: Courier New;&#39;&gt;end&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=&#39;scribefire-powered&#39;&gt;Powered by &lt;a href=&#39;http://www.scribefire.com/&#39;&gt;ScribeFire&lt;/a&gt;.&lt;/p&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://embeddedlive.blogspot.com/feeds/1898498051618950663/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://embeddedlive.blogspot.com/2009/05/some-fun-with-matlab.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1907071224335910840/posts/default/1898498051618950663'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1907071224335910840/posts/default/1898498051618950663'/><link rel='alternate' type='text/html' href='http://embeddedlive.blogspot.com/2009/05/some-fun-with-matlab.html' title='Some fun with matlab'/><author><name>Deepz</name><uri>http://www.blogger.com/profile/16543298327846220464</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1907071224335910840.post-9110198374113257637</id><published>2009-05-20T21:35:00.001+05:30</published><updated>2009-05-20T21:35:27.028+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="funda"/><category scheme="http://www.blogger.com/atom/ns#" term="Info"/><category scheme="http://www.blogger.com/atom/ns#" term="Technology"/><title type='text'>Faster and Hotter chips!!</title><content type='html'>&lt;div xmlns=&#39;http://www.w3.org/1999/xhtml&#39;&gt;&lt;div style=&#39;text-align: justify; font-family: tahoma;&#39;&gt;&lt;span style=&#39;font-family: tahoma;&#39;&gt;I have not been able to blog here due to two reasons. One I got lazy, two is first as the same. Any way now i have woken up from my slumber. &lt;a href=&#39;http://news.cnet.com/8301-13924_3-10244564-64.html?part=rss&amp;amp;subj=news&amp;amp;tag=2547-1_3-0-20&#39; target=&#39;_blank&#39;&gt;This neat article&lt;/a&gt; talks about a new 8 core chip ( for servers) from Intel. However, have you ever wondered why suddenly there was a paradigm shift from having faster chips (3GHz or more) to having more cores?&lt;/span&gt;&lt;br style=&#39;font-family: tahoma;&#39;/&gt;&lt;br style=&#39;font-family: tahoma;&#39;/&gt;&lt;span style=&#39;font-family: tahoma;&#39;&gt;The main reason ( though there might be many others) is the problem of heat dissipiation. Just to give a little bit more information in this regard i will try to go a bit below the layer. The modern chips are all based on CMOS technology. Though most magazines call them as transistors they are really MOSFET&#39;s ( which means MOS Feild Effect Transistors). CMOS has this wonderful property that it consumes literally no power when it is holding a logic &#39;O&#39; or logic &#39;1&#39;. So why the power loss? The power loss really occurs when there is a switching of the CMOS from the logic &#39;0&#39; to logic &#39;1&#39; or visa versa. &lt;/span&gt;&lt;br style=&#39;font-family: tahoma;&#39;/&gt;&lt;br style=&#39;font-family: tahoma;&#39;/&gt;This means that more you switch the transistor the more heat you dissipiate. The more heat you dissipate the more cooling need for your chip. Now we are left with two options, either ensure that  we cool the chip well or we reduce the heat generated. To a great extent we can cool the chip by adding bigger fans and heat sinks, however there is a limit to this ( because the heat generated takes a finite amount of time to get carried out and be dissipiated!!). If we concentrate on the second option we observe that if we do not switch the transistors so fast we can control the heating. This is what Intel has chosen to do by not trying to pump up the gigahertz. However, to boost performance now there are two cores ( which run at a slower rate!!) which can parallely execute instructions which are not directly dependent on each other . The story i am sure is more than this and i am not technically competant enough to put in that stuff here. However, someone i know does. I would be requesting him to add a few lines to this blog in a few days. &lt;br/&gt;&lt;small style=&#39;font-family: georgia; color: rgb(51, 102, 255);&#39;&gt;Please leave your comment if you have one. You can subscribe to this blog by using the links under &quot;Subscribe&quot; section. &lt;/small&gt;&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=&#39;scribefire-powered&#39;&gt;Powered by &lt;a href=&#39;http://www.scribefire.com/&#39;&gt;ScribeFire&lt;/a&gt;.&lt;/p&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://embeddedlive.blogspot.com/feeds/9110198374113257637/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://embeddedlive.blogspot.com/2009/05/faster-and-hotter-chips.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1907071224335910840/posts/default/9110198374113257637'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1907071224335910840/posts/default/9110198374113257637'/><link rel='alternate' type='text/html' href='http://embeddedlive.blogspot.com/2009/05/faster-and-hotter-chips.html' title='Faster and Hotter chips!!'/><author><name>Deepz</name><uri>http://www.blogger.com/profile/16543298327846220464</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1907071224335910840.post-5462826407446634884</id><published>2009-05-07T11:44:00.001+05:30</published><updated>2009-05-07T11:44:45.087+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="Automotive"/><category scheme="http://www.blogger.com/atom/ns#" term="Embedded Software"/><category scheme="http://www.blogger.com/atom/ns#" term="funda"/><category scheme="http://www.blogger.com/atom/ns#" term="Intermediate"/><title type='text'>Time Out!!</title><content type='html'>&lt;div xmlns=&#39;http://www.w3.org/1999/xhtml&#39;&gt;This question came from a very good friend and ex-colleague. So just responding it via this post which i trust will be useful to others also.&lt;br/&gt;&lt;br/&gt;The question&lt;br/&gt;&lt;br/&gt;&lt;span style=&#39;font-weight: bold;&#39;&gt;What is a &quot;Cyclic Wakeup Timer&quot;?&lt;/span&gt;&lt;br/&gt;&lt;br/&gt;The question can be answered if we understand each of the three terms. &lt;br/&gt;&lt;br/&gt;We start with &lt;span style=&#39;font-weight: bold; font-style: italic;&#39;&gt;Timer&lt;/span&gt;. &lt;span style=&#39;font-weight: bold; font-style: italic;&#39;&gt;Timer &lt;/span&gt;is a hardware or software that keeps track of time via counts. If we know that each count takes say 10ms then we know that 10 counts will mean 100ms. The timer is controlled by its clock which is usually derived from an external crystal or internal PLL circuits.&lt;br/&gt;&lt;br/&gt;Next we take &lt;span style=&#39;font-style: italic; font-weight: bold;&#39;&gt;Cyclic&lt;/span&gt;. It is clear from the word that this shows a repetitive process. The timer runs continuously and maintains time. Which means i can configure a cyclic timer to create an event every 10ms. When 10ms elapses there is a event generated by the Timer (called the timer interrupt by some people). In the event handler we can choose to reinitialize the timer to count for another 10ms. Various configurations are possible, we will not discuss all of them here.&lt;br/&gt;&lt;br/&gt;Last part is &lt;span style=&#39;font-weight: bold; font-style: italic;&#39;&gt;Wakeup&lt;/span&gt;. This is simple, we do this everyday. In this case we are talking about the microcontroller waking up.&lt;br/&gt;&lt;br/&gt;To put it all together, a timer that wakes up the microcontroller at periodic intervals is a CWT or Cyclic wakeup timer. &lt;br/&gt;&lt;br/&gt;The pertinent question is now, &lt;span style=&#39;font-weight: bold;&#39;&gt;why do we need this&lt;/span&gt;?&lt;br/&gt;&lt;br/&gt;I can talk only for automotive and perhaps for some other battery powered devices.&lt;br/&gt;&lt;br/&gt;Many devices go into sleep mode when they are not doing anything useful, however the periodically wakeup to check if there is something useful to be done. I quote a few examples :&lt;br/&gt;&lt;br/&gt;&lt;ul&gt;&lt;li&gt;A PKE ( Passive Keyless Entry) system might wakeup periodically to see if there is a key in the vicinity of the vehicle. If there is then it automatically unlocks the door. (&lt;span style=&#39;font-weight: bold;&#39;&gt;Note:&lt;/span&gt; It is technically quite challenging and complicated)&lt;/li&gt;&lt;li&gt;A BCM ( Body Computer Module) needs to wakeup periodically to check for monitoring certain inputs.However, this is usually because multiple external events might try to wakeup the ECU but there might not be so many interrupt pins available. &lt;/li&gt;&lt;li&gt;I know of a system which used to maintain the time. The system would go to sleep and wakeup every 1 sec to update its time variables. Only when the vehicle was on the system would display the time else it would go to low power mode and wakeup only every 1 sec.&lt;/li&gt;&lt;/ul&gt;As you can see that the CWT is quite useful. However, it might be a tough job to handle the CWT along with other wakeup sources which try to interfere with its operation. &lt;br/&gt;&lt;br/&gt;Hope this clears my buddy&#39;s query...&lt;br/&gt;&lt;br/&gt;&lt;small style=&#39;font-family: georgia; color: rgb(51, 102, 255);&#39;&gt;Please leave your comment if you have one. You can subscribe to this blog by using the links under &quot;Subscribe&quot; section. &lt;/small&gt;&lt;br/&gt;&lt;br/&gt; &lt;br/&gt;&lt;br/&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=&#39;scribefire-powered&#39;&gt;Powered by &lt;a href=&#39;http://www.scribefire.com/&#39;&gt;ScribeFire&lt;/a&gt;.&lt;/p&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://embeddedlive.blogspot.com/feeds/5462826407446634884/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://embeddedlive.blogspot.com/2009/05/time-out.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1907071224335910840/posts/default/5462826407446634884'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1907071224335910840/posts/default/5462826407446634884'/><link rel='alternate' type='text/html' href='http://embeddedlive.blogspot.com/2009/05/time-out.html' title='Time Out!!'/><author><name>Deepz</name><uri>http://www.blogger.com/profile/16543298327846220464</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1907071224335910840.post-5613434010927264653</id><published>2009-05-06T16:38:00.001+05:30</published><updated>2009-05-06T16:40:12.966+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="Embedded Software"/><category scheme="http://www.blogger.com/atom/ns#" term="funda"/><category scheme="http://www.blogger.com/atom/ns#" term="Gadget"/><category scheme="http://www.blogger.com/atom/ns#" term="Info"/><category scheme="http://www.blogger.com/atom/ns#" term="Intermediate"/><title type='text'>Let Us Model</title><content type='html'>&lt;div xmlns=&#39;http://www.w3.org/1999/xhtml&#39;&gt;&lt;div style=&#39;text-align: justify; font-family: tahoma;&#39;&gt;I am not really an expert in this domain. I switched companies about 3 months back and with that i also changed my working area to some extent. Now instead of writing code i model it.&lt;br/&gt;&lt;br/&gt;&lt;span style=&#39;font-weight: bold;&#39;&gt;Why does one need to model code?&lt;/span&gt;&lt;br/&gt;The reason is that model acts like a common language between the coder and the provider of requirements. However that is not the only reason. Most of the Modeling languages these days provide a mechanism to directly convert the model into code or partial code.&lt;br/&gt;&lt;br/&gt;&lt;span style=&#39;font-weight: bold;&#39;&gt;Simple cases:&lt;/span&gt;&lt;br/&gt;&lt;/div&gt;&lt;ul style=&#39;text-align: justify; font-family: tahoma;&#39;&gt;&lt;li&gt;&lt;span style=&#39;font-style: italic; font-weight: bold;&#39;&gt;UML modeling&lt;/span&gt;: These days many if not all commonly used high level languages are object oriented. UML provide a very nice method to model the system in terms of classes, packages and their interdependencies etc. There are free and paid tools that are can directly convert from UML models to skeleton code. &lt;br/&gt;&lt;/li&gt;&lt;li&gt;&lt;span style=&#39;font-style: italic; font-weight: bold;&#39;&gt;Simulink modeling&lt;/span&gt; : Simulink is a very powerful tool available from &lt;a target=&#39;_blank&#39; href=&#39;http://www.mathworks.in/&#39;&gt;mathworks&lt;/a&gt;. The tool provides you simple gui based interface to create models. These models can be fed with inputs and then the corresponding outputs can be tested for their validity etc.&lt;/li&gt;&lt;/ul&gt;&lt;div style=&#39;text-align: justify;&#39;&gt;&lt;span style=&#39;font-family: tahoma;&#39;&gt;In the automotive domain currently, Matlab is used very often for verification of complicated algorithms. Once the simulink models are tested extensively, then it is possible to automatically generate &lt;/span&gt;&lt;span style=&#39;font-weight: bold; font-family: tahoma;&#39;&gt;floating point &lt;/span&gt;&lt;span style=&#39;font-family: tahoma;&#39;&gt;code using RTW and Embedded Coder. This code can be directly flashed into controllers which have sufficent floating point muscle power be used to verify the functionality in the real hardware. However, more often than not, floating point muscle power comes at a heavy price and is not preffered for production programs. &lt;/span&gt;&lt;br/&gt;&lt;br style=&#39;font-family: tahoma;&#39;/&gt;&lt;span style=&#39;font-family: tahoma; font-weight: bold;&#39;&gt;So what is the next step?&lt;/span&gt;&lt;br style=&#39;font-family: tahoma;&#39;/&gt;&lt;br style=&#39;font-family: tahoma;&#39;/&gt;&lt;span style=&#39;font-family: tahoma;&#39;&gt;You got it right!! Convert the floating point code into &lt;/span&gt;&lt;span style=&#39;font-weight: bold; font-family: tahoma;&#39;&gt;fixed point&lt;/span&gt;&lt;span style=&#39;font-family: tahoma;&#39;&gt; code. The fixed point code can run faster on simple µC&#39;s. &lt;/span&gt;&lt;span style=&#39;font-weight: bold; font-family: tahoma;&#39;&gt;Caution&lt;/span&gt;&lt;span style=&#39;font-family: tahoma;&#39;&gt;: Note that all processors are capable of doing floating point operations however, in simpler micro processors there is no dedicated hardware unit for doing this. Which means that this has to be done in software which is time consuming and memory consuming. Some processors like PPC are capable of doing this in their hardware&lt;/span&gt;&lt;br/&gt;---------------------------------------------------------------------------------------------------------------------------&lt;br/&gt;&lt;span style=&#39;font-weight: bold; font-style: italic; font-family: arial;&#39;&gt;— Floating point&lt;/span&gt;&lt;br style=&#39;font-weight: bold; font-style: italic; font-family: arial;&#39;/&gt;&lt;span style=&#39;font-weight: bold; font-style: italic; font-family: arial;&#39;&gt;– IEEE® 754 compatible with software wrapper&lt;/span&gt;&lt;br style=&#39;font-weight: bold; font-style: italic; font-family: arial;&#39;/&gt;&lt;span style=&#39;font-weight: bold; font-style: italic; font-family: arial;&#39;&gt;– Single precision in hardware, double precision with software library&lt;/span&gt;&lt;br style=&#39;font-weight: bold; font-style: italic; font-family: arial;&#39;/&gt;&lt;span style=&#39;font-weight: bold; font-style: italic; font-family: arial;&#39;&gt;– Conversion instructions between single precision floating point and fixed point&lt;/span&gt;&lt;br/&gt;---------------------------------------------------------------------------------------------------------------------------&lt;br/&gt;&lt;span style=&#39;font-family: tahoma;&#39;&gt;Excerpt from PPC mannual.&lt;/span&gt;&lt;br/&gt;&lt;br/&gt;Obviously we have to understand that due the limitations of the fixed point code there will be resolution error also called quantisation errors. Based on how we choose our scaling ( will talk about this later) we can ensure minimal quantisation errors. Of course, note that fixed point code is not really all that fast but ofcourse faster than floating point code ( slower than unscaled code!!) .&lt;br/&gt;&lt;br/&gt;To conclude, these days quite often the system engineers etc use the simulink models to develop their algorithms while software developers work on the simulink models as inputs and create the fixed point code that goes into the ECU.&lt;br/&gt;&lt;br/&gt;&lt;small style=&#39;font-family: georgia; color: rgb(51, 102, 255);&#39;&gt;Please leave your comment if you have one. You can subscribe to this blog by using the links under &quot;Subscribe&quot; section. &lt;/small&gt;&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;&lt;/div&gt;&lt;br/&gt;&lt;br/&gt;&lt;p class=&#39;scribefire-powered&#39;&gt;Powered by &lt;a href=&#39;http://www.scribefire.com/&#39;&gt;ScribeFire&lt;/a&gt;.&lt;/p&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://embeddedlive.blogspot.com/feeds/5613434010927264653/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://embeddedlive.blogspot.com/2009/05/let-us-model.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1907071224335910840/posts/default/5613434010927264653'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1907071224335910840/posts/default/5613434010927264653'/><link rel='alternate' type='text/html' href='http://embeddedlive.blogspot.com/2009/05/let-us-model.html' title='Let Us Model'/><author><name>Deepz</name><uri>http://www.blogger.com/profile/16543298327846220464</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1907071224335910840.post-6467865410044837025</id><published>2009-05-04T21:19:00.001+05:30</published><updated>2009-05-04T21:19:51.233+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="Basic"/><category scheme="http://www.blogger.com/atom/ns#" term="Embedded Software"/><category scheme="http://www.blogger.com/atom/ns#" term="funda"/><title type='text'>Where does it run ?</title><content type='html'>&lt;div xmlns=&#39;http://www.w3.org/1999/xhtml&#39;&gt;&lt;div style=&#39;text-align: justify;&#39;&gt;&lt;span style=&#39;font-family: tahoma;&#39;&gt;This post comes in the wake up some discussions i had with few people working the embedded domain a few days back. &lt;/span&gt;&lt;br style=&#39;font-family: tahoma;&#39;/&gt;&lt;br style=&#39;font-family: tahoma;&#39;/&gt;&lt;span style=&#39;font-family: tahoma;&#39;&gt;The question was, where exactly does our code in the micro controller run? The answer again unfortunately is not so straight forward. The reason is because different micro controllers behave in different ways. Let us therefore try to understand how the whole process works so that we can judge it better.&lt;/span&gt;&lt;br style=&#39;font-family: tahoma;&#39;/&gt;&lt;br style=&#39;font-family: tahoma;&#39;/&gt;&lt;span style=&#39;font-family: tahoma;&#39;&gt;Frankly, the micro controllers at its core are just a bunch of registers on which a few mathematical operations can be done by another piece of hardware ( part of the core) called the &lt;span style=&#39;font-weight: bold;&#39;&gt;ALU&lt;/span&gt;(Arithmatic Logic Unit). Most of the micro&#39;s thus have a Accumalator(Acc). This is like the mother register and most of the operations (mathematical or logical) will use the Acc register (There are instructions that do not involve the Acc also. like mov H,L does not involve the Acc). To ensure that some instrucution is &lt;/span&gt;&lt;span style=&#39;font-weight: bold; font-family: tahoma;&#39;&gt;executed&lt;/span&gt;&lt;span style=&#39;font-family: tahoma;&#39;&gt;, it must be first &lt;/span&gt;&lt;span style=&#39;font-weight: bold; font-family: tahoma;&#39;&gt;fetched&lt;/span&gt;&lt;span style=&#39;font-family: tahoma;&#39;&gt;, &lt;/span&gt;&lt;span style=&#39;font-weight: bold; font-family: tahoma;&#39;&gt;decoded&lt;/span&gt;&lt;span style=&#39;font-family: tahoma;&#39;&gt; and only there can be some action. To &lt;/span&gt;&lt;span style=&#39;font-weight: bold; font-family: tahoma;&#39;&gt;fetch&lt;/span&gt;&lt;span style=&#39;font-family: tahoma;&#39;&gt; an instruction, it should be &lt;/span&gt;&lt;span style=&#39;font-weight: bold; font-family: tahoma;&#39;&gt;readily&lt;/span&gt;&lt;span style=&#39;font-family: tahoma;&#39;&gt; available.&lt;/span&gt;&lt;span style=&#39;font-weight: bold; font-family: tahoma;&#39;&gt; Readily&lt;/span&gt;&lt;span style=&#39;font-family: tahoma;&#39;&gt; is a fuzzy word here because what is readily on 8Mhz system is really too slow on a 1GHz processor. The readiness depends on how fast we can read the said instrucution. The simplest micro controllers like 8051 keep the instructions in their flash memories. These are accessed by the core and then executed. Some industry folks call this as &lt;/span&gt;&lt;span style=&#39;font-weight: bold; font-family: tahoma;&#39;&gt;&quot;&lt;span style=&#39;font-style: italic;&#39;&gt;Executing from the Flash&lt;/span&gt;&quot;&lt;/span&gt;&lt;span style=&#39;font-family: tahoma;&#39;&gt;.&lt;/span&gt;&lt;br style=&#39;font-family: tahoma;&#39;/&gt;&lt;br style=&#39;font-family: tahoma;&#39;/&gt;&lt;span style=&#39;font-family: tahoma;&#39;&gt;Modern micro&#39;s have the concept of cache. This means they will&lt;/span&gt;&lt;span style=&#39;font-weight: bold; font-family: tahoma;&#39;&gt; pre-fetch&lt;/span&gt;&lt;span style=&#39;font-family: tahoma;&#39;&gt; and keep some of the instructions in a &lt;/span&gt;&lt;span style=&#39;font-weight: bold; font-family: tahoma;&#39;&gt;faster&lt;/span&gt;&lt;span style=&#39;font-family: tahoma;&#39;&gt; re-writeable memory. The core thus will use the cache to read the instructions instead of reading from the flash. Crude and simpler implementations of cache are in the form of instruction queue etc. These don&#39;t have the capabilities of the cache memory but never the less helps in making execution faster. So, now the instructions are stored in flash, but executed really out of cache memory. &lt;/span&gt;&lt;br style=&#39;font-family: tahoma;&#39;/&gt;&lt;br style=&#39;font-family: tahoma;&#39;/&gt;&lt;span style=&#39;font-family: tahoma;&#39;&gt;Some micro controllers also provide a wonderful feature where in the instructions can be stored in the RAM. This is generally done while reprogramming. More about reprogramming will be there in future posts. Here the real program resides in the flash memory but one can copy the program to RAM and then set the core to fetch the instructions from the RAM instead of the flash. &lt;/span&gt;&lt;br style=&#39;font-family: tahoma;&#39;/&gt;&lt;span style=&#39;font-family: tahoma;&#39;&gt;Some folks call this &lt;/span&gt;&lt;span style=&#39;font-weight: bold; font-family: tahoma;&#39;&gt;&quot;&lt;span style=&#39;font-style: italic;&#39;&gt;Execution from RAM&lt;/span&gt;&quot;&lt;/span&gt;&lt;span style=&#39;font-family: tahoma;&#39;&gt;. &lt;/span&gt;&lt;br style=&#39;font-family: tahoma;&#39;/&gt;&lt;br style=&#39;font-family: tahoma;&#39;/&gt;&lt;span style=&#39;font-family: tahoma;&#39;&gt;The fact is that most modern micro&#39;s can read instructions from both Flash, Ram or in some cases even from communication buses (like CAN/FlexRay). The last part is tricky one and will be discussed in some other post ( because i have to get more information on that yet)&lt;/span&gt;.&lt;br/&gt;&lt;br/&gt;&lt;span style=&#39;font-family: tahoma;&#39;&gt;My take is this, all code gets executed in the core. All that can vary is where we are fetching it from.&lt;/span&gt;&lt;br style=&#39;font-family: tahoma;&#39;/&gt;&lt;br style=&#39;font-family: tahoma;&#39;/&gt;&lt;br style=&#39;font-family: tahoma;&#39;/&gt;&lt;small style=&#39;font-family: georgia; color: rgb(51, 102, 255);&#39;&gt;Please leave your comment if you have one. You can subscribe to this blog by using the links under &quot;Subscribe&quot; section. &lt;/small&gt;&lt;br/&gt;&lt;br style=&#39;font-family: tahoma;&#39;/&gt;&lt;br style=&#39;font-family: tahoma;&#39;/&gt;&lt;br style=&#39;font-family: tahoma;&#39;/&gt;&lt;br style=&#39;font-family: tahoma;&#39;/&gt;&lt;br style=&#39;font-family: tahoma;&#39;/&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class=&#39;scribefire-powered&#39;&gt;Powered by &lt;a href=&#39;http://www.scribefire.com/&#39;&gt;ScribeFire&lt;/a&gt;.&lt;/p&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://embeddedlive.blogspot.com/feeds/6467865410044837025/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://embeddedlive.blogspot.com/2009/05/where-does-it-run.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1907071224335910840/posts/default/6467865410044837025'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1907071224335910840/posts/default/6467865410044837025'/><link rel='alternate' type='text/html' href='http://embeddedlive.blogspot.com/2009/05/where-does-it-run.html' title='Where does it run ?'/><author><name>Deepz</name><uri>http://www.blogger.com/profile/16543298327846220464</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry></feed>