/* Program: RPM.c Revision: 21-OCT-1995 This program ask for you to enter a number of parameters: Minimum RPM Maximum RPM Increment RPM Degrees that the trigger is before TDC Advance degrees before TDC at zero RPM Maximum advance in degrees BTDC RPM at which the maximum advance is achieved For each of the RPM increments between min and max the following information is calculated: msec per revolution msec between trigger and TDC degrees between trigger and spark msec between trigger and spark degrees spark is before TDC msec spark is before TDC */ #include #include #define PI 3.1415926 main () { float rpm, min_rpm, max_rpm, inc_rpm ; float trig_BTDC_deg, trig_BTDC_msec ; float trig_spark_deg, trig_spark_msec ; float spark_BTDC_deg, spark_BTDC_msec ; float zero_rpm_adv_deg, max_adv_deg ; float rpm_for_max_adv ; float rev_msec, temp, temp_2 ; printf(" \n "); printf(" " ); printf(" " ); printf(" \n "); printf("Enter the MINIMUM RPM for this table: ") ; scanf( "%f", &min_rpm ) ; printf(" \n ") ; printf("Enter the MAXIMUM RPM for this table: ") ; scanf( "%f", &max_rpm ) ; printf(" \n ") ; printf("Enter the RPM INCREMENT per line of this table: ") ; scanf( "%f", &inc_rpm ) ; printf(" \n ") ; printf("Enter the number of degrees the Trigger is before TDC: ") ; scanf( "%f", &trig_BTDC_deg ) ; printf(" \n ") ; printf("Enter the Degrees Advance before TDC at Zero RPM: ") ; scanf( "%f", &zero_rpm_adv_deg ) ; printf(" \n ") ; printf("Enter the Maximum Advance BTDC achieved in degrees: ") ; scanf( "%f", &max_adv_deg ) ; printf(" \n ") ; printf("Enter the RPM at which Maximum Advance is achieved: ") ; scanf( "%f", &rpm_for_max_adv ) ; printf(" \n ") ; /* Calculate and display the first table, proportional to rmp table. */ printf( "\n " ); printf( "\n In the following table the centrifugal auto-advance will " ); printf( "\n be assumed to be, linear, i.e. proportional to the rpm. " ); printf( "\n " ); printf( "\n Specifically, the degrees of advance at a given rpm is " ); printf( "\n equal to the advance at zero rpm plus current rpm / rpm " ); printf( "\n at which the maximum centrifugal auto advance is achieved " ); printf( "\n times the maximum degrees of advance provided by the " ); printf( "\n centrifugal auto advance mechanizm. " ); printf( "\n " ); printf( "\n " ); printf( "\n The Trigger is before Spark is " ); printf( "\n --------------------- ----------- " ); printf( "\n msec per TDC Spark Spark BTDC BTDC " ); printf( "\n RPM Revolution msec Degs msec Degs msec " ); printf( "\n ----- ---------- ------ ----- ----- ---- ---- " ); for (rpm = min_rpm; rpm <= max_rpm; rpm += inc_rpm) { if ( rpm == 0 ) { rev_msec = 9999 ; } else { rev_msec = 1000 * ( 1 / (rpm / 60) ) ; } trig_BTDC_msec = rev_msec * (trig_BTDC_deg / 360.0) ; if (rpm <= rpm_for_max_adv) { temp = rpm ; } else { temp = rpm_for_max_adv ; } temp_2 = (max_adv_deg - zero_rpm_adv_deg) * (temp / rpm_for_max_adv) ; spark_BTDC_deg = temp_2 + zero_rpm_adv_deg ; spark_BTDC_msec = rev_msec * (spark_BTDC_deg / 360.0) ; trig_spark_deg = trig_BTDC_deg - spark_BTDC_deg ; trig_spark_msec = rev_msec * (trig_spark_deg / 360.0) ; /* The Trigger is before Spark is */ /* --------------------- ----------- */ /* msec per TDC Spark Spark BTDC BTDC */ /* RPM Revolution msec Degs msec Degs msec */ /* ----- ---------- ------ ----- ----- ---- ---- */ printf( "\n %5.1f %4.1f %4.1f %3.1f %4.1f %3.1f %4.1f ", rpm, rev_msec, trig_BTDC_msec, trig_spark_deg, trig_spark_msec, spark_BTDC_deg, spark_BTDC_msec ) ; } /* Calculate and display the second table, fixed time BTDC table. */ printf( "\n " ); printf( "\n In the following table the centrifugal auto-advance will " ); printf( "\n provide the spark at a fixed time before TDC. " ); printf( "\n " ); printf( "\n Specifically, the degrees of advance at a given rpm is " ); printf( "\n calculated to always provide the spark at a fixed number " ); printf( "\n of msec before TDC. The number of msec is picked to " ); printf( "\n match the maximum advance provieded and the rpm at which " ); printf( "\n the maximum advance is achieved. The input parameter, " ); printf( "\n advance at zero rpm, is not used. " ); printf( "\n " ); printf( "\n " ); printf( "\n The Trigger is before Spark is " ); printf( "\n --------------------- ----------- " ); printf( "\n msec per TDC Spark Spark BTDC BTDC " ); printf( "\n RPM Revolution msec Degs msec Degs msec " ); printf( "\n ----- ---------- ------ ----- ----- ---- ---- " ); for (rpm = min_rpm; rpm <= max_rpm; rpm += inc_rpm) { if ( rpm == 0 ) { rev_msec = 9999 ; } else { rev_msec = 1000 * ( 1 / (rpm / 60) ) ; } trig_BTDC_msec = rev_msec * (trig_BTDC_deg / 360.0) ; if (rpm <= rpm_for_max_adv) { spark_BTDC_msec = (max_adv_deg / 360.0) * (1000 * ( 1 / (rpm_for_max_adv / 60))) ; spark_BTDC_deg = (spark_BTDC_msec / rev_msec) * 360.0 ; } else { spark_BTDC_deg = max_adv_deg ; spark_BTDC_msec = rev_msec * ( spark_BTDC_deg / 360.0 ) ; } trig_spark_deg = trig_BTDC_deg - spark_BTDC_deg ; trig_spark_msec = rev_msec * (trig_spark_deg / 360.0) ; /* The Trigger is before Spark is */ /* --------------------- ----------- */ /* msec per TDC Spark Spark BTDC BTDC */ /* RPM Revolution msec Degs msec Degs msec */ /* ----- ---------- ------ ----- ----- ---- ---- */ printf( "\n %5.1f %4.1f %4.1f %3.1f %4.1f %3.1f %4.1f ", rpm, rev_msec, trig_BTDC_msec, trig_spark_deg, trig_spark_msec, spark_BTDC_deg, spark_BTDC_msec ) ; } }