<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://community.element14.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>Engine Management (part 2: the cylinder)</title><link>https://community.element14.com/products/arduino/w/documents/1307/engine-management-part-2-the-cylinder</link><description /><dc:language>en-US</dc:language><generator>Telligent Community 12</generator><item><title>Engine Management (part 2: the cylinder)</title><link>https://community.element14.com/products/arduino/w/documents/1307/engine-management-part-2-the-cylinder</link><pubDate>Wed, 06 Oct 2021 20:46:54 GMT</pubDate><guid isPermaLink="false">93d5dcb4-84c2-446f-b2cb-99731719e767:7651a0f7-cce5-4a99-97aa-6febc105e434</guid><dc:creator>jack.chaney56</dc:creator><comments>https://community.element14.com/products/arduino/w/documents/1307/engine-management-part-2-the-cylinder#comments</comments><description>Current Revision posted to Documents by jack.chaney56 on 10/6/2021 8:46:54 PM&lt;br /&gt;
&lt;p style="margin:0;"&gt;Last time, after a long discussion, we figured out how to calculate RPM. This time, hopefully, without a lot of discussion, we will get some detail about our ignition events.&amp;nbsp; I also hinted before, that this will be done on a per-cylinder basis, and engines with multiple cylinders, would have multiple instances of the same operation.&lt;/p&gt;&lt;p style="margin:0;padding:0px;"&gt;&amp;nbsp;&lt;/p&gt;&lt;p style="margin:0;"&gt;I teach through metaphor as a means to explain a complicated idea using familiar imagery. The ignition management process is kind of like a carousel ride, with the riders trying to grab the gold ring. For a majority of the ride, the rider watches the target, and makes the plan. Then a short period of time before, adjust seating, and extend an arm. Then at the exact moment, clutch the ring and win the prize. Looking at the problem from the viewpoint of a single cylinder, the process is similar for ignition. The majority of the time is used for configuration and determining when we need to perform the spark. then, a short time before, we start dwell, then at just the right moment, the spark is ignited.&lt;/p&gt;&lt;p style="margin:0;padding:0px;"&gt;&amp;nbsp;&lt;/p&gt;&lt;p class="Standard" style="margin:0;"&gt;&lt;span style="font-size:11.0pt;font-family:&amp;#39;Arial&amp;#39;,sans-serif;"&gt;With this in mind we begin with the first group of equations. Each cylinder has, what is called a top dead center (TDC) point in its cycle.&amp;nbsp; This is, independent of whether it is a two or four cycle operation, the position in the cycle of full compression, before the power stroke of the cycle following ignition.&amp;nbsp; Moving earlier in the cycle is referred to as advance, while moving later in the cycle is referred to as retard.&amp;nbsp; Advance and retard are angle based measurements and managed in degrees. Several factors go into the calculation, but for now the result is all that is important so the resultant total advance will be used for a working operator.&amp;nbsp; The expression to add timing, means adding more angle to total advance. Conversely, taking away timing, or retarding, means subtracting angle from total advance.&lt;/span&gt;&lt;/p&gt;&lt;p class="Standard" style="margin:0;padding:0px;"&gt;&amp;nbsp;&lt;/p&gt;&lt;p class="Standard" style="margin:0;"&gt;&lt;span style="font-size:11.0pt;font-family:&amp;#39;Arial&amp;#39;,sans-serif;"&gt;Two factors go into the calculation of the total advance, first is rotational speed of the engine (measured in rpm), the second is the burn rate of the fuel (nothing happens instantly).&amp;nbsp; Many factors affect both of these values, and need to be monitored over the course of operation. The desired effect is to have the maximization of the expansion of ignited gasses occur at the instant past TDC (for measurement this can be TDC) to produce the maximum amount of energy. This yields our first calculation.&lt;/span&gt;&lt;/p&gt;&lt;p class="Standard" style="margin:0;padding:0px;"&gt;&amp;nbsp;&lt;/p&gt;&lt;p class="Standard" style="margin:0;"&gt;&lt;span style="font-size:11.0pt;font-family:&amp;#39;Arial&amp;#39;,sans-serif;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; sparkEvent&lt;/span&gt;&lt;span style="font-size:7.0pt;font-family:&amp;#39;Arial Narrow&amp;#39;,sans-serif;"&gt;cyl&lt;/span&gt;&lt;span style="font-size:11.0pt;font-family:&amp;#39;Arial&amp;#39;,sans-serif;"&gt; = TDC&lt;/span&gt;&lt;span style="font-size:7.0pt;font-family:&amp;#39;Arial Narrow&amp;#39;,sans-serif;"&gt;cyl&lt;/span&gt;&lt;span style="font-size:11.0pt;font-family:&amp;#39;Arial&amp;#39;,sans-serif;"&gt; – totalAdvance;&lt;/span&gt;&lt;/p&gt;&lt;p class="Standard" style="margin:0;padding:0px;"&gt;&amp;nbsp;&lt;/p&gt;&lt;p class="Standard" style="margin:0;"&gt;&lt;span style="font-size:11.0pt;font-family:&amp;#39;Arial&amp;#39;,sans-serif;"&gt;Which seems pretty simple, but TDC is a point in the cycle for each cylinder and there is one TDC for each, so this calculation needs to be repeated for each cylinder. This brings the discussion to “timing” which is the mechanical derivative of the angle to time conversion.&amp;nbsp; Even though there is a TDC for each cylinder, in discussion when the term TDC is used it references TDC of cylinder 1 or the first cylinder in the firing sequence.&lt;/span&gt;&lt;span style="font-size:11.0pt;font-family:&amp;#39;Arial&amp;#39;,sans-serif;"&gt; (Again mechanical versus mathematical definitions so cylinder numbers are one based and not zero based)&lt;/span&gt;&lt;/p&gt;&lt;p class="Standard" style="margin:0;padding:0px;"&gt;&amp;nbsp;&lt;/p&gt;&lt;p class="Standard" style="margin:0;"&gt;&lt;span style="font-size:11.0pt;font-family:&amp;#39;Arial&amp;#39;,sans-serif;"&gt;The spark event now depends on the spark generation, a dwell must be started some amount of time prior to the spark event. &lt;/span&gt;&lt;span style="font-size:11.0pt;font-family:&amp;#39;Arial&amp;#39;,sans-serif;"&gt;Again, several factors go into the calculation but for simplification, the resultant total dwell will be used for now.&amp;nbsp; Total dwell is measured in time, which cannot be directly combined with the spark event and a conversion needs to occur.&amp;nbsp; The two calculations for converting between time and angle are:&lt;/span&gt;&lt;/p&gt;&lt;p class="Standard" style="margin:0;padding:0px;"&gt;&amp;nbsp;&lt;/p&gt;&lt;p class="Standard" style="margin:0;"&gt;&lt;span style="font-size:11.0pt;font-family:&amp;#39;Arial&amp;#39;,sans-serif;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; eventAngle = DEGS_PER_REV * eventTime / ROTATIONAL_SPEED;&lt;/span&gt;&lt;/p&gt;&lt;p class="Standard" style="margin:0;"&gt;&lt;span style="font-size:11.0pt;font-family:&amp;#39;Arial&amp;#39;,sans-serif;"&gt;or&lt;/span&gt;&lt;/p&gt;&lt;p class="Standard" style="margin:0;"&gt;&lt;span style="font-size:11.0pt;font-family:&amp;#39;Arial&amp;#39;,sans-serif;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; eventTime = ROTATIONAL_SPEED * eventAngle / DEGS_PER_REV;&lt;/span&gt;&lt;/p&gt;&lt;p class="Standard" style="margin:0;padding:0px;"&gt;&amp;nbsp;&lt;/p&gt;&lt;p class="Standard" style="margin:0;"&gt;&lt;span style="font-size:11.0pt;font-family:&amp;#39;Arial&amp;#39;,sans-serif;"&gt;For discussion the calculations will be maintained in angle here, and the conversion will be from total dwell to dwell angle. This yields the second equation for start of dwell.&lt;/span&gt;&lt;/p&gt;&lt;p class="Standard" style="margin:0;padding:0px;"&gt;&amp;nbsp;&lt;/p&gt;&lt;p class="Standard" style="margin:0;"&gt;&lt;span style="font-size:11.0pt;font-family:&amp;#39;Arial&amp;#39;,sans-serif;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; dwellStart&lt;/span&gt;&lt;span style="font-size:7.0pt;font-family:&amp;#39;Arial Narrow&amp;#39;,sans-serif;"&gt;cyl&lt;/span&gt;&lt;span style="font-size:11.0pt;font-family:&amp;#39;Arial&amp;#39;,sans-serif;"&gt; = sparkEvent&lt;/span&gt;&lt;span style="font-size:7.0pt;font-family:&amp;#39;Arial Narrow&amp;#39;,sans-serif;"&gt;cyl&lt;/span&gt;&lt;span style="font-size:11.0pt;font-family:&amp;#39;Arial&amp;#39;,sans-serif;"&gt; – dwellAngle;&lt;/span&gt;&lt;/p&gt;&lt;p class="Standard" style="margin:0;padding:0px;"&gt;&amp;nbsp;&lt;/p&gt;&lt;p class="Standard" style="margin:0;"&gt;&lt;span style="font-size:11.0pt;font-family:&amp;#39;Arial&amp;#39;,sans-serif;"&gt;Again this equation is simple, but needs to be repeated for each cylinder. After the preceding operation we have obtained two events for each cylinder, the start of dwell, and the spark event. Both events need to be scheduled to occur based on the operation of the engine, and require a scheduling mechanism to link the event to the action.&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="Standard" style="margin:0;padding:0px;"&gt;&amp;nbsp;&lt;/p&gt;&lt;p class="Standard" style="margin:0;"&gt;&lt;span style="font-size:11.0pt;font-family:&amp;#39;Arial&amp;#39;,sans-serif;"&gt;This is a good point to start collecting constants and variable information. From the previous discussion there was a t&lt;sub&gt;0&lt;/sub&gt; and t&lt;sub&gt;1&lt;/sub&gt; used for the event time of the previous tooth event and the current tooth event. With that was dT for the delta between the two events, these items are candidates for variable data, where t&lt;sub&gt;1&lt;/sub&gt; becomes the new t&lt;sub&gt;0&lt;/sub&gt; at the next event. To keep track of information, the system will use a section called calibration values. Calibration values, are values that can be different for a specific motor&amp;#39;s operation, but are not likely to change substantially during operation. Candidates for calibration values are; teeth per revolution, cam to TDC&lt;sub&gt;1&lt;/sub&gt;, cylinder count, and cylinder TDC (for each). Last set of items are constants. These are physical constants that do no change like mass of dry air at sea level (handy for fueling), or number of degrees in a rotation, etc.&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="Standard" style="margin:0;padding:0px;"&gt;&amp;nbsp;&lt;/p&gt;&lt;p class="Standard" style="margin:0;"&gt;&lt;span style="font-size:11.0pt;font-family:&amp;#39;Arial&amp;#39;,sans-serif;"&gt;The basic discussion is complete, and the process is now ready to start coming together. The determination of angular velocity has already been determined, but it is necessary to locate the angular position in the rotation as well. The value of cam to TDC is used to locate the correct angle. From the previous discussion, it was determined, the cam event provides the angle of the crank event that preceded using the formula d&lt;sub&gt;0&lt;/sub&gt; = 2 * {degrees_per_rotation} - ((cam to TDC + 1) * degrees_per_tooth). For the question that is raised, &amp;quot;why use a term degrees per rotation in place of some accepted value?&amp;quot;, please accept that numbering systems are being kept as flexible as possible early on in the process and units might need to be adjusted.&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="Standard" style="margin:0;padding:0px;"&gt;&amp;nbsp;&lt;/p&gt;&lt;p class="Standard" style="margin:0;"&gt;&lt;span style="font-size:11.0pt;font-family:&amp;#39;Arial&amp;#39;,sans-serif;"&gt;Finally for this section, as soon as the value of current angle (meaning the most recent crank event) it can be determined the time until start of dwell and ignition event (spark). This is done using the formulas&lt;/span&gt;&lt;/p&gt;&lt;p class="Standard" style="margin:0;padding:0px;"&gt;&amp;nbsp;&lt;/p&gt;&lt;p class="Standard" style="margin:0;"&gt;&lt;span style="font-size:11.0pt;font-family:&amp;#39;Arial&amp;#39;,sans-serif;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; rotation_distance = sparkEvent&lt;sub&gt;cyl&lt;/sub&gt; - d0&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {where d0 is the angle of the most recent event}&lt;/span&gt;&lt;/p&gt;&lt;p class="Standard" style="margin:0;"&gt;&lt;span style="font-size:11.0pt;font-family:&amp;#39;Arial&amp;#39;,sans-serif;"&gt;if rotation_distance is a negative number, then add (2 * degrees_per_rotation). Then&lt;/span&gt;&lt;span style="font-size:11.0pt;font-family:&amp;#39;Arial&amp;#39;,sans-serif;"&gt; converting from angle to time&lt;/span&gt;&lt;/p&gt;&lt;p class="Standard" style="margin:0;"&gt;&lt;span style="font-size:11.0pt;font-family:&amp;#39;Arial&amp;#39;,sans-serif;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; time_to_event = ROTATIONAL_SPEED * rotation_distance / degrees_per_rotation&lt;/span&gt;&lt;/p&gt;&lt;p class="Standard" style="margin:0;padding:0px;"&gt;&amp;nbsp;&lt;/p&gt;&lt;p class="Standard" style="margin:0;"&gt;&lt;span style="font-size:11.0pt;font-family:&amp;#39;Arial&amp;#39;,sans-serif;"&gt;Similar equations are performed to determine start of dwell.&lt;/span&gt;&lt;/p&gt;&lt;p class="Standard" style="margin:0;padding:0px;"&gt;&amp;nbsp;&lt;/p&gt;&lt;p class="Standard" style="margin:0;"&gt;&lt;span style="font-size:11.0pt;font-family:&amp;#39;Arial&amp;#39;,sans-serif;"&gt;Promised information; a discussion about degrees in a circle. In mathematics, the units for angles is calculated in degrees, radians, and grads. Degrees are used because they date back centuries. Radians are used, mostly in mathematics because they represent a pi based ratio.&amp;nbsp; Grads are used because they provide a decimal percentage of distance around the circle.&amp;nbsp; Because this is a computer system, and integer operations are more portable to other processors, the system here will use a 16 bit value for angle where 360 degrees is equal to 32768.&amp;nbsp; This was chosen, because two rotations are needed per cam cycle, and it also provides a signed angle capability.&amp;nbsp; I leave it to you, to perform a number of operations to prove out the logic.&amp;nbsp; For discussion of theory, the named constant will be used. Once the discussion changes to applied operation, the actual value will be used.&lt;/span&gt;&lt;/p&gt;&lt;p class="Standard" style="margin:0;padding:0px;"&gt;&amp;nbsp;&lt;/p&gt;&lt;p class="Standard" style="margin:0;"&gt;&lt;span style="font-size:11.0pt;font-family:&amp;#39;Arial&amp;#39;,sans-serif;"&gt;More to come,&lt;/span&gt;&lt;/p&gt;&lt;p class="Standard" style="margin:0;"&gt;&lt;span style="font-size:11.0pt;font-family:&amp;#39;Arial&amp;#39;,sans-serif;"&gt;Jack&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;
</description></item></channel></rss>