diff --git a/ardustim/src/ardustim.ino b/ardustim/src/ardustim.ino index d1ef3d9..c3d84e8 100644 --- a/ardustim/src/ardustim.ino +++ b/ardustim/src/ardustim.ino @@ -1,549 +1,553 @@ -/* vim: set syntax=c expandtab sw=2 softtabstop=2 autoindent smartindent smarttab : */ -/* - * Arbritrary wheel pattern generator - * - * copyright 2014 David J. Andruczyk - * - * Ardu-Stim software is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * ArduStim software is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with any ArduStim software. If not, see http://www.gnu.org/licenses/ - * - */ - -#include "defines.h" -#include "ardustim.h" -#include "enums.h" -#include "comms.h" -#include "storage.h" -#include "user_defaults.h" -#include "wheel_defs.h" -#include -#include - -/* Sensistive stuff used in ISR's */ -volatile uint8_t fraction = 0; -volatile uint16_t adc0; /* POT RPM */ -volatile uint16_t adc1; /* Pot Wheel select */ -volatile uint32_t oc_remainder = 0; -/* Setting rpm to any value over 0 will enabled sweeping by default */ -/* Stuff for handling prescaler changes (small tooth wheels are low RPM) */ -volatile uint8_t analog_port = 0; -volatile bool adc0_read_complete = false; -volatile bool adc1_read_complete = false; -volatile bool reset_prescaler = false; -volatile bool normal = true; -volatile bool sweep_reset_prescaler = true; /* Force sweep to reset prescaler value */ -volatile bool sweep_lock = false; -volatile uint8_t output_invert_mask = 0x00; /* Don't invert anything */ -volatile uint8_t sweep_direction = ASCENDING; -volatile byte total_sweep_stages = 0; -volatile uint8_t sweep_stage = 0; -volatile uint8_t prescaler_bits = 0; -volatile uint8_t last_prescaler_bits = 0; -volatile uint8_t mode = 0; -volatile uint16_t new_OCR1A = 5000; /* sane default */ -volatile uint16_t edge_counter = 0; - -/* Less sensitive globals */ -uint8_t bitshift = 0; -uint16_t sweep_low_rpm = 250; -uint16_t sweep_high_rpm = 4000; -uint16_t sweep_rate = 1; - -sweep_step *SweepSteps; /* Global pointer for the sweep steps */ - -wheels Wheels[MAX_WHEELS] = { - /* Pointer to friendly name string, pointer to edge array, RPM Scaler, Number of edges in the array */ - { dizzy_four_cylinder_friendly_name, dizzy_four_cylinder, 0.003333, 4, 360 }, - { dizzy_six_cylinder_friendly_name, dizzy_six_cylinder, 0.05, 6, 360 }, - { dizzy_eight_cylinder_friendly_name, dizzy_eight_cylinder, 0.06667, 8, 360 }, - { sixty_minus_two_friendly_name, sixty_minus_two, 1.0, 120, 360 }, - { sixty_minus_two_with_cam_friendly_name, sixty_minus_two_with_cam, 1.0, 240, 720 }, - { thirty_six_minus_one_friendly_name, thirty_six_minus_one, 0.6, 72, 360 }, - { twenty_four_minus_one_friendly_name, twenty_four_minus_one, 0.5, 48, 360 }, - { four_minus_one_with_cam_friendly_name, four_minus_one_with_cam, 0.06667, 16, 720 }, - { eight_minus_one_friendly_name, eight_minus_one, 0.13333, 16, 360 }, - { six_minus_one_with_cam_friendly_name, six_minus_one_with_cam, 0.15, 36, 720 }, - { twelve_minus_one_with_cam_friendly_name, twelve_minus_one_with_cam, 0.6, 144, 720 }, - { fourty_minus_one_friendly_name, fourty_minus_one, 0.66667, 80, 360 }, - { dizzy_four_trigger_return_friendly_name, dizzy_four_trigger_return, 0.15, 9, 720 }, - { oddfire_vr_friendly_name, oddfire_vr, 0.2, 24, 360 }, - { optispark_lt1_friendly_name, optispark_lt1, 3.0, 720, 720 }, - { twelve_minus_three_friendly_name, twelve_minus_three, 0.4, 48, 360 }, - { thirty_six_minus_two_two_two_friendly_name, thirty_six_minus_two_two_two, 0.6, 72, 360 }, - { thirty_six_minus_two_two_two_with_cam_friendly_name, thirty_six_minus_two_two_two_with_cam, 0.6, 144, 720 }, - { fourty_two_hundred_wheel_friendly_name, fourty_two_hundred_wheel, 0.6, 72, 360 }, - { thirty_six_minus_one_with_cam_fe3_friendly_name, thirty_six_minus_one_with_cam_fe3, 0.6, 144, 720 }, - { six_g_seventy_two_with_cam_friendly_name, six_g_seventy_two_with_cam, 0.6, 144, 720 }, - { buell_oddfire_cam_friendly_name, buell_oddfire_cam, 0.33333, 80, 720 }, - { gm_ls1_crank_and_cam_friendly_name, gm_ls1_crank_and_cam, 6.0, 720, 720 }, - { lotus_thirty_six_minus_one_one_one_one_friendly_name, lotus_thirty_six_minus_one_one_one_one, 0.6, 72, 360 }, - { honda_rc51_with_cam_friendly_name, honda_rc51_with_cam, 0.2, 48, 720 }, - { thirty_six_minus_one_with_second_trigger_friendly_name, thirty_six_minus_one_with_second_trigger, 0.6, 144, 720 }, - { thirty_six_minus_one_plus_one_with_cam_ngc4_friendly_name, thirty_six_minus_one_plus_one_with_cam_ngc4, 3.0, 720, 720 }, - { weber_iaw_with_cam_friendly_name, weber_iaw_with_cam, 1.2, 144, 720 }, - { fiat_one_point_eight_sixteen_valve_with_cam_friendly_name, fiat_one_point_eight_sixteen_valve_with_cam, 3.0, 720, 720 }, - { three_sixty_nissan_cas_friendly_name, three_sixty_nissan_cas, 3.0, 720, 720 }, - { twenty_four_minus_two_with_second_trigger_friendly_name, twenty_four_minus_two_with_second_trigger, 0.3, 72, 720 }, - { yamaha_eight_tooth_with_cam_friendly_name, yamaha_eight_tooth_with_cam, 0.26667, 64, 720 }, - { gm_four_tooth_with_cam_friendly_name, gm_four_tooth_with_cam, 0.06666, 8, 720 }, - { gm_six_tooth_with_cam_friendly_name, gm_six_tooth_with_cam, 0.1, 12, 720 }, - { gm_eight_tooth_with_cam_friendly_name, gm_eight_tooth_with_cam, 0.13333, 16, 720 }, - { volvo_d12acd_with_cam_friendly_name, volvo_d12acd_with_cam, 4.0, 480, 720 }, - { mazda_thirty_six_minus_two_two_two_with_six_tooth_cam_friendly_name, mazda_thirty_six_minus_two_two_two_with_six_tooth_cam, 1.5, 360, 720 }, - { mitsubishi_4g63_4_2_friendly_name, mitsubishi_4g63_4_2, 0.6, 144, 720 }, - { audi_135_with_cam_friendly_name, audi_135_with_cam, 1.5, 1080, 720 }, - { honda_d17_no_cam_friendly_name, honda_d17_no_cam, 0.6, 144, 720 }, - { mazda_323_au_friendly_name, mazda_323_au, 1, 30, 720 }, - { daihatsu_3cyl_friendly_name, daihatsu_3cyl, 0.8, 144, 360 }, - { miata_9905_friendly_name, miata_9905, 0.6, 144, 720 }, - { twelve_with_cam_friendly_name, twelve_with_cam, 0.6, 144, 720 }, - { twenty_four_with_cam_friendly_name, twelve_with_cam, 0.6, 144, 720 }, - { subaru_six_seven_name_friendly_name, subaru_six_seven, 3.0, 720, 720 }, - { gm_seven_x_friendly_name, gm_seven_x, 1.502, 180, 720 }, - { four_twenty_a_friendly_name, four_twenty_a, 0.6, 144, 720 }, - { ford_st170_friendly_name, ford_st170, 0.6, 720, 720 }, - { mitsubishi_3A92_friendly_name, mitsubishi_3A92, 0.6, 144, 720 }, -}; - -/* Initialization */ -void setup() { - serialSetup(); - loadConfig(); - - cli(); // stop interrupts - - /* Configuring TIMER1 (pattern generator) */ - // Set timer1 to generate pulses - TCCR1A = 0; - TCCR1B = 0; - TCNT1 = 0; - - // Set compare register to sane default - OCR1A = 1000; /* 8000 RPM (60-2) */ - - // Turn on CTC mode - TCCR1B |= (1 << WGM12); // Normal mode (not PWM) - // Set prescaler to 1 - TCCR1B |= (1 << CS10); /* Prescaler of 1 */ - // Enable output compare interrupt for timer channel 1 (16 bit) - TIMSK1 |= (1 << OCIE1A); - - // Set timer2 to run sweeper routine - TCCR2A = 0; - TCCR2B = 0; - TCNT2 = 0; - - // Set compare register to sane default - OCR2A = 249; /* With prescale of x64 gives 1ms tick */ - - // Turn on CTC mode - TCCR2A |= (1 << WGM21); // Normal mode (not PWM) - // Set prescaler to x64 - TCCR2B |= (1 << CS22); /* Prescaler of 64 */ - // Enable output compare interrupt for timer channel 2 - TIMSK2 |= (1 << OCIE2A); - - - /* Configure ADC as per http://www.glennsweeney.com/tutorials/interrupt-driven-analog-conversion-with-an-atmega328p */ - // clear ADLAR in ADMUX (0x7C) to right-adjust the result - // ADCL will contain lower 8 bits, ADCH upper 2 (in last two bits) - ADMUX &= B11011111; - - // Set REFS1..0 in ADMUX (0x7C) to change reference voltage to the - // proper source (01) - ADMUX |= B01000000; - - // Clear MUX3..0 in ADMUX (0x7C) in preparation for setting the analog - // input - ADMUX &= B11110000; - - // Set MUX3..0 in ADMUX (0x7C) to read from AD8 (Internal temp) - // Do not set above 15! You will overrun other parts of ADMUX. A full - // list of possible inputs is available in Table 24-4 of the ATMega328 - // datasheet - // ADMUX |= 8; - // ADMUX |= B00001000; // Binary equivalent - - // Set ADEN in ADCSRA (0x7A) to enable the ADC. - // Note, this instruction takes 12 ADC clocks to execute - ADCSRA |= B10000000; - - // Set ADATE in ADCSRA (0x7A) to enable auto-triggering. - ADCSRA |= B00100000; - - // Clear ADTS2..0 in ADCSRB (0x7B) to set trigger mode to free running. - // This means that as soon as an ADC has finished, the next will be - // immediately started. - ADCSRB &= B11111000; - - // Set the Prescaler to 128 (16000KHz/128 = 125KHz) - // Above 200KHz 10-bit results are not reliable. - ADCSRA |= B00000111; - - // Set ADIE in ADCSRA (0x7A) to enable the ADC interrupt. - // Without this, the internal interrupt will not trigger. - ADCSRA |= B00001000; - -// pinMode(7, OUTPUT); /* Debug pin for Saleae to track sweep ISR execution speed */ - pinMode(8, OUTPUT); /* Primary (crank usually) output */ - pinMode(9, OUTPUT); /* Secondary (cam usually) output */ - pinMode(10, OUTPUT); /* Knock signal for seank, ony on LS1 pattern, NOT IMPL YET */ -#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__) - pinMode(53, OUTPUT); - pinMode(52, OUTPUT); -#endif - - sei(); // Enable interrupts - // Set ADSC in ADCSRA (0x7A) to start the ADC conversion - ADCSRA |= B01000000; - /* Make sure we are using the DEFAULT RPM on startup */ - reset_new_OCR1A(wanted_rpm); - -} // End setup - - -//! ADC ISR for alternating between ADC pins 0 and 1 -/*! - * Reads ADC ports 0 and 1 alternately. Port 0 is RPM, Port 1 is for - * future fun (possible wheel selection) - */ -ISR(ADC_vect){ - if (analog_port == 0) - { - adc0 = ADCL | (ADCH << 8); - adc0_read_complete = true; - /* Flip to channel 1 */ - //ADMUX |= B00000001; - //analog_port = 1; - /* Trigger another conversion */ - //ADCSRA |= B01000000; - return; - } -// if (analog_port == 1) -// { -// adc1 = ADCL | (ADCH << 8); -// adc1_read_complete = true; -// /* Flip to channel 0 */ -// /* Tell it to read ADC0, clear MUX0..3 */ -// ADMUX &= B11110000; -// analog_port = 0; -// /* Trigger another conversion */ -// ADCSRA |= B01000000; -// return; -// } -} - - -/* This is the "low speed" 1000x/second sweeper interrupt routine - * who's sole purpose in life is to reset the output compare value - * for timer zero to change the output RPM. In cases where the RPM - * change per ISR is LESS than one LSB of the counter a set of modulus - * variabels are used to handle fractional values. - */ -ISR(TIMER2_COMPA_vect) { -// PORTD = (1 << 7); - if ( mode != LINEAR_SWEPT_RPM) - { -// PORTD = (0 << 7); - return; - } - if (sweep_lock) // semaphore to protect around changes/critical sections - { - // PORTD = (0 << 7); - return; - } - sweep_lock = true; - if (sweep_reset_prescaler) - { - sweep_reset_prescaler = false; - reset_prescaler = true; - prescaler_bits = SweepSteps[sweep_stage].prescaler_bits; - last_prescaler_bits = prescaler_bits; - } - /* Sweep code */ - if (sweep_direction == ASCENDING) - { - oc_remainder += SweepSteps[sweep_stage].remainder_per_isr; - /* IF the total is over the threshold we increment the TCNT factor - * for each multiple it is over by - */ - while (oc_remainder > FACTOR_THRESHOLD) - { - fraction++; - oc_remainder -= FACTOR_THRESHOLD; - } - if (new_OCR1A > SweepSteps[sweep_stage].ending_ocr) - { - new_OCR1A -= (SweepSteps[sweep_stage].tcnt_per_isr + fraction); - fraction = 0; - } - else /* END of the stage, find out where we are */ - { - sweep_stage++; - oc_remainder = 0; - if (sweep_stage < total_sweep_stages) - { - /* Toggle when changing stages */ - //PORTD &= ~(1<<7); /* turn DBG pin off */ - //PORTD |= (1<<7); /* Turn DBG pin on */ - new_OCR1A = SweepSteps[sweep_stage].beginning_ocr; - if (SweepSteps[sweep_stage].prescaler_bits != last_prescaler_bits) - sweep_reset_prescaler = true; - } - else /* END of line, time to reverse direction */ - { - sweep_stage--; /*Bring back within limits */ - sweep_direction = DESCENDING; - new_OCR1A = SweepSteps[sweep_stage].ending_ocr; - if (SweepSteps[sweep_stage].prescaler_bits != last_prescaler_bits) - sweep_reset_prescaler = true; - PORTD |= 1 << 7; /* Debugginga, ascending */ - } - /* Reset fractionals or next round */ - } - } - else /* Descending */ - { - oc_remainder += SweepSteps[sweep_stage].remainder_per_isr; - while (oc_remainder > FACTOR_THRESHOLD) - { - fraction++; - oc_remainder -= FACTOR_THRESHOLD; - } - if (new_OCR1A < SweepSteps[sweep_stage].beginning_ocr) - { - new_OCR1A += (SweepSteps[sweep_stage].tcnt_per_isr + fraction); - fraction = 0; - } - else /* End of stage */ - { - sweep_stage--; - oc_remainder = 0; - if (sweep_stage >= 0) - { - new_OCR1A = SweepSteps[sweep_stage].ending_ocr; - if (SweepSteps[sweep_stage].prescaler_bits != last_prescaler_bits) - sweep_reset_prescaler = true; - } - else /*End of the line */ - { - sweep_stage++; /*Bring back within limits */ - sweep_direction = ASCENDING; - new_OCR1A = SweepSteps[sweep_stage].beginning_ocr; - if (SweepSteps[sweep_stage].prescaler_bits != last_prescaler_bits) - sweep_reset_prescaler = true; - PORTD &= ~(1<<7); /*Descending turn pin off */ - } - } - } - sweep_lock = false; - //wanted_rpm = get_rpm_from_tcnt(&SweepSteps[sweep_stage].beginning_ocr, &SweepSteps[sweep_stage].prescaler_bits); -// PORTD = (0 << 7); -} - -/* Pumps the pattern out of flash to the port - * The rate at which this runs is dependent on what OCR1A is set to - * the sweeper in timer2 alters this on the fly to alow changing of RPM - * in a very nice way - */ -ISR(TIMER1_COMPA_vect) { - /* This is VERY simple, just walk the array and wrap when we hit the limit */ - PORTB = output_invert_mask ^ pgm_read_byte(&Wheels[selected_wheel].edge_states_ptr[edge_counter]); /* Write it to the port */ - /* Normal direction overflow handling */ - if (normal) - { - edge_counter++; - if (edge_counter == Wheels[selected_wheel].wheel_max_edges) { - edge_counter = 0; - } - } - else - { - if (edge_counter == 0) - edge_counter = Wheels[selected_wheel].wheel_max_edges; - edge_counter--; - } - /* The tables are in flash so we need pgm_read_byte() */ - - /* Reset Prescaler only if flag is set */ - if (reset_prescaler) - { - TCCR1B &= ~((1 << CS10) | (1 << CS11) | (1 << CS12)); /* Clear CS10, CS11 and CS12 */ - TCCR1B |= prescaler_bits; - reset_prescaler = false; - } - /* Reset next compare value for RPM changes */ - OCR1A = new_OCR1A; /* Apply new "RPM" from Timer2 ISR, i.e. speed up/down the virtual "wheel" */ -} - -void loop() -{ - uint16_t tmp_rpm = 0; - /* Just handle the Serial UI, everything else is in - * interrupt handlers or callbacks from SerialUI. - */ - - - if(Serial.available() > 0) { commandParser(); } - - if(mode == POT_RPM) - { - if (adc0_read_complete == true) - { - adc0_read_complete = false; - tmp_rpm = adc0 << TMP_RPM_SHIFT; - if (tmp_rpm > TMP_RPM_CAP) { tmp_rpm = TMP_RPM_CAP; } - wanted_rpm = tmp_rpm; - reset_new_OCR1A(tmp_rpm); - } - } - -} - - -void reset_new_OCR1A(uint32_t new_rpm) -{ - uint32_t tmp; - uint8_t bitshift; - uint8_t tmp_prescaler_bits; - tmp = (uint32_t)(8000000.0/(Wheels[selected_wheel].rpm_scaler * (float)(new_rpm < 10 ? 10:new_rpm))); -/* mySUI.print(F("new_OCR1a: ")); - mySUI.println(tmpl); - */ - get_prescaler_bits(&tmp,&tmp_prescaler_bits,&bitshift); - /* - mySUI.print(F("new_OCR1a: ")); - mySUI.println(tmp2); - */ - new_OCR1A = (uint16_t)(tmp >> bitshift); - prescaler_bits = tmp_prescaler_bits; - reset_prescaler = true; -} - - -uint8_t get_bitshift_from_prescaler(uint8_t *prescaler_bits) -{ - switch (*prescaler_bits) - { - case PRESCALE_1024: - return 10; - case PRESCALE_256: - return 8; - case PRESCALE_64: - return 6; - case PRESCALE_8: - return 3; - case PRESCALE_1: - return 0; - } - return 0; -} - - -//! Gets RPM from the TCNT value -/*! - * Gets the RPM value based on the passed TCNT and prescaler - * \param tcnt pointer to Output Compare register value - * \param prescaler_bits point to prescaler bits enum - */ -uint16_t get_rpm_from_tcnt(uint16_t *tcnt, uint8_t *prescaler_bits) -{ - bitshift = get_bitshift_from_prescaler(prescaler_bits); - return (uint16_t)((float)(8000000 >> bitshift)/(Wheels[selected_wheel].rpm_scaler*(*tcnt))); -} - - -//! Gets prescaler enum and bitshift based on OC value -void get_prescaler_bits(uint32_t *potential_oc_value, uint8_t *prescaler, uint8_t *bitshift) -{ - if (*potential_oc_value >= 16777216) - { - *prescaler = PRESCALE_1024; - *bitshift = 10; - } - else if (*potential_oc_value >= 4194304) - { - *prescaler = PRESCALE_256; - *bitshift = 8; - } - else if (*potential_oc_value >= 524288) - { - *prescaler = PRESCALE_64; - *bitshift = 6; - } - else if (*potential_oc_value >= 65536) - { - *prescaler = PRESCALE_8; - *bitshift = 3; - } - else - { - *prescaler = PRESCALE_1; - *bitshift = 0; - } -} - - -//! Builds the SweepSteps[] structure -/*! - * For sweeping we cannot just pick the TCNT value at the beginning and ending - * and sweep linearily between them as it'll result in a VERY slow RPM change - * at the low end and a VERY FAST change at the high end due to the inverse - * relationship between RPM and TCNT. So we compromise and break up the RPM - * range into octaves (doubles of RPM), and use a linear TCNT change between - * those two points. It's not perfect, but computationally easy - * - * \param low_rpm_tcnt pointer to low rpm OC value, (not prescaled!) - * \param high_rpm_tcnt pointer to low rpm OC value, (not prescaled!) - * \param total_stages pointer to tell the number of structs to allocate - * \returns pointer to array of structures for each sweep stage. - */ -sweep_step *build_sweep_steps(uint32_t *low_rpm_tcnt, uint32_t *high_rpm_tcnt, uint8_t *total_stages) -{ - sweep_step *steps; - uint8_t prescaler_bits; - uint8_t bitshift; - uint32_t tmp = *low_rpm_tcnt; - /* DEBUG - mySUI.print(*low_rpm_tcnt); - mySUI.print(F("<->")); - mySUI.println(*high_rpm_tcnt); - */ - - steps = (sweep_step *)malloc(sizeof(sweep_step)*(*total_stages)); - -#ifdef MORE_LINEAR_SWEEP - for (uint8_t i = 0; i < (*total_stages); i+=2) -#else - for (uint8_t i = 0; i < (*total_stages); i++) -#endif - { - /* The low rpm value will ALWAYS have the highed TCNT value so use that - to determine the prescaler value - */ - get_prescaler_bits(&tmp, &steps[i].prescaler_bits, &bitshift); - - steps[i].beginning_ocr = (uint16_t)(tmp >> bitshift); - if ((tmp >> 1) < (*high_rpm_tcnt)) - steps[i].ending_ocr = (uint16_t)((*high_rpm_tcnt) >> bitshift); - else - steps[i].ending_ocr = (uint16_t)(tmp >> (bitshift + 1)); // Half the begin value - tmp = tmp >> 1; /* Divide by 2 */ - /* DEBUG - mySUI.print(steps[i].beginning_ocr); - mySUI.print(F("<->")); - mySUI.println(steps[i].ending_ocr); - */ - } - return steps; -} +/* vim: set syntax=c expandtab sw=2 softtabstop=2 autoindent smartindent smarttab : */ +/* + * Arbritrary wheel pattern generator + * + * copyright 2014 David J. Andruczyk + * + * Ardu-Stim software is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * ArduStim software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with any ArduStim software. If not, see http://www.gnu.org/licenses/ + * + */ + +#include "defines.h" +#include "ardustim.h" +#include "enums.h" +#include "comms.h" +#include "storage.h" +#include "user_defaults.h" +#include "wheel_defs.h" +#include +#include + +/* Sensistive stuff used in ISR's */ +volatile uint8_t fraction = 0; +volatile uint16_t adc0; /* POT RPM */ +volatile uint16_t adc1; /* Pot Wheel select */ +volatile uint32_t oc_remainder = 0; +/* Setting rpm to any value over 0 will enabled sweeping by default */ +/* Stuff for handling prescaler changes (small tooth wheels are low RPM) */ +volatile uint8_t analog_port = 0; +volatile bool adc0_read_complete = false; +volatile bool adc1_read_complete = false; +volatile bool reset_prescaler = false; +volatile bool normal = true; +volatile bool sweep_reset_prescaler = true; /* Force sweep to reset prescaler value */ +volatile bool sweep_lock = false; +volatile uint8_t output_invert_mask = 0x00; /* Don't invert anything */ +volatile uint8_t sweep_direction = ASCENDING; +volatile byte total_sweep_stages = 0; +volatile uint8_t sweep_stage = 0; +volatile uint8_t prescaler_bits = 0; +volatile uint8_t last_prescaler_bits = 0; +volatile uint8_t mode = 0; +volatile uint16_t new_OCR1A = 5000; /* sane default */ +volatile uint16_t edge_counter = 0; + +/* Less sensitive globals */ +uint8_t bitshift = 0; +uint16_t sweep_low_rpm = 250; +uint16_t sweep_high_rpm = 4000; +uint16_t sweep_rate = 1; + +sweep_step *SweepSteps; /* Global pointer for the sweep steps */ + +wheels Wheels[MAX_WHEELS] = { + /* Pointer to friendly name string, pointer to edge array, RPM Scaler, Number of edges in the array */ + { dizzy_four_cylinder_friendly_name, dizzy_four_cylinder, 0.003333, 4, 360 }, + { dizzy_six_cylinder_friendly_name, dizzy_six_cylinder, 0.05, 6, 360 }, + { dizzy_eight_cylinder_friendly_name, dizzy_eight_cylinder, 0.06667, 8, 360 }, + { sixty_minus_two_friendly_name, sixty_minus_two, 1.0, 120, 360 }, + { sixty_minus_two_with_cam_friendly_name, sixty_minus_two_with_cam, 1.0, 240, 720 }, + { thirty_six_minus_one_friendly_name, thirty_six_minus_one, 0.6, 72, 360 }, + { twenty_four_minus_one_friendly_name, twenty_four_minus_one, 0.5, 48, 360 }, + { four_minus_one_with_cam_friendly_name, four_minus_one_with_cam, 0.06667, 16, 720 }, + { eight_minus_one_friendly_name, eight_minus_one, 0.13333, 16, 360 }, + { six_minus_one_with_cam_friendly_name, six_minus_one_with_cam, 0.15, 36, 720 }, + { twelve_minus_one_with_cam_friendly_name, twelve_minus_one_with_cam, 0.6, 144, 720 }, + { fourty_minus_one_friendly_name, fourty_minus_one, 0.66667, 80, 360 }, + { dizzy_four_trigger_return_friendly_name, dizzy_four_trigger_return, 0.15, 9, 720 }, + { oddfire_vr_friendly_name, oddfire_vr, 0.2, 24, 360 }, + { optispark_lt1_friendly_name, optispark_lt1, 3.0, 720, 720 }, + { twelve_minus_three_friendly_name, twelve_minus_three, 0.4, 48, 360 }, + { thirty_six_minus_two_two_two_friendly_name, thirty_six_minus_two_two_two, 0.6, 72, 360 }, + { thirty_six_minus_two_two_two_with_cam_friendly_name, thirty_six_minus_two_two_two_with_cam, 0.6, 144, 720 }, + { fourty_two_hundred_wheel_friendly_name, fourty_two_hundred_wheel, 0.6, 72, 360 }, + { thirty_six_minus_one_with_cam_fe3_friendly_name, thirty_six_minus_one_with_cam_fe3, 0.6, 144, 720 }, + { six_g_seventy_two_with_cam_friendly_name, six_g_seventy_two_with_cam, 0.6, 144, 720 }, + { buell_oddfire_cam_friendly_name, buell_oddfire_cam, 0.33333, 80, 720 }, + { gm_ls1_crank_and_cam_friendly_name, gm_ls1_crank_and_cam, 6.0, 720, 720 }, + { lotus_thirty_six_minus_one_one_one_one_friendly_name, lotus_thirty_six_minus_one_one_one_one, 0.6, 72, 360 }, + { honda_rc51_with_cam_friendly_name, honda_rc51_with_cam, 0.2, 48, 720 }, + { thirty_six_minus_one_with_second_trigger_friendly_name, thirty_six_minus_one_with_second_trigger, 0.6, 144, 720 }, + { thirty_six_minus_one_plus_one_with_cam_ngc4_friendly_name, thirty_six_minus_one_plus_one_with_cam_ngc4, 3.0, 720, 720 }, + { weber_iaw_with_cam_friendly_name, weber_iaw_with_cam, 1.2, 144, 720 }, + { fiat_one_point_eight_sixteen_valve_with_cam_friendly_name, fiat_one_point_eight_sixteen_valve_with_cam, 3.0, 720, 720 }, + { three_sixty_nissan_cas_friendly_name, three_sixty_nissan_cas, 3.0, 720, 720 }, + { twenty_four_minus_two_with_second_trigger_friendly_name, twenty_four_minus_two_with_second_trigger, 0.3, 72, 720 }, + { yamaha_eight_tooth_with_cam_friendly_name, yamaha_eight_tooth_with_cam, 0.26667, 64, 720 }, + { gm_four_tooth_with_cam_friendly_name, gm_four_tooth_with_cam, 0.06666, 8, 720 }, + { gm_six_tooth_with_cam_friendly_name, gm_six_tooth_with_cam, 0.1, 12, 720 }, + { gm_eight_tooth_with_cam_friendly_name, gm_eight_tooth_with_cam, 0.13333, 16, 720 }, + { volvo_d12acd_with_cam_friendly_name, volvo_d12acd_with_cam, 4.0, 480, 720 }, + { mazda_thirty_six_minus_two_two_two_with_six_tooth_cam_friendly_name, mazda_thirty_six_minus_two_two_two_with_six_tooth_cam, 1.5, 360, 720 }, + { mitsubishi_4g63_4_2_friendly_name, mitsubishi_4g63_4_2, 0.6, 144, 720 }, + { audi_135_with_cam_friendly_name, audi_135_with_cam, 1.5, 1080, 720 }, + { honda_d17_no_cam_friendly_name, honda_d17_no_cam, 0.6, 144, 720 }, + { mazda_323_au_friendly_name, mazda_323_au, 1, 30, 720 }, + { daihatsu_3cyl_friendly_name, daihatsu_3cyl, 0.8, 144, 360 }, + { miata_9905_friendly_name, miata_9905, 0.6, 144, 720 }, + { twelve_with_cam_friendly_name, twelve_with_cam, 0.6, 144, 720 }, + { twenty_four_with_cam_friendly_name, twelve_with_cam, 0.6, 144, 720 }, + { subaru_six_seven_name_friendly_name, subaru_six_seven, 3.0, 720, 720 }, + { gm_seven_x_friendly_name, gm_seven_x, 1.502, 180, 720 }, + { four_twenty_a_friendly_name, four_twenty_a, 0.6, 144, 720 }, + { ford_st170_friendly_name, ford_st170, 0.6, 720, 720 }, + { mitsubishi_3A92_friendly_name, mitsubishi_3A92, 0.6, 144, 720 }, + { rover_k_mode1_thirtysix_minus_one_one_friendly_name, rover_k_mode1_thirtysix_minus_one_one, 0.6, 72, 360 }, + { rover_k_mode2_thirtysix_minus_one_one_one_one_friendly_name, rover_k_mode2_thirtysix_minus_one_one_one_one, 0.6, 72, 360 }, + { rover_k_mode3_thirtysix_minus_one_one_one_one_friendly_name, rover_k_mode3_thirtysix_minus_one_one_one_one, 0.6, 72, 360 }, + { rover_k_mode4_thirtysix_minus_one_one_one_one_friendly_name, rover_k_mode4_thirtysix_minus_one_one_one_one, 0.6, 72, 360 }, +}; + +/* Initialization */ +void setup() { + serialSetup(); + loadConfig(); + + cli(); // stop interrupts + + /* Configuring TIMER1 (pattern generator) */ + // Set timer1 to generate pulses + TCCR1A = 0; + TCCR1B = 0; + TCNT1 = 0; + + // Set compare register to sane default + OCR1A = 1000; /* 8000 RPM (60-2) */ + + // Turn on CTC mode + TCCR1B |= (1 << WGM12); // Normal mode (not PWM) + // Set prescaler to 1 + TCCR1B |= (1 << CS10); /* Prescaler of 1 */ + // Enable output compare interrupt for timer channel 1 (16 bit) + TIMSK1 |= (1 << OCIE1A); + + // Set timer2 to run sweeper routine + TCCR2A = 0; + TCCR2B = 0; + TCNT2 = 0; + + // Set compare register to sane default + OCR2A = 249; /* With prescale of x64 gives 1ms tick */ + + // Turn on CTC mode + TCCR2A |= (1 << WGM21); // Normal mode (not PWM) + // Set prescaler to x64 + TCCR2B |= (1 << CS22); /* Prescaler of 64 */ + // Enable output compare interrupt for timer channel 2 + TIMSK2 |= (1 << OCIE2A); + + + /* Configure ADC as per http://www.glennsweeney.com/tutorials/interrupt-driven-analog-conversion-with-an-atmega328p */ + // clear ADLAR in ADMUX (0x7C) to right-adjust the result + // ADCL will contain lower 8 bits, ADCH upper 2 (in last two bits) + ADMUX &= B11011111; + + // Set REFS1..0 in ADMUX (0x7C) to change reference voltage to the + // proper source (01) + ADMUX |= B01000000; + + // Clear MUX3..0 in ADMUX (0x7C) in preparation for setting the analog + // input + ADMUX &= B11110000; + + // Set MUX3..0 in ADMUX (0x7C) to read from AD8 (Internal temp) + // Do not set above 15! You will overrun other parts of ADMUX. A full + // list of possible inputs is available in Table 24-4 of the ATMega328 + // datasheet + // ADMUX |= 8; + // ADMUX |= B00001000; // Binary equivalent + + // Set ADEN in ADCSRA (0x7A) to enable the ADC. + // Note, this instruction takes 12 ADC clocks to execute + ADCSRA |= B10000000; + + // Set ADATE in ADCSRA (0x7A) to enable auto-triggering. + ADCSRA |= B00100000; + + // Clear ADTS2..0 in ADCSRB (0x7B) to set trigger mode to free running. + // This means that as soon as an ADC has finished, the next will be + // immediately started. + ADCSRB &= B11111000; + + // Set the Prescaler to 128 (16000KHz/128 = 125KHz) + // Above 200KHz 10-bit results are not reliable. + ADCSRA |= B00000111; + + // Set ADIE in ADCSRA (0x7A) to enable the ADC interrupt. + // Without this, the internal interrupt will not trigger. + ADCSRA |= B00001000; + +// pinMode(7, OUTPUT); /* Debug pin for Saleae to track sweep ISR execution speed */ + pinMode(8, OUTPUT); /* Primary (crank usually) output */ + pinMode(9, OUTPUT); /* Secondary (cam usually) output */ + pinMode(10, OUTPUT); /* Knock signal for seank, ony on LS1 pattern, NOT IMPL YET */ +#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__) + pinMode(53, OUTPUT); + pinMode(52, OUTPUT); +#endif + + sei(); // Enable interrupts + // Set ADSC in ADCSRA (0x7A) to start the ADC conversion + ADCSRA |= B01000000; + /* Make sure we are using the DEFAULT RPM on startup */ + reset_new_OCR1A(wanted_rpm); + +} // End setup + + +//! ADC ISR for alternating between ADC pins 0 and 1 +/*! + * Reads ADC ports 0 and 1 alternately. Port 0 is RPM, Port 1 is for + * future fun (possible wheel selection) + */ +ISR(ADC_vect){ + if (analog_port == 0) + { + adc0 = ADCL | (ADCH << 8); + adc0_read_complete = true; + /* Flip to channel 1 */ + //ADMUX |= B00000001; + //analog_port = 1; + /* Trigger another conversion */ + //ADCSRA |= B01000000; + return; + } +// if (analog_port == 1) +// { +// adc1 = ADCL | (ADCH << 8); +// adc1_read_complete = true; +// /* Flip to channel 0 */ +// /* Tell it to read ADC0, clear MUX0..3 */ +// ADMUX &= B11110000; +// analog_port = 0; +// /* Trigger another conversion */ +// ADCSRA |= B01000000; +// return; +// } +} + + +/* This is the "low speed" 1000x/second sweeper interrupt routine + * who's sole purpose in life is to reset the output compare value + * for timer zero to change the output RPM. In cases where the RPM + * change per ISR is LESS than one LSB of the counter a set of modulus + * variabels are used to handle fractional values. + */ +ISR(TIMER2_COMPA_vect) { +// PORTD = (1 << 7); + if ( mode != LINEAR_SWEPT_RPM) + { +// PORTD = (0 << 7); + return; + } + if (sweep_lock) // semaphore to protect around changes/critical sections + { + // PORTD = (0 << 7); + return; + } + sweep_lock = true; + if (sweep_reset_prescaler) + { + sweep_reset_prescaler = false; + reset_prescaler = true; + prescaler_bits = SweepSteps[sweep_stage].prescaler_bits; + last_prescaler_bits = prescaler_bits; + } + /* Sweep code */ + if (sweep_direction == ASCENDING) + { + oc_remainder += SweepSteps[sweep_stage].remainder_per_isr; + /* IF the total is over the threshold we increment the TCNT factor + * for each multiple it is over by + */ + while (oc_remainder > FACTOR_THRESHOLD) + { + fraction++; + oc_remainder -= FACTOR_THRESHOLD; + } + if (new_OCR1A > SweepSteps[sweep_stage].ending_ocr) + { + new_OCR1A -= (SweepSteps[sweep_stage].tcnt_per_isr + fraction); + fraction = 0; + } + else /* END of the stage, find out where we are */ + { + sweep_stage++; + oc_remainder = 0; + if (sweep_stage < total_sweep_stages) + { + /* Toggle when changing stages */ + //PORTD &= ~(1<<7); /* turn DBG pin off */ + //PORTD |= (1<<7); /* Turn DBG pin on */ + new_OCR1A = SweepSteps[sweep_stage].beginning_ocr; + if (SweepSteps[sweep_stage].prescaler_bits != last_prescaler_bits) + sweep_reset_prescaler = true; + } + else /* END of line, time to reverse direction */ + { + sweep_stage--; /*Bring back within limits */ + sweep_direction = DESCENDING; + new_OCR1A = SweepSteps[sweep_stage].ending_ocr; + if (SweepSteps[sweep_stage].prescaler_bits != last_prescaler_bits) + sweep_reset_prescaler = true; + PORTD |= 1 << 7; /* Debugginga, ascending */ + } + /* Reset fractionals or next round */ + } + } + else /* Descending */ + { + oc_remainder += SweepSteps[sweep_stage].remainder_per_isr; + while (oc_remainder > FACTOR_THRESHOLD) + { + fraction++; + oc_remainder -= FACTOR_THRESHOLD; + } + if (new_OCR1A < SweepSteps[sweep_stage].beginning_ocr) + { + new_OCR1A += (SweepSteps[sweep_stage].tcnt_per_isr + fraction); + fraction = 0; + } + else /* End of stage */ + { + sweep_stage--; + oc_remainder = 0; + if (sweep_stage >= 0) + { + new_OCR1A = SweepSteps[sweep_stage].ending_ocr; + if (SweepSteps[sweep_stage].prescaler_bits != last_prescaler_bits) + sweep_reset_prescaler = true; + } + else /*End of the line */ + { + sweep_stage++; /*Bring back within limits */ + sweep_direction = ASCENDING; + new_OCR1A = SweepSteps[sweep_stage].beginning_ocr; + if (SweepSteps[sweep_stage].prescaler_bits != last_prescaler_bits) + sweep_reset_prescaler = true; + PORTD &= ~(1<<7); /*Descending turn pin off */ + } + } + } + sweep_lock = false; + //wanted_rpm = get_rpm_from_tcnt(&SweepSteps[sweep_stage].beginning_ocr, &SweepSteps[sweep_stage].prescaler_bits); +// PORTD = (0 << 7); +} + +/* Pumps the pattern out of flash to the port + * The rate at which this runs is dependent on what OCR1A is set to + * the sweeper in timer2 alters this on the fly to alow changing of RPM + * in a very nice way + */ +ISR(TIMER1_COMPA_vect) { + /* This is VERY simple, just walk the array and wrap when we hit the limit */ + PORTB = output_invert_mask ^ pgm_read_byte(&Wheels[selected_wheel].edge_states_ptr[edge_counter]); /* Write it to the port */ + /* Normal direction overflow handling */ + if (normal) + { + edge_counter++; + if (edge_counter == Wheels[selected_wheel].wheel_max_edges) { + edge_counter = 0; + } + } + else + { + if (edge_counter == 0) + edge_counter = Wheels[selected_wheel].wheel_max_edges; + edge_counter--; + } + /* The tables are in flash so we need pgm_read_byte() */ + + /* Reset Prescaler only if flag is set */ + if (reset_prescaler) + { + TCCR1B &= ~((1 << CS10) | (1 << CS11) | (1 << CS12)); /* Clear CS10, CS11 and CS12 */ + TCCR1B |= prescaler_bits; + reset_prescaler = false; + } + /* Reset next compare value for RPM changes */ + OCR1A = new_OCR1A; /* Apply new "RPM" from Timer2 ISR, i.e. speed up/down the virtual "wheel" */ +} + +void loop() +{ + uint16_t tmp_rpm = 0; + /* Just handle the Serial UI, everything else is in + * interrupt handlers or callbacks from SerialUI. + */ + + + if(Serial.available() > 0) { commandParser(); } + + if(mode == POT_RPM) + { + if (adc0_read_complete == true) + { + adc0_read_complete = false; + tmp_rpm = adc0 << TMP_RPM_SHIFT; + if (tmp_rpm > TMP_RPM_CAP) { tmp_rpm = TMP_RPM_CAP; } + wanted_rpm = tmp_rpm; + reset_new_OCR1A(tmp_rpm); + } + } + +} + + +void reset_new_OCR1A(uint32_t new_rpm) +{ + uint32_t tmp; + uint8_t bitshift; + uint8_t tmp_prescaler_bits; + tmp = (uint32_t)(8000000.0/(Wheels[selected_wheel].rpm_scaler * (float)(new_rpm < 10 ? 10:new_rpm))); +/* mySUI.print(F("new_OCR1a: ")); + mySUI.println(tmpl); + */ + get_prescaler_bits(&tmp,&tmp_prescaler_bits,&bitshift); + /* + mySUI.print(F("new_OCR1a: ")); + mySUI.println(tmp2); + */ + new_OCR1A = (uint16_t)(tmp >> bitshift); + prescaler_bits = tmp_prescaler_bits; + reset_prescaler = true; +} + + +uint8_t get_bitshift_from_prescaler(uint8_t *prescaler_bits) +{ + switch (*prescaler_bits) + { + case PRESCALE_1024: + return 10; + case PRESCALE_256: + return 8; + case PRESCALE_64: + return 6; + case PRESCALE_8: + return 3; + case PRESCALE_1: + return 0; + } + return 0; +} + + +//! Gets RPM from the TCNT value +/*! + * Gets the RPM value based on the passed TCNT and prescaler + * \param tcnt pointer to Output Compare register value + * \param prescaler_bits point to prescaler bits enum + */ +uint16_t get_rpm_from_tcnt(uint16_t *tcnt, uint8_t *prescaler_bits) +{ + bitshift = get_bitshift_from_prescaler(prescaler_bits); + return (uint16_t)((float)(8000000 >> bitshift)/(Wheels[selected_wheel].rpm_scaler*(*tcnt))); +} + + +//! Gets prescaler enum and bitshift based on OC value +void get_prescaler_bits(uint32_t *potential_oc_value, uint8_t *prescaler, uint8_t *bitshift) +{ + if (*potential_oc_value >= 16777216) + { + *prescaler = PRESCALE_1024; + *bitshift = 10; + } + else if (*potential_oc_value >= 4194304) + { + *prescaler = PRESCALE_256; + *bitshift = 8; + } + else if (*potential_oc_value >= 524288) + { + *prescaler = PRESCALE_64; + *bitshift = 6; + } + else if (*potential_oc_value >= 65536) + { + *prescaler = PRESCALE_8; + *bitshift = 3; + } + else + { + *prescaler = PRESCALE_1; + *bitshift = 0; + } +} + + +//! Builds the SweepSteps[] structure +/*! + * For sweeping we cannot just pick the TCNT value at the beginning and ending + * and sweep linearily between them as it'll result in a VERY slow RPM change + * at the low end and a VERY FAST change at the high end due to the inverse + * relationship between RPM and TCNT. So we compromise and break up the RPM + * range into octaves (doubles of RPM), and use a linear TCNT change between + * those two points. It's not perfect, but computationally easy + * + * \param low_rpm_tcnt pointer to low rpm OC value, (not prescaled!) + * \param high_rpm_tcnt pointer to low rpm OC value, (not prescaled!) + * \param total_stages pointer to tell the number of structs to allocate + * \returns pointer to array of structures for each sweep stage. + */ +sweep_step *build_sweep_steps(uint32_t *low_rpm_tcnt, uint32_t *high_rpm_tcnt, uint8_t *total_stages) +{ + sweep_step *steps; + uint8_t prescaler_bits; + uint8_t bitshift; + uint32_t tmp = *low_rpm_tcnt; + /* DEBUG + mySUI.print(*low_rpm_tcnt); + mySUI.print(F("<->")); + mySUI.println(*high_rpm_tcnt); + */ + + steps = (sweep_step *)malloc(sizeof(sweep_step)*(*total_stages)); + +#ifdef MORE_LINEAR_SWEEP + for (uint8_t i = 0; i < (*total_stages); i+=2) +#else + for (uint8_t i = 0; i < (*total_stages); i++) +#endif + { + /* The low rpm value will ALWAYS have the highed TCNT value so use that + to determine the prescaler value + */ + get_prescaler_bits(&tmp, &steps[i].prescaler_bits, &bitshift); + + steps[i].beginning_ocr = (uint16_t)(tmp >> bitshift); + if ((tmp >> 1) < (*high_rpm_tcnt)) + steps[i].ending_ocr = (uint16_t)((*high_rpm_tcnt) >> bitshift); + else + steps[i].ending_ocr = (uint16_t)(tmp >> (bitshift + 1)); // Half the begin value + tmp = tmp >> 1; /* Divide by 2 */ + /* DEBUG + mySUI.print(steps[i].beginning_ocr); + mySUI.print(F("<->")); + mySUI.println(steps[i].ending_ocr); + */ + } + return steps; +} diff --git a/ardustim/src/wheel_defs.h b/ardustim/src/wheel_defs.h index 3d50e6a..f66000c 100644 --- a/ardustim/src/wheel_defs.h +++ b/ardustim/src/wheel_defs.h @@ -1,1142 +1,1206 @@ -/* vim: set syntax=c expandtab sw=2 softtabstop=2 autoindent smartindent smarttab : */ -/* - * Arbritrary wheel pattern generator wheel definitions - * - * copyright 2014 David J. Andruczyk - * - * Ardu-Stim software is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * ArduStim software is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with any ArduStim software. If not, see http://www.gnu.org/licenses/ - * - */ - #ifndef __WHEEL_DEFS_H__ - #define __WHEEL_DEFS_H__ - - #include - - /* Wheel patterns! - * - * Wheel patterns define the pin states and specific times. The ISR runs - * at a constant speed related to the requested RPM. The request RPM is - * scaled based on the LENGTH of each wheel's array. The reference is - * the 60-2 which was the first decoder designed which has 120 "edges" - * (transitions" for each revolution of the wheel. Any other wheel that - * also has 120 edges has and RPM scaling factor of 1.0. IF a wheel has - * less edges needed to "describe" it, it's number of edges are divided by 120 to - * get the scaling factor which is applied to the RPM calculation. - * There is an enumeration (below) that lists the defined wheel types, - * as well as an array listing the rpm_scaling factors with regards to - * each pattern. - * - * NOTE: There is MORE THAN ONE WAY to define a wheel pattern. You can - * use more edges to get to 1 deg accuracy but the side effect is that - * your maximum RPM is capped because of that. Currently 60-2 can run - * up to about 60,000 RPM, 360and8 can only do about 10,000 RPM becasue - * it has 6x the number of edges... The less edges, the faster it can go... :) - * - * Using more edges allows you to do things like vary the dutycycle, - * i.e. a simple non-missing tooth 50% duty cycle wheel can be defined - * with only 2 entries if you really want, but I didn't do it that way - * for some of the simple ones as it made it seem somewhat confusing - * to look at as it required you to keep the rpm_scaler factor in mind. - * Most/all patterns show the pulses you're receive for one revolution - * of a REAL wheel on a real engine. - */ - - /* Wheel types we know about... - * This enumerations is the INDEX into the Wheels[] array of structures - * defined in main file. That struct contains pointers to the following: - * wheel name in a user friendly string - * pointer to the wheel edge array used by the ISR - * RPM scaling factor (num_edges/120 for crank wheels) - * Number of edges in the edge array above, needed by the ISR - */ - typedef enum { - DIZZY_FOUR_CYLINDER, /* 2 evenly spaced teeth */ - DIZZY_SIX_CYLINDER, /* 3 evenly spaced teeth */ - DIZZY_EIGHT_CYLINDER, /* 4 evenly spaced teeth */ - SIXTY_MINUS_TWO, /* 60-2 crank only */ - SIXTY_MINUS_TWO_WITH_CAM, /* 60-2 with 2nd trigger on cam */ - THIRTY_SIX_MINUS_ONE, /* 36-1 crank only */ - TWENTY_FOUR_MINUS_ONE, - FOUR_MINUS_ONE_WITH_CAM, /* 4-1 crank + cam */ - EIGHT_MINUS_ONE, /* 8-1 crank only */ - SIX_MINUS_ONE_WITH_CAM,/* 6-1 crank + cam */ - TWELVE_MINUS_ONE_WITH_CAM, /* 12-1 crank + cam */ - FOURTY_MINUS_ONE, /* Ford V-10 40-1 crank only */ - DIZZY_FOUR_TRIGGER_RETURN, /* dizzy 4 cylinder signal, 40deg on 50 deg off */ - ODDFIRE_VR, /* Oddfire V-twin */ - OPTISPARK_LT1, /* Optispark 360 and 8 */ - TWELVE_MINUS_THREE, /* 12-3 */ - THIRTY_SIX_MINUS_TWO_TWO_TWO, /* 36-2-2-2 crank only */ - THIRTY_SIX_MINUS_TWO_TWO_TWO_WITH_CAM, /* 36-2-2-2 crank and cam */ - FOURTY_TWO_HUNDRED_WHEEL, /* 4200 wheel */ - THIRTY_SIX_MINUS_ONE_WITH_CAM_FE3, /* Mazda F3 36-1 crank and cam */ - SIX_G_SEVENTY_TWO_WITH_CAM, /* Mitsubishi DOHC CAS and TCDS 6G72 */ - BUELL_ODDFIRE_CAM, /* Buell 45 deg cam wheel */ - GM_LS1_CRANK_AND_CAM, /* GM LS1 24 tooth with cam */ - LOTUS_THIRTY_SIX_MINUS_ONE_ONE_ONE_ONE, /* Lotus crank wheel 36-1-1-1-1 */ - HONDA_RC51_WITH_CAM, /* Honda oddfire 90 deg V-twin */ - THIRTY_SIX_MINUS_ONE_WITH_SECOND_TRIGGER, /* From jimstim */ - THIRTY_SIX_MINUS_ONE_PLUS_ONE_WITH_CAM_NGC4, /* From jimstim 36-1+1 wheel #5 4 cyl chrysler? */ - WEBER_IAW_WITH_CAM, /* From jimstim IAW weber-marelli */ - FIAT_ONE_POINT_EIGHT_SIXTEEN_VALVE_WITH_CAM, /* Fiat 1.8 16V from jimstim */ - THREE_SIXTY_NISSAN_CAS, /*from jimstim 360 tooth cas with 6 slots */ - TWENTY_FOUR_MINUS_TWO_WITH_SECOND_TRIGGER, /* Mazda CAS 24-1 inner ring single pulse outer ring */ - YAMAHA_EIGHT_TOOTH_WITH_CAM, /* 02-03 Yamaha R1, seank */ - GM_FOUR_TOOTH_WITH_CAM, /* GM 4 even crank with half moon cam */ - GM_SIX_TOOTH_WITH_CAM, /* GM 4 even crank with half moon cam */ - GM_EIGHT_TOOTH_WITH_CAM, /* GM 4 even crank with half moon cam */ - VOLVO_D12ACD_WITH_CAM, /* Volvo Diesel d12[acd] with cam (alex32 on forums.libreems.org */ - MAZDA_THIRTY_SIX_MINUS_TWO_TWO_TWO_WITH_SIX_TOOTH_CAM, - MITSUBISH_4g63_4_2, - AUDI_135_WITH_CAM, - HONDA_D17_NO_CAM, - MAZDA_323_AU, - DAIHATSU_3CYL, - MIATA_9905, - TWELVE_WITH_CAM, //12 evenly spaced crank teeth and a single cam tooth - TWENTY_FOUR_WITH_CAM, //24 evenly spaced crank teeth and a single cam tooth - SUBARU_SIX_SEVEN, /* Subaru 6 crank, 7 cam */ - GM_7X, /* GM 7X pattern. 6 even teeth with 1 extra uneven tooth */ - FOUR_TWENTY_A, /* DSM 420a */ - FORD_ST170, /* Ford ST170 */ - MITSUBISHI_3A92, /* Mitsubishi 3cylinder 3A92 */ - MAX_WHEELS, - }WheelType; - -/* Name strings for EACH wheel type, for serial UI */ - const char dizzy_four_cylinder_friendly_name[] PROGMEM = "4 cylinder dizzy"; - const char dizzy_six_cylinder_friendly_name[] PROGMEM = "6 cylinder dizzy"; - const char dizzy_eight_cylinder_friendly_name[] PROGMEM = "8 cylinder dizzy"; - const char sixty_minus_two_friendly_name[] PROGMEM = "60-2 crank only"; - const char sixty_minus_two_with_cam_friendly_name[] PROGMEM = "60-2 crank and cam"; - const char thirty_six_minus_one_friendly_name[] PROGMEM = "36-1 crank only"; - const char twenty_four_minus_one_friendly_name[] PROGMEM = "24-1 crank only"; - const char four_minus_one_with_cam_friendly_name[] PROGMEM = "4-1 crank wheel with cam"; - const char eight_minus_one_friendly_name[] PROGMEM = "8-1 crank only (R6)"; - const char six_minus_one_with_cam_friendly_name[] PROGMEM = "6-1 crank with cam"; - const char twelve_minus_one_with_cam_friendly_name[] PROGMEM = "12-1 crank with cam"; - const char fourty_minus_one_friendly_name[] PROGMEM = "40-1 crank only (Ford V10)"; - const char dizzy_four_trigger_return_friendly_name[] PROGMEM = "Distributor style 4 cyl 50deg off, 40 deg on"; - const char oddfire_vr_friendly_name[] PROGMEM = "odd fire 90 deg pattern 0 and 135 pulses"; - const char optispark_lt1_friendly_name[] PROGMEM = "GM OptiSpark LT1 360 and 8"; - const char twelve_minus_three_friendly_name[] PROGMEM = "12-3 oddball"; - const char thirty_six_minus_two_two_two_friendly_name[] PROGMEM = "36-2-2-2 Crank only"; - const char thirty_six_minus_two_two_two_with_cam_friendly_name[] PROGMEM = "36-2-2-2 Crank and cam"; - const char fourty_two_hundred_wheel_friendly_name[] PROGMEM = "GM 4200 crank wheel"; - const char thirty_six_minus_one_with_cam_fe3_friendly_name[] PROGMEM = "Mazda FE3 36-1 with cam"; - const char six_g_seventy_two_with_cam_friendly_name[] PROGMEM = "Mitsubishi 6g72 with cam"; - const char buell_oddfire_cam_friendly_name[] PROGMEM = "Buell Oddfire CAM wheel"; - const char gm_ls1_crank_and_cam_friendly_name[] PROGMEM = "GM LS1 crank and cam"; - const char lotus_thirty_six_minus_one_one_one_one_friendly_name[] PROGMEM = "Odd Lotus 36-1-1-1-1 flywheel"; - const char honda_rc51_with_cam_friendly_name[] PROGMEM = "Honda RC51 with cam"; - const char thirty_six_minus_one_with_second_trigger_friendly_name[] PROGMEM = "36-1 crank with 2nd trigger on teeth 33-34"; - const char thirty_six_minus_one_plus_one_with_cam_ngc4_friendly_name[] PROGMEM = "36-1+1 crank with cam pattern NGC4"; - const char weber_iaw_with_cam_friendly_name[] PROGMEM = "Weber-Marelli 8 crank+2 cam pattern"; - const char fiat_one_point_eight_sixteen_valve_with_cam_friendly_name[] PROGMEM = "Fiat 1.8 16V crank and cam"; - const char three_sixty_nissan_cas_friendly_name[] PROGMEM = "Nissan 360 CAS with 6 slots"; - const char twenty_four_minus_two_with_second_trigger_friendly_name[] PROGMEM = "Mazda CAS 24-2 with single pulse outer ring"; - const char yamaha_eight_tooth_with_cam_friendly_name[] PROGMEM = "Yamaha 2002-03 R1 8 even-tooth crank with 1 tooth cam"; - const char gm_four_tooth_with_cam_friendly_name[] PROGMEM = "GM 4 even-tooth crank with 1 tooth cam"; - const char gm_six_tooth_with_cam_friendly_name[] PROGMEM = "GM 6 even-tooth crank with 1 tooth cam"; - const char gm_eight_tooth_with_cam_friendly_name[] PROGMEM = "GM 8 even-tooth crank with 1 tooth cam"; - const char volvo_d12acd_with_cam_friendly_name[] PROGMEM = "Volvo d12[acd] crank with 7 tooth cam"; - const char mazda_thirty_six_minus_two_two_two_with_six_tooth_cam_friendly_name[] PROGMEM = "Mazda 36-2-2-2 with 6 tooht cam"; - const char mitsubishi_4g63_4_2_friendly_name[] PROGMEM = "Mitsubishi 4g63 aka 4/2 crank and cam"; - const char audi_135_with_cam_friendly_name[] PROGMEM = "Audi 135 tooth crank and cam"; - const char honda_d17_no_cam_friendly_name[] PROGMEM = "Honda D17 Crank (12+1)"; - const char mazda_323_au_friendly_name[] PROGMEM = "Mazda 323 AU version"; - const char daihatsu_3cyl_friendly_name[] PROGMEM = "Daihatsu 3+1 distributor (3 cylinders)"; - const char miata_9905_friendly_name[] PROGMEM = "Miata 99-05"; - const char twelve_with_cam_friendly_name[] PROGMEM = "12/1 (12 crank with cam)"; - const char twenty_four_with_cam_friendly_name[] PROGMEM = "24/1 (24 crank with cam)"; - const char subaru_six_seven_name_friendly_name[] PROGMEM = "Subaru 6/7 crank and cam"; - const char gm_seven_x_friendly_name[] PROGMEM = "GM 7X"; - const char four_twenty_a_friendly_name[] PROGMEM = "DSM 420a"; - const char ford_st170_friendly_name[] PROGMEM = "Ford ST170"; - const char mitsubishi_3A92_friendly_name[] PROGMEM = "Mitsubishi 3A92"; - - - /* Very simple 50% duty cycle */ - const unsigned char dizzy_four_cylinder[] PROGMEM = - { /* dizzy 4 cylinder */ - 1,0,1,0 /* two pulses per crank revolution (one per cylinder) */ - }; - - /* Very simple 50% duty cycle */ - const unsigned char dizzy_six_cylinder[] PROGMEM = - { /* dizzy 6 cylinder */ - 1,0,1,0,1,0 /* three pulses per crank revolution (one per cylinder) */ - }; - - /* Very simple 50% duty cycle */ - const unsigned char dizzy_eight_cylinder[] PROGMEM = - { /* dizzy 8 cyl */ - 1,0,1,0,1,0,1,0 /* four pulses per crank revolution (one per cylinder) */ - }; - - /* Standard bosch 60-2 pattern, 50% duty cyctle during normal teeth */ - const unsigned char sixty_minus_two[] PROGMEM = - { /* 60-2 */ - 1,0,1,0,1,0,1,0,1,0, /* teeth 1-5 */ - 1,0,1,0,1,0,1,0,1,0, /* teeth 6-10 */ - 1,0,1,0,1,0,1,0,1,0, /* teeth 11-15 */ - 1,0,1,0,1,0,1,0,1,0, /* teeth 16-20 */ - 1,0,1,0,1,0,1,0,1,0, /* teeth 21-25 */ - 1,0,1,0,1,0,1,0,1,0, /* teeth 26-30 */ - 1,0,1,0,1,0,1,0,1,0, /* teeth 31-35 */ - 1,0,1,0,1,0,1,0,1,0, /* teeth 36-40 */ - 1,0,1,0,1,0,1,0,1,0, /* teeth 41-45 */ - 1,0,1,0,1,0,1,0,1,0, /* teeth 46-50 */ - 1,0,1,0,1,0,1,0,1,0, /* teeth 51-55 */ - 1,0,1,0,1,0,0,0,0,0 /* teeth 56-58 and 59-60 MISSING */ - }; - - /* Bosch 60-2 pattern with 2nd trigger on rotation 2, - * 50% duty cyctle during normal teeth */ - const unsigned char sixty_minus_two_with_cam[] PROGMEM = - { /* 60-2 */ - 1,0,1,0,1,0,1,0,1,0, /* teeth 1-5 */ - 1,0,1,0,1,0,1,0,1,0, /* teeth 6-10 */ - 1,0,1,0,1,0,1,0,1,0, /* teeth 11-15 */ - 1,0,1,0,1,0,1,0,1,0, /* teeth 16-20 */ - 1,0,1,0,1,0,1,0,1,0, /* teeth 21-25 */ - 1,0,1,0,1,0,1,0,1,0, /* teeth 26-30 */ - 1,0,1,0,1,0,1,0,1,0, /* teeth 31-35 */ - 1,0,1,0,1,0,1,0,1,0, /* teeth 36-40 */ - 1,0,1,0,1,0,1,0,1,0, /* teeth 41-45 */ - 1,0,1,0,1,0,1,0,1,0, /* teeth 46-50 */ - 1,0,1,0,1,0,1,0,1,0, /* teeth 51-55 */ - 1,0,1,0,1,0,0,0,0,0, /* teeth 56-58 and 59-60 MISSING */ - 1,0,1,0,1,0,1,0,1,0, /* Second revolution teeth 1-5 */ - 1,0,1,0,1,0,1,0,1,0, /* teeth 6-10 */ - 1,0,1,0,1,0,1,0,1,0, /* teeth 11-15 */ - 1,0,1,0,1,0,1,0,1,0, /* teeth 16-20 */ - 1,0,1,0,1,0,1,0,1,0, /* teeth 21-25 */ - 1,0,1,0,1,0,1,0,1,0, /* teeth 26-30 */ - 1,0,1,0,1,0,1,0,1,0, /* teeth 31-35 */ - 1,2,1,0,1,0,1,0,1,0, /* teeth 36-40, Cam trigger on latter half of 36th */ - 1,0,1,0,1,0,1,0,1,0, /* teeth 41-45 */ - 1,0,1,0,1,0,1,0,1,0, /* teeth 46-50 */ - 1,0,1,0,1,0,1,0,1,0, /* teeth 51-55 */ - 1,0,1,0,1,0,0,0,0,0 /* teeth 56-58 and 59-60 MISSING */ - }; - - /* Standard ford/mazda and aftermarket 36-1 pattern, 50% duty cyctle during normal teeth */ - const unsigned char thirty_six_minus_one[] PROGMEM = - { /* 36-1 */ - 1,0,1,0,1,0,1,0,1,0, /* teeth 1-5 */ - 1,0,1,0,1,0,1,0,1,0, /* teeth 6-10 */ - 1,0,1,0,1,0,1,0,1,0, /* teeth 11-15 */ - 1,0,1,0,1,0,1,0,1,0, /* teeth 16-20 */ - 1,0,1,0,1,0,1,0,1,0, /* teeth 21-25 */ - 1,0,1,0,1,0,1,0,1,0, /* teeth 26-30 */ - 1,0,1,0,1,0,1,0,1,0, /* teeth 31-35 */ - 0,0 /* MISSING 36th tooth */ - }; - - /* Standard ford/mazda and aftermarket 36-1 pattern, 50% duty cyctle during normal teeth */ - const unsigned char twenty_four_minus_one[] PROGMEM = - { /* 36-1 */ - 1,0,1,0,1,0, /* teeth 1-3 */ - 1,0,1,0,1,0, /* teeth 4-6 */ - 1,0,1,0,1,0, /* teeth 7-9 */ - 1,0,1,0,1,0, /* teeth 10-12 */ - 1,0,1,0,1,0, /* teeth 13-15 */ - 1,0,1,0,1,0, /* teeth 16-18 */ - 1,0,1,0,1,0, /* teeth 19-21 */ - 1,0,1,0,0,0, /* teeth 22-21 */ - }; - - /* 4-1 crank signal 50% duty cycle with Cam tooth enabled during the second rotation prior to tooth 2 */ - const unsigned char four_minus_one_with_cam[] PROGMEM = - { /* 4-1 with cam */ - 0,1,0,1,0,1,0,0, /* Teeth 1-3, then MISSING */ - 0,1,2,1,0,1,0,0 /* Tooth 5, 2nd trigger on cam between 5 and 6 - then 6 and 7 and MISSING 8th */ - }; - - /* Yamaha R6 crank trigger 8 teeth missing one, (22.5deg low, 22.5deg high) 50% duty cycle during normal teeth */ - const unsigned char eight_minus_one[] PROGMEM = - { /* 8-1 */ - 0,1,0,1,0,1,0,1, /* Teeth 1-4 */ - 0,1,0,1,0,1,0,0 /* Teeth 5-7, then MISSING */ - }; - - /* 40deg low, 20 deg high per tooth, cam signal on second rotation during 40deg low portion of 3rd tooth */ - const unsigned char six_minus_one_with_cam[] PROGMEM = - { /* 6-1 with cam */ - 0,0,1,0,0,1,0,0,1, /* Teeth 1-3 */ - 0,0,1,0,0,1,0,0,0, /* Teeth 4 and 5 and MISSING 6th */ - 0,0,1,0,0,1,2,2,1, /* 2nd rev teeth 7 and 8, then 2nd trigger on cam between 8 and 9 */ - 0,0,1,0,0,1,0,0,0 /* teeth 10 and 11 then missing 12th */ - }; - - /* 25 deg low, 5 deg high, #12 is missing, cam is high for 25 deg on second crank rotation just after tooth 21 (9) */ - const unsigned char twelve_minus_one_with_cam[] PROGMEM = - { /* 12-1 with cam */ - 0,0,0,0,0,1,0,0,0,0,0,1, /* Teeth 1 and 2 */ - 0,0,0,0,0,1,0,0,0,0,0,1, /* Teeth 3 and 4 */ - 0,0,0,0,0,1,0,0,0,0,0,1, /* Teeth 5 and 6 */ - 0,0,0,0,0,1,0,0,0,0,0,1, /* Teeth 7 and 8 */ - 0,0,0,0,0,1,0,0,0,0,0,1, /* Teeth 9 and 10 */ - 0,0,0,0,0,1,0,0,0,0,0,0, /* Tooth 11 and MISSING twelth */ - //0,0,0,0,0,1,0,0,0,0,0,1, /* Tooth 11 and WITHOUT MISSING twelth */ - 0,0,0,0,0,1,0,0,0,0,0,1, /* 2nd rotation: Teeth 13 and 14 */ - 0,0,0,0,0,1,0,0,0,0,0,1, /* Teeth 15 and 16 */ - 0,0,0,0,0,1,0,0,0,0,0,1, /* Teeth 17 and 18 */ - 0,0,0,0,0,1,0,0,0,0,0,1, /* Teeth 19 and 20 */ - 0,0,0,0,0,1,2,2,2,2,2,1, /* Tooth 21 and 22, 2nd trigger on cam between teeth 21 and 22 for 25 deg */ - 0,0,0,0,0,1,0,0,0,0,0,0 /* Totth 23 and MISSING 24th */ - //0,0,0,0,0,1,0,0,0,0,0,1 /* Totth 23 and WITHOUT MISSING 24th */ - }; - - /* Ford V10 version of EDIS with 40 teeth instead of 36, 50% duty cycle during normal teeth.. */ - const unsigned char fourty_minus_one[] PROGMEM = - { /* 40-1 */ - 0,1,0,1,0,1,0,1,0,1, /* Teeth 1-5 */ - 0,1,0,1,0,1,0,1,0,1, /* Teeth 6-10 */ - 0,1,0,1,0,1,0,1,0,1, /* Teeth 11-15 */ - 0,1,0,1,0,1,0,1,0,1, /* Teeth 16-20 */ - 0,1,0,1,0,1,0,1,0,1, /* Teeth 21-25 */ - 0,1,0,1,0,1,0,1,0,1, /* Teeth 26-30 */ - 0,1,0,1,0,1,0,1,0,1, /* Teeth 31-35 */ - 0,1,0,1,0,1,0,1,0,0 /* Teeth 36-39 and MISSING 40th tooth */ - }; - - /* 50deg off, 40 deg on dissy style signal */ - const unsigned char dizzy_four_trigger_return[] PROGMEM = - { /* dizzy trigger return */ - 0,0,0,0,0,1,1,1,1l /* Simple off/on signal, 50deg off, 40 deg on */ - }; - - /* Oddfire V twin 135/225 split */ - const unsigned char oddfire_vr[] PROGMEM = - { /* Oddfire VR */ - 1,0,0,0,0,0,0,0,0,1,0,0, /* Tooth 1 and 2 at 0 deg and 135 deg, then 225 off */ - 0,0,0,0,0,0,0,0,0,0,0,0 - }; - - /* GM LT1 360 and 8 wheel, see http://powerefi.com/files/opti-LT1-count.JPG */ - const unsigned char optispark_lt1[] PROGMEM = - { /* Optispark 360 outside teeth, 8 varying inside teeth */ - /* 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 */ - 0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1, - 0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1, - 0,1,0,1,0,1,0,1,0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,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1, - 0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,2,3,2,3, /* 241-270 */ - 0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1, - 0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1, - 0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1, /* 271-300 */ - 0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1, - 0,1,0,1,0,1,2,3,2,3,2,3,2,3,2,3,2,3,2,3, - 2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3, /* 301-330 */ - 2,3,2,3,2,3,2,3,2,3,0,1,0,1,0,1,0,1,0,1, - 0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1, - 0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,2,3,2,3 /* 331-360 */ - }; - - const unsigned char twelve_minus_three[] PROGMEM = - { /* 12-3, http://www.msextra.com/doc/triggers/12_3_wheel_133.jpg */ - 1,0,0,0,1,0,0,0, /* Teeth 1-2 */ - 1,0,0,0,1,0,0,0, /* Teeth 3-4 */ - 1,0,0,0,1,0,0,0, /* Teeth 5-6 */ - 1,0,0,0,1,0,0,0, /* Teeth 7-8 */ - 1,0,0,0,0,0,0,0, /* Tooth 9 and MISSING 10th */ - 0,0,0,0,0,0,0,0 /* MISSING Teeth 11-12 */ - }; - - const unsigned char thirty_six_minus_two_two_two[] PROGMEM = - { - 1,0,1,0,1,0,1,0,1,0, - 1,0,1,0,1,0,1,0,1,0, - 1,0,1,0,1,0,0,0,0,0, - 1,0,0,0,0,0,1,0,1,0, - 1,0,1,0,1,0,1,0,1,0, - 1,0,1,0,1,0,1,0,1,0, - 1,0,0,0,0,0,1,0,1,0, - 1,0 - }; - - const unsigned char thirty_six_minus_two_two_two_with_cam[] PROGMEM = - { /* 36-2-2-2 with cam */ - 1,0,0,2,0,0,1,0,0,0, /* Tooth one, missing teeth 2,3 and 5, 2nd trigger during teeth 2 and 3 */ - 0,0,1,0,1,0,1,0,1,0, /* Missing tooth 6, then 7-10 */ - 1,0,1,0,1,0,1,0,1,0, /* Teeth 11-15 */ - 1,0,1,0,1,0,1,0,1,0, /* Teeth 16-20 */ - 1,0,1,0,0,2,0,0,1,0, /* Teeth 21-2sing 23-24, then 25, 2nd trigger during teeth 23 and 24 */ - 1,0,1,0,1,0,1,0,1,0, /* Teeth 26-30 */ - 1,0,1,0,1,0,1,0,1,0, /* Teeth 31-35 */ - 1,0, /* 36th Tooth */ - 1,0,0,0,0,0,1,0,0,0, /* Tooth one, missing teeth 2,3 and 5 */ - 0,0,1,0,1,2,1,0,1,0, /* Missing tooth 6, then 7-10 */ - 1,0,1,0,1,0,1,0,1,0, /* Teeth 11-15 */ - 1,0,1,0,1,0,1,0,1,0, /* Teeth 16-20 */ - 1,0,1,0,0,0,0,0,1,0, /* Teeth 21-22 missing 23-24, then 25 */ - 1,0,1,0,1,0,1,0,1,0, /* Teeth 26-30 */ - 1,0,1,0,1,0,1,0,1,0, /* Teeth 31-35 */ - 1,0 /* 36th Tooth */ - }; - - - const unsigned char fourty_two_hundred_wheel[] PROGMEM = - { /* 4200 wheel http://msextra.com/doc/triggers/4200_timing.pdf */ - /* 55 deg high, 5 deg low, 55 deg high, 5 deg low, - * 5 deg high, 5 deg low, 45 deg high, 5 deg low, - * 55 deg high, 5 deg low, 65 deg high, 5 deg low, - * 45 deg high, 5 deg low, (360 degreees ) */ - 1,1,1,1,1,1,1,1,1,1, - 1,0,1,1,1,1,1,1,1,1, - 1,1,1,0,1,0,1,1,1,1, - 1,1,1,1,1,0,1,1,1,1, - 1,1,1,1,1,1,1,0,1,1, - 1,1,1,1,1,1,1,1,1,1, - 1,0,1,1,1,1,1,1,1,1, - 1,0 - }; - - /* Mazda F3 36-1 with cam */ - const unsigned char thirty_six_minus_one_with_cam_fe3[] PROGMEM = - { /* 36-1 with cam, 3 cam teeth, 2 180deg from each other */ - 1,0,1,0,1,0,1,0,1,0,1,0, /* 0-55 deg */ - 1,0,1,0,1,0,3,2,3,0,1,0, /* 60-115 deg cam tooth at 90 deg crank for 15 crank degrees */ - 1,0,1,0,1,0,1,0,1,0,1,0, /* 120-175 deg */ - 1,0,1,0,1,0,1,0,1,0,1,0, /* 180-235 deg */ - 1,0,1,0,1,0,1,0,1,0,1,0, /* 240-295 deg */ - 1,0,1,0,1,0,1,0,1,0,0,0, /* 300-355 deg Crank missing tooth at end */ - 1,0,1,0,1,0,1,0,1,0,1,0, /* 360-415 deg */ - 3,2,3,0,1,0,3,2,3,0,1,0, /* 420-475 deg 2 more cam teeth at 420 and 450 deg, 15 crank degrees each */ - 1,0,1,0,1,0,1,0,1,0,1,0, /* 480-535 deg */ - 1,0,1,0,1,0,1,0,1,0,1,0, /* 540-595 deg */ - 1,0,1,0,1,0,1,0,1,0,1,0, /* 600-655 deg */ - 1,0,1,0,1,0,1,0,1,0,0,0 /* 660-715 deg Crank missing tooth at end */ - }; - - /* Mitsubishi 6g72 crank/cam */ - const unsigned char six_g_seventy_two_with_cam[] PROGMEM = - { /* Mitsubishi 6g72 */ - /* Crank signal's are 50 deg wide, and one per cylinder - * Cam signals have 3 40 deg wide teeh and one 85 deg wide tooth - * Counting both From TDC#1 - * Crank: 40 deg high, 70 deg low (repeats whole cycle) - * Cam: 70 deg high, 80 deg low, 40 deg high, 150 deg low, - * 40 deg high, 130 deg low, 40 deg high, 155 deg low - */ - 3,3,3,3,3,3,3,3,3,2, - 2,2,2,2,0,0,0,0,0,0, - 0,0,0,1,1,1,1,1,1,1, - 3,3,3,2,2,2,2,2,0,0, - 0,0,0,0,0,0,0,1,1,1, - 1,1,1,1,1,1,1,0,0,0, - 0,0,0,0,0,0,0,0,2,2, - 2,3,3,3,3,3,1,1,1,1, - 1,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,1,1,1,1,1, - 1,1,3,3,3,2,2,2,2,2, - 0,0,0,0,0,0,0,0,0,1, - 1,1,1,1,1,1,1,1,1,0, - 0,0,0,0,0,0,0,0,0,0, - 0,2,2,3 - }; - - const unsigned char buell_oddfire_cam[] PROGMEM = - { /* Buell oddfire cam wheel */ - /* Wheel is a cam wheel (degress are in crank degrees - * 36 deg high, 54 deg low, - * 36 deg high, 54 deg low, - * (Rear at TDC) 36 deg high, - * 1889 deg low, 36 deg high - * 54 deg low, 36 deg high, - * 54 deg low, (Front at TDC), - * 36 deg high, 99 deg low - */ - 1,1,1,1,0,0,0,0,0,0, /* Tooth 1 (36 deg) and 54 deg space */ - 1,1,1,1,0,0,0,0,0,0, /* Tooth 2 (36 deg) and 54 deg space */ - 1,1,1,1,0,0,0,0,0,0, /* Tooth 3 (36 deg) and begin of 189 deg space */ - 0,0,0,0,0,0,0,0,0,0, /* Part of 189 deg space */ - 0,0,0,0,0,1,1,1,1,0, /* Tail of 189 deg space, 36 deg tooth, begin of 54 deg space */ - 0,0,0,0,0,1,1,1,1,0, /* Tail of 54 deg space, 36 deg tooth, begin of 54 deg space */ - 0,0,0,0,0,1,1,1,1,0, /* Tail of 54 deg space, last 36 deg tooth, begin of 99 deg space */ - 0,0,0,0,0,0,0,0,0,0 /* Tail of 99 deg space */ - }; - - const unsigned char gm_ls1_crank_and_cam[] PROGMEM = - { /* GM LS1 24 tooth crank snd 1 tooth cam */ - /* 12 deg low, 3 deg high, 3 deg low, - * 12 deg high, 3deg low, 12 deg high, - * 3 deg low, 12 deg high, 3 deg low, - * 12 deg high, 3 deg low, 12 deg high, - * 12 deg low, 3 deg high, 3 deg low, - * 12 deg high, 3 deg low, 12 deg high, - * 3 deg low, 12 deg high, 12 deg low, - * 3 deg high, 12 deg low, 3 deg high, - * 3 deg low, 12 deg high, 3 deg low, - * 12 deg high, 12 deg low, 3 deg high, - * 12 deg low, 3 deg high, 12 deg low, - * 3 deg high, 12 deg low, 3 deg high, - * 3 deg low, 12 deg high, 12 deg low, - * 3 deg high, 3 deg low, 12 deg high, - * 12 deg low, 3 deg high, 12 deg low, - * 3 deg high, 12 deg low, 3 deg high - * Second rotation is the SAME pattern - * with cam signal held high for 360 - * crank degrees */ - 4,0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,0,0,1,1, - 1,1,1,1,1,1,1,1,1,1,0,0,0,1,1,1,1,1,1,1, - 1,1,1,1,1,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1, - 0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,1,1, - 1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0, - 0,0,1,1,1,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1, - 0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,1,1, - 1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0, - 0,0,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1, - 0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,1,1, - 1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0, - 0,0,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1, - 0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,0,0,1,1, - 1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0, - 0,0,1,1,1,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1, - 0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0, - 0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,0,0, - 0,0,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1, - 2,2,2,2,2,2,2,2,2,2,2,2,3,3,3,2,2,2,3,3, /* Second rotation with */ - 3,3,3,3,3,3,3,3,3,3,2,2,2,3,3,3,3,3,3,3, /* Cam tooth enabled */ - 3,3,3,3,3,2,2,2,3,3,3,3,3,3,3,3,3,3,3,3, - 2,2,2,3,3,3,3,3,3,3,3,3,3,3,3,2,2,2,3,3, - 3,3,3,3,3,3,3,3,3,3,2,2,2,2,2,2,2,2,2,2, - 2,2,3,3,3,2,2,2,3,3,3,3,3,3,3,3,3,3,3,3, - 2,2,2,3,3,3,3,3,3,3,3,3,3,3,3,2,2,2,3,3, - 3,3,3,3,3,3,3,3,3,3,2,2,2,2,2,2,2,2,2,2, - 2,2,3,3,3,2,2,2,2,2,2,2,2,2,2,2,2,3,3,3, - 2,2,2,3,3,3,3,3,3,3,3,3,3,3,3,2,2,2,3,3, - 3,3,3,3,3,3,3,3,3,3,2,2,2,2,2,2,2,2,2,2, - 2,2,3,3,3,2,2,2,2,2,2,2,2,2,2,2,2,3,3,3, - 2,2,2,2,2,2,2,2,2,2,2,2,3,3,3,2,2,2,3,3, - 3,3,3,3,3,3,3,3,3,3,2,2,2,2,2,2,2,2,2,2, - 2,2,3,3,3,2,2,2,3,3,3,3,3,3,3,3,3,3,3,3, - 2,2,2,2,2,2,2,2,2,2,2,2,3,3,3,2,2,2,2,2, - 2,2,2,2,2,2,2,3,3,3,2,2,2,2,2,2,2,2,2,2, - 2,2,3,3,3,2,2,2,2,2,2,2,2,2,2,2,2,3,3,3, - }; - - /* Lotus 36-1-1-1-1 wheel, missing teeth at - * 36,32,17 and 14 - */ - const unsigned char lotus_thirty_six_minus_one_one_one_one[] PROGMEM = - { /* 36-1 */ - 1,0,1,0,1,0,1,0,1,0, /* teeth 1-5 */ - 1,0,1,0,1,0,1,0,1,0, /* teeth 6-10 */ - 1,0,1,0,1,0,0,0,1,0, /* teeth 11-15 */ - 1,0,0,0,1,0,1,0,1,0, /* teeth 16-20 */ - 1,0,1,0,1,0,1,0,1,0, /* teeth 21-25 */ - 1,0,1,0,1,0,1,0,1,0, /* teeth 26-30 */ - 1,0,0,0,1,0,1,0,1,0, /* teeth 31-35 */ - 0,0 /* MISSING 36th tooth */ - }; - const unsigned char honda_rc51_with_cam[] PROGMEM = - { /* Honda RC51 oddfire 90deg Vtwin with cam */ - 0,1,0,1,0,1,0,1,0,1, /* teeth 1-5 */ - 0,3,0,1,0,1,0,1,0,1, /* teeth 6-10, cam triggers on tooth 6 */ - 0,1,0,1, /* Teeth 11-12 */ - 0,1,0,1,0,1,0,3,0,1, /* 2nd rotation, teeth 1-5 (13-17), cam trigger on tooth 4(16)*/ - 0,3,0,1,0,1,0,1,0,1, /* teeth 6-10 (18-22), cam trigger on tooth 18 */ - 0,1,0,1 /* teeth 11-12, (23-24) */ - }; - - /* 36-1 with second trigger pulse across teeth 33-34 on first rotation */ - const unsigned char thirty_six_minus_one_with_second_trigger[] PROGMEM = - { /* 36-1 */ - 1,0,1,0,1,0,1,0,1,0, /* Teeth 1-5 */ - 1,0,1,0,1,0,1,0,1,0, /* Teeth 6-10 */ - 1,0,1,0,1,0,1,0,1,0, /* Teeth 11-15 */ - 1,0,1,0,1,0,1,0,1,0, /* Teeth 16-20 */ - 1,0,1,0,1,0,1,0,1,0, /* Teeth 21-25 */ - 1,0,1,0,1,0,1,0,1,0, /* Teeth 26-30 */ - 1,0,1,0,3,2,3,2,1,0, /* Teeth 31-35, second trigger during 33-34 */ - 0,0, /* 36th tooth MISSING */ - 1,0,1,0,1,0,1,0,1,0, /* Revolution 2 Teeth 1-5 */ - 1,0,1,0,1,0,1,0,1,0, /* Teeth 6-10 */ - 1,0,1,0,1,0,1,0,1,0, /* Teeth 11-15 */ - 1,0,1,0,1,0,1,0,1,0, /* Teeth 16-20 */ - 1,0,1,0,1,0,1,0,1,0, /* Teeth 21-25 */ - 1,0,1,0,1,0,1,0,1,0, /* Teeth 26-30 */ - 1,0,1,0,1,0,1,0,0,0, /* Teeth 31-35 */ - 0,0 /* 36th MISSING tooth */ - }; - - const unsigned char thirty_six_minus_one_plus_one_with_cam_ngc4[] PROGMEM = - { /* 36-1+1 NGC-4 needs 1 deg resolution, chrysler 2.0/2.4 engines - * cam edges are at 26,62,98,134,170,314,350,368,422,458,494,530,674 and 710 dev - * crank is 36-1 with alarge window at one end 2.5 teeth cycles (25 deg) wide and alosed - * at 180deg apart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,1,0,2,2,2,2,3,3,3,3,3,2,2,2,2,2,3,3,3,3,3, /* 401-440 */ - 2,2,2,2,2,3,3,3,3,3,2,2,2,2,2,3,3,1,1,1,0,0,0,0,0,1,1,1,1,1,0,0,0,0,0,1,1,1,1,1, /* 441-480 */ - 0,0,0,0,0,1,1,1,1,1,0,0,0,2,2,3,3,3,3,3,2,2,2,2,2,3,3,3,3,3,2,2,2,2,2,3,3,3,3,3, /* 481-520 */ - 2,2,2,2,2,3,3,3,3,1,0,0,0,0,0,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 521-560 */ - 0,0,0,0,0,1,1,1,1,1,0,0,0,0,0,1,1,1,1,1,0,0,0,0,0,1,1,1,1,1,0,0,0,0,0,1,1,1,1,1, /* 561-600 */ - 0,0,0,0,0,1,1,1,1,1,0,0,0,0,0,1,1,1,1,1,0,0,0,0,0,1,1,1,1,1,0,0,0,0,0,1,1,1,1,1, /* 601-640 */ - 0,0,0,0,0,1,1,1,1,1,0,0,0,0,0,1,1,1,1,1,0,0,0,0,0,1,1,1,1,1,0,0,0,2,2,3,3,3,3,3, /* 641-680 */ - 2,2,2,2,2,3,3,3,3,3,2,2,2,2,2,3,3,3,3,3,2,2,2,2,2,3,3,3,3,1,0,0,0,0,0,1,1,1,1,1 /* 681-720 */ - }; - - - const unsigned char weber_iaw_with_cam[] PROGMEM = - { /*Weber marelli (Cosworth/Lancia) from jimstim - 80 deg low, 10 deg high, Tooth 1 - 20 deg low, 45 deg cam pulse, 15 deg low, 10 deg high, Cam tooth 1 and crank tooth 2 - 80 deg low, 10 deg high, Crank tooth 3 - 20 deg low, 45 deg cam pulse, 15 deg low, 10 deg high, Cam tooth2 and crank tooth 4 - 80 deg low, 10 deg high, Crank tooth 5 - 80 deg low, 10 deg high Crank tooth 6 - 80 deg low, 10 deg high, Crank tooth 7 - 80 deg low, 10 deg high Crank tooth 8 */ - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,2,2,2,2,0,0,0,0,0,0,0,0,1,1, /* Teeth 1 and 2 & cam1 */ - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,2,2,2,2,0,0,0,0,0,0,0,0,1,1, /* Teeth 3 and 4 & cam2 */ - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1, /* Teeth 5 and 6 */ - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1 /* Teeth 7 and 8 */ - }; - - const unsigned char fiat_one_point_eight_sixteen_valve_with_cam[] PROGMEM = - { - /* Starting from TDC #1 - * Cam is high for 40 deg, low for 20, high 170deg, low for 170, high for 20, - * low for 170, then high for 130 - * Crank is low for 97, high for 5, low for 27, high for 5, low for 50, high for 5, - * low for 102, high for 5, low for 27, high for 5, low for 50, high for 5, - * low for 102, high for 5, low for 27, high for 5, low for 50, high for 5, - * low for 102, high for 5, low for 27, high for 5, low for 50, high for 5, low for 5 - * http://msextra.com/doc/triggers/fiat1.8-16v.jpg - */ - /* Crankshaft degrees - 1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 33 35 37 39 */ - 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2, - 2,2,2,3,3,3,3,3,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,3,3,3,3,3, - 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2, - 2,2,2,2,2,2,2,2,2,2,3,3,3,3,3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,2,2,2,2,2, - 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,3,3,3,3,3,2,2,2,2,2 - }; - - const unsigned char three_sixty_nissan_cas[] PROGMEM = - /* This version has the 360 teeth on the cam - { - 1,2,0,2,0,2,0,2,0,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3, // 1-40 deg - 1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3, // 41-80 deg - 1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3, // 81-120 deg - 1,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3, // 121-160 deg - 1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3, // 161-200 deg - 1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3, // 201-240 deg - 1,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3, // 241-280 deg - 1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3, // 281-320 deg - 1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3, // 321-360 deg - 1,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,3,1,3,1,3,1,3, // 361-400 deg - 1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3, // 401-340 deg - 1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3, // 441-480 deg - 1,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2, // 481-520 deg - 0,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3, // 521-560 deg - 1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3, // 561-600 deg - 1,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2, // 601-640 deg - 0,2,0,2,0,2,0,2,0,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3, // 641-680 deg - 1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3, // 681-720 deg - };*/ - { - /* Home teeth every 120 degrees in increasing widths (8,16,24,32,40,48) */ - /* Crankshaft degrees - 1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 33 35 37 39 */ - 2,1,0,1,0,1,0,1,0,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3, /* 1-40 deg */ - 2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3, /* 41-80 deg */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- 0,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3, /* 521-560 deg */ - 2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3, /* 561-600 deg */ - 2,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1, /* 601-640 deg */ - 0,1,0,1,0,1,0,1,0,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3, /* 641-680 deg */ - 2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3, /* 681-720 deg */ - }; - - const unsigned char twenty_four_minus_two_with_second_trigger[] PROGMEM = - { - /* See http://postimg.org/image/pcwkrxktx/, 24-2 inner ring, single outer pulse */ - 1,0,0,1,0,0,1,0,0,1,0,0,1,0,0,1,0,0,1,0,0,1,0,0,1,0,0,1,0,0,3,2,2,2,2,2, /* 11 teeth then outer and missing */ - 3,0,0,1,0,0,1,0,0,1,0,0,1,0,0,1,0,0,1,0,0,1,0,0,1,0,0,1,0,0,1,0,0,0,0,0, /* 11 more teeth then missing */ - }; - - /* eight tooth with 1 tooth cam */ - const unsigned char yamaha_eight_tooth_with_cam[] PROGMEM = - { /* Yamaha R1 (02-03) 8 tooth crank with 1 tooth cam */ - 0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,1, /* Teeth 1-4, 11.25 deg per step */ - 0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,1, /* teeth 5-8 */ - 0,2,2,3,2,0,0,1,0,0,0,1,0,0,0,1, /* Cam tooth on 9 */ - 0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,1 /* Teeth 13-16 */ - }; - - /* 50% dutycle, 4 tooth + 1 cam */ - const unsigned char gm_four_tooth_with_cam[] PROGMEM = - { /* 4 cylinder with 1 cam pulse for 360 crank degrees */ - 1,0,1,0,3,2,3,2 /* two pulses per crank revolution (one per cylinder) */ - }; - - /* 50% dutycle, 6 tooth + 1 cam */ - const unsigned char gm_six_tooth_with_cam[] PROGMEM = - { /* 6 cylinder with 1 cam pulse for 360 crank degrees */ - 1,0,1,0,1,0,3,2,3,2,3,2 /* three pulses per crank revolution (one per cylinder) */ - }; - - /* 50% dutycle, 8 tooth + 1 cam */ - const unsigned char gm_eight_tooth_with_cam[] PROGMEM = - { /* 8 cylinder with 1 cam pulse for 360 crank degrees */ - 1,0,1,0,1,0,1,0,3,2,3,2,3,2,3,2 /* four pulses per crank revolution (one per cylinder) */ - }; - - const unsigned char volvo_d12acd_with_cam[] PROGMEM = - { /* Volvo 6 cylinder dieslet 17-1-17-1-17-1 (60 overall teeth) */ - 0,1,1,1,0,1,1,1,0,1,1,1,0,1,1,1, /* Teeth 1-4 */ - 0,1,1,1,0,1,1,1,0,1,1,1,0,1,1,1, /* Teeth 5-8 */ - 0,1,1,1,0,1,1,1,0,1,1,1,0,1,1,1, /* Teeth 9-12 */ - 2,1,1,1,0,1,1,1,0,1,1,1,0,1,1,1, /* Teeth 13-16 */ - 0,1,1,1,2,1,1,1,1,1,1,1,1,1,1,1, /* Teeth 17-20 1 normal, 1 long (3 teeth wide) */ - 0,1,1,1,0,1,1,1,0,1,1,1,0,1,1,1, /* Teeth 21-24 */ - 0,1,1,1,0,1,1,1,0,1,1,1,0,1,1,1, /* Teeth 25-28 */ - 0,1,1,1,0,1,1,1,0,1,1,1,0,1,1,1, /* Teeth 29-32 */ - 0,1,1,1,0,1,1,1,0,1,1,1,0,1,1,1, /* Teeth 33-36 */ - 0,1,1,1,2,1,1,1,1,1,1,1,1,1,1,1, /* Teeth 37-40 1 normal, 1 long (3 teeth wide) */ - 0,1,1,1,0,1,1,1,0,1,1,1,0,1,1,1, /* Teeth 41-44 */ - 0,1,1,1,0,1,1,1,0,1,1,1,0,1,1,1, /* Teeth 45-48 */ - 0,1,1,1,0,1,1,1,0,1,1,1,0,1,1,1, /* Teeth 49-52 */ - 0,1,1,1,0,1,1,1,0,1,1,1,0,1,1,1, /* Teeth 53-56 */ - 0,1,1,1,2,1,1,1,1,1,1,1,1,1,1,1, /* Teeth 57-60 1 normal, 1 long (3 teeth wide) */ - 0,1,1,1,0,1,1,1,0,1,1,1,0,1,1,1, /* Teeth 1-4 */ - 0,1,1,1,0,1,1,1,0,1,1,1,0,1,1,1, /* Teeth 5-8 */ - 0,1,1,1,0,1,1,1,0,1,1,1,0,1,1,1, /* Teeth 9-12 */ - 0,1,1,1,0,1,1,1,0,1,1,1,0,1,1,1, /* Teeth 13-16 */ - 0,1,1,1,2,1,1,1,1,1,1,1,1,1,1,1, /* Teeth 17-20 1 normal, 1 long (3 teeth wide) */ - 0,1,1,1,0,1,1,1,0,1,1,1,0,1,1,1, /* Teeth 21-24 */ - 0,1,1,1,0,1,1,1,0,1,1,1,0,1,1,1, /* Teeth 25-28 */ - 0,1,1,1,0,1,1,1,0,1,1,1,0,1,1,1, /* Teeth 29-32 */ - 0,1,1,1,0,1,1,1,0,1,1,1,0,1,1,1, /* Teeth 33-36 */ - 0,1,1,1,2,1,1,1,1,1,1,1,1,1,1,1, /* Teeth 37-40 1 normal, 1 long (3 teeth wide) */ - 0,1,1,1,0,1,1,1,0,1,1,1,0,1,1,1, /* Teeth 41-44 */ - 0,1,1,1,0,1,1,1,0,1,1,1,0,1,1,1, /* Teeth 45-48 */ - 0,1,1,1,0,1,1,1,0,1,1,1,0,1,1,1, /* Teeth 49-52 */ - 0,1,1,1,0,1,1,1,0,1,1,1,0,1,1,1, /* Teeth 53-56 */ - 0,1,1,1,2,1,1,1,1,1,1,1,1,1,1,1, /* Teeth 57-60 1 normal, 1 long (3 teeth wide) */ - }; - const unsigned char mazda_thirty_six_minus_two_two_two_with_six_tooth_cam[] PROGMEM = - { /* Mazda 36-2-2-2 with 6 tooth cam */ - 1,1,0,0,0, 1,1,0,0,0, 1,1,0,0,0, /* Teeth 1-3*/ - 1,1,0,0,0, 1,1,0,0,0, 1,1,0,0,0, /* Teeth 4-6*/ - 1,1,0,0,0, 1,3,2,2,2, 3,3,2,2,2, /* Teeth 7-9 , second trigger on tooth 9 */ - 3,1,0,0,0, 1,1,0,0,0, 0,0,0,0,0, /* Teeth 10,11, missing 12 */ - 0,0,0,0,0, 1,3,2,2,2, 2,2,2,2,2, /* Missing 13, 14, Missing 15 , second trigger on missing tooth 15 */ - 2,0,0,0,0, 1,1,0,0,0, 1,1,0,0,0, /* Missing 16, 17-18m 2nd trigger ends on tooth 16 */ - 1,1,0,0,0, 1,1,0,0,0, 1,1,0,0,0, /* Teeth 19-21 */ - 1,1,0,0,0, 1,1,0,0,0, 1,1,0,0,0, /* Teeth 22-24 */ - 1,1,0,0,0, 1,3,2,2,2, 3,3,2,2,2, /* Teeth 25-27, second trigger on tooth 26-27 */ - 3,1,0,0,0, 1,1,0,0,0, 0,0,0,0,0, /* Teeth 28-29, missing 30 */ - 0,0,0,0,0, 1,3,2,2,2, 3,3,2,2,2, /* Missing 31, Tooth 32, 33, 2nd trigger within tooth 32 */ - 3,1,0,0,0, 1,1,0,0,0, 1,1,0,0,0, /* Teeth 34-36, 2nd trigger ends just after tooth 32 starts*/ - /* SECOND ROTATION */ - 1,1,0,0,0, 1,1,0,0,0, 1,1,0,0,0, /* Teeth 1-3 */ - 1,1,0,0,0, 1,1,0,0,0, 1,1,0,0,0, /* Teeth 4-6 */ - 1,1,0,0,0, 1,1,0,0,0, 1,1,0,0,0, /* Teeth 7-9 */ - 1,1,0,0,0, 1,1,0,0,0, 0,0,0,0,0, /* Teeth 10,11, missing 12 */ - 0,0,0,0,0, 1,3,2,2,2, 2,2,2,2,2, /* Missing 13, 14, Missing 15 , second trigger on 14-15 */ - 2,0,0,0,0, 1,1,0,0,0, 1,1,0,0,0, /* Missing 16, 17-18 */ - 1,1,0,0,0, 1,1,0,0,0, 1,1,0,0,0, /* Teeth 19-21 */ - 1,1,0,0,0, 1,1,0,0,0, 1,1,0,0,0, /* Teeth 22-24 */ - 1,1,0,0,0, 1,1,0,0,0, 1,1,0,0,0, /* Teeth 25-27 */ - 1,1,0,0,0, 1,1,0,0,0, 0,0,0,0,0, /* Teeth 28-29, missing 30 */ - 0,0,0,0,0, 1,3,2,2,2, 3,3,2,2,2, /* Missing 31,Tooth 32-33, 2nd trigger on 32-33*/ - 3,1,0,0,0, 1,1,0,0,0, 1,1,0,0,0, /* Teeth 34-36, 2nd trigger ends jsut after tooth 34 starts */ -}; - - /* Mitsubish 4g63 aka 4/2 crank and cam */ - const unsigned char mitsubishi_4g63_4_2[] PROGMEM = - { //Split into 5 degree blocks (12 per line) - 2,2,2,2,2,2,2,2,2,2,2,0, - 0,0,0,0,0,0,0,0,0,1,1,1, //Start edge 6 - 1,1,1,1,1,1,1,1,1,1,1,0, - 0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,2,2,2,3,3,3, - 3,3,3,3,3,3,3,3,1,1,1,0, - 0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,1,1,1, - 1,1,1,1,1,1,1,1,1,1,1,0, - 0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,2,3,3,3, - 3,3,3,3,3,3,3,3,3,3,3,2 - }; - - /* Mitsubish 4g63 aka 4/2 crank and cam */ - const unsigned char audi_135_with_cam[] PROGMEM = - { //0 - 180 degrees - 3,3,2,2,3,3,2,2,3,3,2,0,1,1,0,0,1,1, - 0,0,1,1,0,0,1,1,0,0,1,1,0,0,1,1,0,0, - 1,1,0,0,1,1,0,0,1,1,0,0,1,1,0,0,1,1, - 0,0,1,1,0,0,1,1,0,0,1,1,0,0,1,1,0,0, - 1,1,0,0,1,1,0,0,1,1,0,0,1,1,0,0,1,1, - 0,0,1,1,0,0,1,1,0,0,1,1,0,0,1,1,0,0, -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,1,0,0,1,1,0,0,1,1,0,0,1,1,0,2, - - }; - - /* Honda D17 12+1. 5 degree per entry*/ - const unsigned char honda_d17_no_cam[] PROGMEM = - { //0 - 360 degrees - 1,0,0,0,0,0,1,0,0,0,0,0, - 1,0,0,0,0,0,1,0,0,0,0,0, - 1,0,0,0,0,0,1,0,0,0,0,0, - 1,0,0,0,0,0,1,0,0,0,0,0, - 1,0,0,0,0,0,1,0,0,0,0,0, - 1,0,0,0,0,0,1,0,1,0,0,0, - - //360 - 720 - 1,0,0,0,0,0,1,0,0,0,0,0, - 1,0,0,0,0,0,1,0,0,0,0,0, - 1,0,0,0,0,0,1,0,0,0,0,0, - 1,0,0,0,0,0,1,0,0,0,0,0, - 1,0,0,0,0,0,1,0,0,0,0,0, - 1,0,0,0,0,0,1,0,1,0,0,0 - - }; - - /* - * http://imgur.com/a/ynLWp - */ - const unsigned char mazda_323_au[] PROGMEM = - { - 0,0,0,0,0,2,0,0,1,0,0,0, - 0,0,1,0,0,0,0,0,2,0,2,1, - 0,0,0,0,0,1 - }; - - /* - * http://www.msextra.com/doc/triggers/daihatsu-trigs.txt - * http://www.msextra.com/doc/triggers/daihatsu3cyla.jpg - * http://jbperf.com/JimStim/wheels_default.jsw - * 5 degree per entry - * - */ - const unsigned char daihatsu_3cyl[] PROGMEM = - { //0 - 360 degrees - 1,1,0,0,0,0,1,1,0,0,0,0, //0-60. Primary pulse plus the additional 1 at 15 crank degrees / 30 cam degrees - 0,0,0,0,0,0,0,0,0,0,0,0, //60-120 - 0,0,0,0,0,0,0,0,0,0,0,0, //120-180 - 0,0,0,0,0,0,0,0,0,0,0,0, //180-240 - 1,1,0,0,0,0,0,0,0,0,0,0, //240-300 - 0,0,0,0,0,0,0,0,0,0,0,0, //300-360 - - //360 - 720 - 0,0,0,0,0,0,0,0,0,0,0,0, //360-420 - 0,0,0,0,0,0,0,0,0,0,0,0, //420-480 - 1,1,0,0,0,0,0,0,0,0,0,0, //480-540 - 0,0,0,0,0,0,0,0,0,0,0,0, //540-600 - 0,0,0,0,0,0,0,0,0,0,0,0, //600-660 - 0,0,0,0,0,0,0,0,0,0,0,0 //660-720 - }; - - /* Mitsubish 4g63 aka 4/2 crank and cam */ - const unsigned char miata_9905[] PROGMEM = - { //Split into 5 degree blocks (12 per line) - 0,0,0,0,0,0,2,2,0,0,0,0, //Single cam tooth - 0,0,0,0,0,0,0,1,1,0,0,0, //Pulse at 100* - 0,0,0,0,0,0,0,0,0,1,1,0, //Pulse at 170* - 0,0,0,0,0,0,0,0,0,0,0,0, //No pulse - 0,0,0,0,0,0,0,1,1,0,0,0, //Pulse at 280* - 0,0,0,0,0,0,0,0,0,1,1,0, //Pulse at 350* - 0,0,2,2,0,0,2,2,0,0,0,0, //Double cam pulses - 0,0,0,0,0,0,0,1,1,0,0,0, //Pulse at 460* - 0,0,0,0,0,0,0,0,0,1,1,0, //Pulse at 530* - 0,0,0,0,0,0,0,0,0,0,0,0, //No pulse - 0,0,0,0,0,0,0,1,1,0,0,0, //Pulse at 640 - 0,0,0,0,0,0,0,0,0,1,1,0 //Pulse at 710 - }; - - /* 25 deg low, 5 deg high, #12 is missing, cam is high for 25 deg on second crank rotation just after tooth 21 (9) */ - const unsigned char twelve_with_cam[] PROGMEM = - { /* 12-1 with cam */ - 0,0,0,0,0,1,0,0,0,0,0,1, /* Teeth 1 and 2 */ - 0,0,0,0,0,1,0,0,0,0,0,1, /* Teeth 3 and 4 */ - 0,0,0,0,0,1,0,0,0,0,0,1, /* Teeth 5 and 6 */ - 0,0,0,0,0,1,0,0,0,0,0,1, /* Teeth 7 and 8 */ - 0,0,0,0,0,1,0,0,0,0,0,1, /* Teeth 9 and 10 */ - 0,0,0,0,0,1,0,0,0,0,0,1, /* Tooth 11 and 12 */ - 0,0,0,0,0,1,0,0,0,0,0,1, /* 2nd rotation: Teeth 13 and 14 */ - 0,0,0,0,0,1,0,0,0,0,0,1, /* Teeth 15 and 16 */ - 0,0,0,0,0,1,0,0,0,0,0,1, /* Teeth 17 and 18 */ - 0,0,0,0,0,1,0,0,0,0,0,1, /* Teeth 19 and 20 */ - 0,0,0,0,0,1,2,2,2,2,2,1, /* Tooth 21 and 22, 2nd trigger on cam between teeth 21 and 22 for 25 deg */ - 0,0,0,0,0,1,0,0,0,0,0,1 /* Totth 23 and 24th */ - }; - - /* 25 deg low, 5 deg high, #12 is missing, cam is high for 25 deg on second crank rotation just after tooth 21 (9) */ - const unsigned char twenty_four_with_cam[] PROGMEM = - { /* 24/1 with cam */ - 0,0,1,0,0,1,0,0,1,0,0,1, /* Teeth 1 and 2 */ - 0,0,1,0,0,1,0,0,1,0,0,1, /* Teeth 3 and 4 */ - 0,0,1,0,0,1,0,0,1,0,0,1, /* Teeth 5 and 6 */ - 0,0,1,0,0,1,0,0,1,0,0,1, /* Teeth 7 and 8 */ - 0,0,1,0,0,1,0,0,1,0,0,1, /* Teeth 9 and 10 */ - 0,0,1,0,0,1,0,0,1,0,0,1, /* Tooth 11 and 12 */ - 0,0,1,0,0,1,0,0,1,0,0,1, /* 2nd rotation: Teeth 13 and 14 */ - 0,0,1,0,0,1,0,0,1,0,0,1, /* Teeth 15 and 16 */ - 0,0,1,0,0,1,0,0,1,0,0,1, /* Teeth 17 and 18 */ - 0,0,1,0,0,1,0,0,1,0,0,1, /* Teeth 19 and 20 */ - 0,0,1,0,0,1,2,2,3,2,2,1, /* Tooth 21 and 22, 2nd trigger on cam between teeth 21 and 22 for 25 deg */ - 0,0,1,0,0,1,0,0,1,0,0,1 /* Totth 23 and 24th */ - }; - - const unsigned char subaru_six_seven[] PROGMEM = - { /* 6/7 */ - /* Cyl 1 TDC */ - 0,0,0,0,0,2,2,2,0,0, 0,2,2,2,0,0,0,2,2,2, /* 00-19 degrees - cam 1-2-3: 5* ATDC */ - 0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0, /* 20-39 degrees */ - 0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0, /* 40-59 degrees */ - 0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0, /* 60-20 degrees */ - 0,0,0,1,1,1,0,0,0,0, 0,0,0,0,0,0,0,0,0,0, /* 80-99 degrees - crank 1: 83* ATDC */ - 0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,1,1,1,0,0, /* 100 degrees - crank 2: 115* ATDC */ - 0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0, /* 120 degrees */ - 0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0, /* 140 degrees */ - 0,0,0,0,0,0,0,0,0,0, 1,1,1,0,0,0,0,0,0,0, /* 160 degrees - crank 3: 170* ATDC */ - - /* Cyl 2 TDC */ - 0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0, /* 180 degrees */ - 2,2,2,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0, /* 200 degrees - cam 4: 20* ATDC (200*) */ - 0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0, /* 220 degrees */ - 0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0, /* 240 degrees */ - 0,0,0,1,1,1,0,0,0,0, 0,0,0,0,0,0,0,0,0,0, /* 260 degrees - crank 4: 83* ATDC (263*) */ - 0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,1,1,1,0,0, /* 280 degrees - crank 5: 115* ATDC (295*) */ - 0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0, /* 300 degrees */ - 0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0, /* 320 degrees */ - 0,0,0,0,0,0,0,0,0,0, 1,1,1,0,0,0,0,0,0,0, /* 340 degrees - crank 6: 170* ATDC (350*) */ - - /* Cyl 3 TDC */ - 0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0, /* 360 degrees */ - 2,2,2,0,0,0,2,2,2,0, 0,0,0,0,0,0,0,0,0,0, /* 380 degrees - cam 5-6: 20* ATDC (380*) */ - 0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0, /* 400 degrees */ - 0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0, /* 420 degrees */ - 0,0,0,1,1,1,0,0,0,0, 0,0,0,0,0,0,0,0,0,0, /* 440 degrees - crank 1: 83* ATDC (443*) */ - 0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,1,1,1,0,0, /* 460 degrees - crank 2: 115* ATDC (475*) */ - 0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0, /* 480 degrees */ - 0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0, /* 500 degrees */ - 0,0,0,0,0,0,0,0,0,0, 1,1,1,0,0,0,0,0,0,0, /* 520 degrees - crank 3: 170* ATDC */ - - /* Cyl 4 TDC */ - 0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0, /* 540 degrees */ - 2,2,2,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0, /* 560 degrees - cam 7: 20* ATDC (560*) */ - 0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0, /* 580 degrees */ - 0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0, /* 600 degrees */ - 0,0,0,1,1,1,0,0,0,0, 0,0,0,0,0,0,0,0,0,0, /* 620 degrees - crank 4: 83* ATDC (623*) */ - 0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,1,1,1,0,0, /* 640 degrees - crank 5: 115* ATDC (655*) */ - 0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0, /* 660 degrees */ - 0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0, /* 680 degrees */ - 0,0,0,0,0,0,0,0,0,0, 1,1,1,0,0,0,0,0,0,0 /* 700 degrees - crank 6: 170* ATDC (710*) */ - }; - - /* GM 7X for 6 cylinder engines */ - /* https://speeduino.com/forum/download/file.php?id=4743 */ - const unsigned char gm_seven_x[] PROGMEM = - { /* Every number represents 2 degrees */ - 0,0,0,0,0,0,0,0,0,0, /* Degrees 0-20 */ - 0,0,0,0,0,0,0,0,0,0, /* Degrees 20-40 */ - 0,1,1,0,0,0,0,0,0,0, /* Degrees 40-60. Tooth #1 at 42* for 4* duration. These are actually 5* duration, but close enough */ - 0,0,0,0,0,0,0,0,0,0, /* Degrees 60-80 */ - 0,0,0,0,0,0,0,0,0,0, /* Degrees 80-100 */ - 0,1,1,0,0,0,1,1,0,0, /* Degrees 100-120. Tooth #2 at 102* for 4* duration. "Extra" tooth at 112* */ - 0,0,0,0,0,0,0,0,0,0, /* Degrees 120-140 */ - 0,0,0,0,0,0,0,0,0,0, /* Degrees 140-160 */ - 0,1,1,0,0,0,0,0,0,0, /* Degrees 160-180. Tooth #3 at 162* for 4* duration */ - 0,0,0,0,0,0,0,0,0,0, /* Degrees 180-200 */ - 0,0,0,0,0,0,0,0,0,0, /* Degrees 200-220 */ - 0,1,1,0,0,0,0,0,0,0, /* Degrees 220-240. Tooth #4 at 222* for 4* duration */ - 0,0,0,0,0,0,0,0,0,0, /* Degrees 240-260 */ - 0,0,0,0,0,0,0,0,0,0, /* Degrees 260-280 */ - 0,1,1,0,0,0,0,0,0,0, /* Degrees 280-300. Tooth #5 at 282* for 4* duration */ - 0,0,0,0,0,0,0,0,0,0, /* Degrees 300-320 */ - 0,0,0,0,0,0,0,0,0,0, /* Degrees 320-340 */ - 0,1,1,0,0,0,0,0,0,0 /* Degrees 340-360. Tooth #6 at 342* for 4* duration */ - }; - - /* DSM 420a Eclipse */ - /* https://github.com/noisymime/speeduino/issues/133 */ - const unsigned char four_twenty_a[] PROGMEM = - { /* Every number represents 5 degrees */ - 0,0,0,0,0,0,0,0,0,0,0,2, - 2,2,2,2,2,2,2,2,2,3,3,2, - 2,3,3,2,2,3,3,2,2,3,3,2, - 2,2,2,2,2,0,0,0,0,0,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,2,3,2,3,2 - }; - - #endif +/* vim: set syntax=c expandtab sw=2 softtabstop=2 autoindent smartindent smarttab : */ +/* + * Arbritrary wheel pattern generator wheel definitions + * + * copyright 2014 David J. Andruczyk + * + * Ardu-Stim software is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * ArduStim software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with any ArduStim software. If not, see http://www.gnu.org/licenses/ + * + */ + #ifndef __WHEEL_DEFS_H__ + #define __WHEEL_DEFS_H__ + + #include + + /* Wheel patterns! + * + * Wheel patterns define the pin states and specific times. The ISR runs + * at a constant speed related to the requested RPM. The request RPM is + * scaled based on the LENGTH of each wheel's array. The reference is + * the 60-2 which was the first decoder designed which has 120 "edges" + * (transitions" for each revolution of the wheel. Any other wheel that + * also has 120 edges has and RPM scaling factor of 1.0. IF a wheel has + * less edges needed to "describe" it, it's number of edges are divided by 120 to + * get the scaling factor which is applied to the RPM calculation. + * There is an enumeration (below) that lists the defined wheel types, + * as well as an array listing the rpm_scaling factors with regards to + * each pattern. + * + * NOTE: There is MORE THAN ONE WAY to define a wheel pattern. You can + * use more edges to get to 1 deg accuracy but the side effect is that + * your maximum RPM is capped because of that. Currently 60-2 can run + * up to about 60,000 RPM, 360and8 can only do about 10,000 RPM becasue + * it has 6x the number of edges... The less edges, the faster it can go... :) + * + * Using more edges allows you to do things like vary the dutycycle, + * i.e. a simple non-missing tooth 50% duty cycle wheel can be defined + * with only 2 entries if you really want, but I didn't do it that way + * for some of the simple ones as it made it seem somewhat confusing + * to look at as it required you to keep the rpm_scaler factor in mind. + * Most/all patterns show the pulses you're receive for one revolution + * of a REAL wheel on a real engine. + */ + + /* Wheel types we know about... + * This enumerations is the INDEX into the Wheels[] array of structures + * defined in main file. That struct contains pointers to the following: + * wheel name in a user friendly string + * pointer to the wheel edge array used by the ISR + * RPM scaling factor (num_edges/120 for crank wheels) + * Number of edges in the edge array above, needed by the ISR + */ + typedef enum { + DIZZY_FOUR_CYLINDER, /* 2 evenly spaced teeth */ + DIZZY_SIX_CYLINDER, /* 3 evenly spaced teeth */ + DIZZY_EIGHT_CYLINDER, /* 4 evenly spaced teeth */ + SIXTY_MINUS_TWO, /* 60-2 crank only */ + SIXTY_MINUS_TWO_WITH_CAM, /* 60-2 with 2nd trigger on cam */ + THIRTY_SIX_MINUS_ONE, /* 36-1 crank only */ + TWENTY_FOUR_MINUS_ONE, + FOUR_MINUS_ONE_WITH_CAM, /* 4-1 crank + cam */ + EIGHT_MINUS_ONE, /* 8-1 crank only */ + SIX_MINUS_ONE_WITH_CAM,/* 6-1 crank + cam */ + TWELVE_MINUS_ONE_WITH_CAM, /* 12-1 crank + cam */ + FOURTY_MINUS_ONE, /* Ford V-10 40-1 crank only */ + DIZZY_FOUR_TRIGGER_RETURN, /* dizzy 4 cylinder signal, 40deg on 50 deg off */ + ODDFIRE_VR, /* Oddfire V-twin */ + OPTISPARK_LT1, /* Optispark 360 and 8 */ + TWELVE_MINUS_THREE, /* 12-3 */ + THIRTY_SIX_MINUS_TWO_TWO_TWO, /* 36-2-2-2 crank only */ + THIRTY_SIX_MINUS_TWO_TWO_TWO_WITH_CAM, /* 36-2-2-2 crank and cam */ + FOURTY_TWO_HUNDRED_WHEEL, /* 4200 wheel */ + THIRTY_SIX_MINUS_ONE_WITH_CAM_FE3, /* Mazda F3 36-1 crank and cam */ + SIX_G_SEVENTY_TWO_WITH_CAM, /* Mitsubishi DOHC CAS and TCDS 6G72 */ + BUELL_ODDFIRE_CAM, /* Buell 45 deg cam wheel */ + GM_LS1_CRANK_AND_CAM, /* GM LS1 24 tooth with cam */ + LOTUS_THIRTY_SIX_MINUS_ONE_ONE_ONE_ONE, /* Lotus crank wheel 36-1-1-1-1 */ + HONDA_RC51_WITH_CAM, /* Honda oddfire 90 deg V-twin */ + THIRTY_SIX_MINUS_ONE_WITH_SECOND_TRIGGER, /* From jimstim */ + THIRTY_SIX_MINUS_ONE_PLUS_ONE_WITH_CAM_NGC4, /* From jimstim 36-1+1 wheel #5 4 cyl chrysler? */ + WEBER_IAW_WITH_CAM, /* From jimstim IAW weber-marelli */ + FIAT_ONE_POINT_EIGHT_SIXTEEN_VALVE_WITH_CAM, /* Fiat 1.8 16V from jimstim */ + THREE_SIXTY_NISSAN_CAS, /*from jimstim 360 tooth cas with 6 slots */ + TWENTY_FOUR_MINUS_TWO_WITH_SECOND_TRIGGER, /* Mazda CAS 24-1 inner ring single pulse outer ring */ + YAMAHA_EIGHT_TOOTH_WITH_CAM, /* 02-03 Yamaha R1, seank */ + GM_FOUR_TOOTH_WITH_CAM, /* GM 4 even crank with half moon cam */ + GM_SIX_TOOTH_WITH_CAM, /* GM 4 even crank with half moon cam */ + GM_EIGHT_TOOTH_WITH_CAM, /* GM 4 even crank with half moon cam */ + VOLVO_D12ACD_WITH_CAM, /* Volvo Diesel d12[acd] with cam (alex32 on forums.libreems.org */ + MAZDA_THIRTY_SIX_MINUS_TWO_TWO_TWO_WITH_SIX_TOOTH_CAM, + MITSUBISH_4g63_4_2, + AUDI_135_WITH_CAM, + HONDA_D17_NO_CAM, + MAZDA_323_AU, + DAIHATSU_3CYL, + MIATA_9905, + TWELVE_WITH_CAM, //12 evenly spaced crank teeth and a single cam tooth + TWENTY_FOUR_WITH_CAM, //24 evenly spaced crank teeth and a single cam tooth + SUBARU_SIX_SEVEN, /* Subaru 6 crank, 7 cam */ + GM_7X, /* GM 7X pattern. 6 even teeth with 1 extra uneven tooth */ + FOUR_TWENTY_A, /* DSM 420a */ + FORD_ST170, /* Ford ST170 */ + MITSUBISHI_3A92, /* Mitsubishi 3cylinder 3A92 */ + ROVER_K_MODE1_36_ONE_ONE, /* early MEMS versions with 24-1-1 pattern (aka 12-1 at cam speed) */ + ROVER_K_MODE2_36_ONE_ONE_ONE_ONE, /* MEMS 1.9 of the 36 with 4 missing teeth */ + ROVER_K_MODE3_36_ONE_ONE_ONE_ONE, /* MEMS 2.0 of the 36 with 4 missing teeth at different places */ + ROVER_K_MODE4_36_ONE_ONE_ONE_ONE, /* MEMS 3.0 of the 36 with 4 missing teeth at different places */ + MAX_WHEELS, + }WheelType; + +/* Name strings for EACH wheel type, for serial UI */ + const char dizzy_four_cylinder_friendly_name[] PROGMEM = "4 cylinder dizzy"; + const char dizzy_six_cylinder_friendly_name[] PROGMEM = "6 cylinder dizzy"; + const char dizzy_eight_cylinder_friendly_name[] PROGMEM = "8 cylinder dizzy"; + const char sixty_minus_two_friendly_name[] PROGMEM = "60-2 crank only"; + const char sixty_minus_two_with_cam_friendly_name[] PROGMEM = "60-2 crank and cam"; + const char thirty_six_minus_one_friendly_name[] PROGMEM = "36-1 crank only"; + const char twenty_four_minus_one_friendly_name[] PROGMEM = "24-1 crank only"; + const char four_minus_one_with_cam_friendly_name[] PROGMEM = "4-1 crank wheel with cam"; + const char eight_minus_one_friendly_name[] PROGMEM = "8-1 crank only (R6)"; + const char six_minus_one_with_cam_friendly_name[] PROGMEM = "6-1 crank with cam"; + const char twelve_minus_one_with_cam_friendly_name[] PROGMEM = "12-1 crank with cam"; + const char fourty_minus_one_friendly_name[] PROGMEM = "40-1 crank only (Ford V10)"; + const char dizzy_four_trigger_return_friendly_name[] PROGMEM = "Distributor style 4 cyl 50deg off, 40 deg on"; + const char oddfire_vr_friendly_name[] PROGMEM = "odd fire 90 deg pattern 0 and 135 pulses"; + const char optispark_lt1_friendly_name[] PROGMEM = "GM OptiSpark LT1 360 and 8"; + const char twelve_minus_three_friendly_name[] PROGMEM = "12-3 oddball"; + const char thirty_six_minus_two_two_two_friendly_name[] PROGMEM = "36-2-2-2 Crank only"; + const char thirty_six_minus_two_two_two_with_cam_friendly_name[] PROGMEM = "36-2-2-2 Crank and cam"; + const char fourty_two_hundred_wheel_friendly_name[] PROGMEM = "GM 4200 crank wheel"; + const char thirty_six_minus_one_with_cam_fe3_friendly_name[] PROGMEM = "Mazda FE3 36-1 with cam"; + const char six_g_seventy_two_with_cam_friendly_name[] PROGMEM = "Mitsubishi 6g72 with cam"; + const char buell_oddfire_cam_friendly_name[] PROGMEM = "Buell Oddfire CAM wheel"; + const char gm_ls1_crank_and_cam_friendly_name[] PROGMEM = "GM LS1 crank and cam"; + const char lotus_thirty_six_minus_one_one_one_one_friendly_name[] PROGMEM = "Odd Lotus 36-1-1-1-1 flywheel"; + const char honda_rc51_with_cam_friendly_name[] PROGMEM = "Honda RC51 with cam"; + const char thirty_six_minus_one_with_second_trigger_friendly_name[] PROGMEM = "36-1 crank with 2nd trigger on teeth 33-34"; + const char thirty_six_minus_one_plus_one_with_cam_ngc4_friendly_name[] PROGMEM = "36-1+1 crank with cam pattern NGC4"; + const char weber_iaw_with_cam_friendly_name[] PROGMEM = "Weber-Marelli 8 crank+2 cam pattern"; + const char fiat_one_point_eight_sixteen_valve_with_cam_friendly_name[] PROGMEM = "Fiat 1.8 16V crank and cam"; + const char three_sixty_nissan_cas_friendly_name[] PROGMEM = "Nissan 360 CAS with 6 slots"; + const char twenty_four_minus_two_with_second_trigger_friendly_name[] PROGMEM = "Mazda CAS 24-2 with single pulse outer ring"; + const char yamaha_eight_tooth_with_cam_friendly_name[] PROGMEM = "Yamaha 2002-03 R1 8 even-tooth crank with 1 tooth cam"; + const char gm_four_tooth_with_cam_friendly_name[] PROGMEM = "GM 4 even-tooth crank with 1 tooth cam"; + const char gm_six_tooth_with_cam_friendly_name[] PROGMEM = "GM 6 even-tooth crank with 1 tooth cam"; + const char gm_eight_tooth_with_cam_friendly_name[] PROGMEM = "GM 8 even-tooth crank with 1 tooth cam"; + const char volvo_d12acd_with_cam_friendly_name[] PROGMEM = "Volvo d12[acd] crank with 7 tooth cam"; + const char mazda_thirty_six_minus_two_two_two_with_six_tooth_cam_friendly_name[] PROGMEM = "Mazda 36-2-2-2 with 6 tooht cam"; + const char mitsubishi_4g63_4_2_friendly_name[] PROGMEM = "Mitsubishi 4g63 aka 4/2 crank and cam"; + const char audi_135_with_cam_friendly_name[] PROGMEM = "Audi 135 tooth crank and cam"; + const char honda_d17_no_cam_friendly_name[] PROGMEM = "Honda D17 Crank (12+1)"; + const char mazda_323_au_friendly_name[] PROGMEM = "Mazda 323 AU version"; + const char daihatsu_3cyl_friendly_name[] PROGMEM = "Daihatsu 3+1 distributor (3 cylinders)"; + const char miata_9905_friendly_name[] PROGMEM = "Miata 99-05"; + const char twelve_with_cam_friendly_name[] PROGMEM = "12/1 (12 crank with cam)"; + const char twenty_four_with_cam_friendly_name[] PROGMEM = "24/1 (24 crank with cam)"; + const char subaru_six_seven_name_friendly_name[] PROGMEM = "Subaru 6/7 crank and cam"; + const char gm_seven_x_friendly_name[] PROGMEM = "GM 7X"; + const char four_twenty_a_friendly_name[] PROGMEM = "DSM 420a"; + const char ford_st170_friendly_name[] PROGMEM = "Ford ST170"; + const char mitsubishi_3A92_friendly_name[] PROGMEM = "Mitsubishi 3A92"; + const char rover_k_mode1_thirtysix_minus_one_one_friendly_name[] PROGMEM = "Rover k series 36-1-1 flywheel EARLY"; + const char rover_k_mode2_thirtysix_minus_one_one_one_one_friendly_name[] PROGMEM = "Rover k series 36-1-1-1-1 flywheel MEMS 1.9"; + const char rover_k_mode3_thirtysix_minus_one_one_one_one_friendly_name[] PROGMEM = "Rover k series 36-1-1-1-1 flywheel MEMS 2"; + const char rover_k_mode4_thirtysix_minus_one_one_one_one_friendly_name[] PROGMEM = "Rover k series 36-1-1-1-1 flywheel MEMS 3"; + + /* Very simple 50% duty cycle */ + const unsigned char dizzy_four_cylinder[] PROGMEM = + { /* dizzy 4 cylinder */ + 1,0,1,0 /* two pulses per crank revolution (one per cylinder) */ + }; + + /* Very simple 50% duty cycle */ + const unsigned char dizzy_six_cylinder[] PROGMEM = + { /* dizzy 6 cylinder */ + 1,0,1,0,1,0 /* three pulses per crank revolution (one per cylinder) */ + }; + + /* Very simple 50% duty cycle */ + const unsigned char dizzy_eight_cylinder[] PROGMEM = + { /* dizzy 8 cyl */ + 1,0,1,0,1,0,1,0 /* four pulses per crank revolution (one per cylinder) */ + }; + + /* Standard bosch 60-2 pattern, 50% duty cyctle during normal teeth */ + const unsigned char sixty_minus_two[] PROGMEM = + { /* 60-2 */ + 1,0,1,0,1,0,1,0,1,0, /* teeth 1-5 */ + 1,0,1,0,1,0,1,0,1,0, /* teeth 6-10 */ + 1,0,1,0,1,0,1,0,1,0, /* teeth 11-15 */ + 1,0,1,0,1,0,1,0,1,0, /* teeth 16-20 */ + 1,0,1,0,1,0,1,0,1,0, /* teeth 21-25 */ + 1,0,1,0,1,0,1,0,1,0, /* teeth 26-30 */ + 1,0,1,0,1,0,1,0,1,0, /* teeth 31-35 */ + 1,0,1,0,1,0,1,0,1,0, /* teeth 36-40 */ + 1,0,1,0,1,0,1,0,1,0, /* teeth 41-45 */ + 1,0,1,0,1,0,1,0,1,0, /* teeth 46-50 */ + 1,0,1,0,1,0,1,0,1,0, /* teeth 51-55 */ + 1,0,1,0,1,0,0,0,0,0 /* teeth 56-58 and 59-60 MISSING */ + }; + + /* Bosch 60-2 pattern with 2nd trigger on rotation 2, + * 50% duty cyctle during normal teeth */ + const unsigned char sixty_minus_two_with_cam[] PROGMEM = + { /* 60-2 */ + 1,0,1,0,1,0,1,0,1,0, /* teeth 1-5 */ + 1,0,1,0,1,0,1,0,1,0, /* teeth 6-10 */ + 1,0,1,0,1,0,1,0,1,0, /* teeth 11-15 */ + 1,0,1,0,1,0,1,0,1,0, /* teeth 16-20 */ + 1,0,1,0,1,0,1,0,1,0, /* teeth 21-25 */ + 1,0,1,0,1,0,1,0,1,0, /* teeth 26-30 */ + 1,0,1,0,1,0,1,0,1,0, /* teeth 31-35 */ + 1,0,1,0,1,0,1,0,1,0, /* teeth 36-40 */ + 1,0,1,0,1,0,1,0,1,0, /* teeth 41-45 */ + 1,0,1,0,1,0,1,0,1,0, /* teeth 46-50 */ + 1,0,1,0,1,0,1,0,1,0, /* teeth 51-55 */ + 1,0,1,0,1,0,0,0,0,0, /* teeth 56-58 and 59-60 MISSING */ + 1,0,1,0,1,0,1,0,1,0, /* Second revolution teeth 1-5 */ + 1,0,1,0,1,0,1,0,1,0, /* teeth 6-10 */ + 1,0,1,0,1,0,1,0,1,0, /* teeth 11-15 */ + 1,0,1,0,1,0,1,0,1,0, /* teeth 16-20 */ + 1,0,1,0,1,0,1,0,1,0, /* teeth 21-25 */ + 1,0,1,0,1,0,1,0,1,0, /* teeth 26-30 */ + 1,0,1,0,1,0,1,0,1,0, /* teeth 31-35 */ + 1,2,1,0,1,0,1,0,1,0, /* teeth 36-40, Cam trigger on latter half of 36th */ + 1,0,1,0,1,0,1,0,1,0, /* teeth 41-45 */ + 1,0,1,0,1,0,1,0,1,0, /* teeth 46-50 */ + 1,0,1,0,1,0,1,0,1,0, /* teeth 51-55 */ + 1,0,1,0,1,0,0,0,0,0 /* teeth 56-58 and 59-60 MISSING */ + }; + + /* Standard ford/mazda and aftermarket 36-1 pattern, 50% duty cyctle during normal teeth */ + const unsigned char thirty_six_minus_one[] PROGMEM = + { /* 36-1 */ + 1,0,1,0,1,0,1,0,1,0, /* teeth 1-5 */ + 1,0,1,0,1,0,1,0,1,0, /* teeth 6-10 */ + 1,0,1,0,1,0,1,0,1,0, /* teeth 11-15 */ + 1,0,1,0,1,0,1,0,1,0, /* teeth 16-20 */ + 1,0,1,0,1,0,1,0,1,0, /* teeth 21-25 */ + 1,0,1,0,1,0,1,0,1,0, /* teeth 26-30 */ + 1,0,1,0,1,0,1,0,1,0, /* teeth 31-35 */ + 0,0 /* MISSING 36th tooth */ + }; + + /* Standard ford/mazda and aftermarket 36-1 pattern, 50% duty cyctle during normal teeth */ + const unsigned char twenty_four_minus_one[] PROGMEM = + { /* 36-1 */ + 1,0,1,0,1,0, /* teeth 1-3 */ + 1,0,1,0,1,0, /* teeth 4-6 */ + 1,0,1,0,1,0, /* teeth 7-9 */ + 1,0,1,0,1,0, /* teeth 10-12 */ + 1,0,1,0,1,0, /* teeth 13-15 */ + 1,0,1,0,1,0, /* teeth 16-18 */ + 1,0,1,0,1,0, /* teeth 19-21 */ + 1,0,1,0,0,0, /* teeth 22-21 */ + }; + + /* 4-1 crank signal 50% duty cycle with Cam tooth enabled during the second rotation prior to tooth 2 */ + const unsigned char four_minus_one_with_cam[] PROGMEM = + { /* 4-1 with cam */ + 0,1,0,1,0,1,0,0, /* Teeth 1-3, then MISSING */ + 0,1,2,1,0,1,0,0 /* Tooth 5, 2nd trigger on cam between 5 and 6 + then 6 and 7 and MISSING 8th */ + }; + + /* Yamaha R6 crank trigger 8 teeth missing one, (22.5deg low, 22.5deg high) 50% duty cycle during normal teeth */ + const unsigned char eight_minus_one[] PROGMEM = + { /* 8-1 */ + 0,1,0,1,0,1,0,1, /* Teeth 1-4 */ + 0,1,0,1,0,1,0,0 /* Teeth 5-7, then MISSING */ + }; + + /* 40deg low, 20 deg high per tooth, cam signal on second rotation during 40deg low portion of 3rd tooth */ + const unsigned char six_minus_one_with_cam[] PROGMEM = + { /* 6-1 with cam */ + 0,0,1,0,0,1,0,0,1, /* Teeth 1-3 */ + 0,0,1,0,0,1,0,0,0, /* Teeth 4 and 5 and MISSING 6th */ + 0,0,1,0,0,1,2,2,1, /* 2nd rev teeth 7 and 8, then 2nd trigger on cam between 8 and 9 */ + 0,0,1,0,0,1,0,0,0 /* teeth 10 and 11 then missing 12th */ + }; + + /* 25 deg low, 5 deg high, #12 is missing, cam is high for 25 deg on second crank rotation just after tooth 21 (9) */ + const unsigned char twelve_minus_one_with_cam[] PROGMEM = + { /* 12-1 with cam */ + 0,0,0,0,0,1,0,0,0,0,0,1, /* Teeth 1 and 2 */ + 0,0,0,0,0,1,0,0,0,0,0,1, /* Teeth 3 and 4 */ + 0,0,0,0,0,1,0,0,0,0,0,1, /* Teeth 5 and 6 */ + 0,0,0,0,0,1,0,0,0,0,0,1, /* Teeth 7 and 8 */ + 0,0,0,0,0,1,0,0,0,0,0,1, /* Teeth 9 and 10 */ + 0,0,0,0,0,1,0,0,0,0,0,0, /* Tooth 11 and MISSING twelth */ + //0,0,0,0,0,1,0,0,0,0,0,1, /* Tooth 11 and WITHOUT MISSING twelth */ + 0,0,0,0,0,1,0,0,0,0,0,1, /* 2nd rotation: Teeth 13 and 14 */ + 0,0,0,0,0,1,0,0,0,0,0,1, /* Teeth 15 and 16 */ + 0,0,0,0,0,1,0,0,0,0,0,1, /* Teeth 17 and 18 */ + 0,0,0,0,0,1,0,0,0,0,0,1, /* Teeth 19 and 20 */ + 0,0,0,0,0,1,2,2,2,2,2,1, /* Tooth 21 and 22, 2nd trigger on cam between teeth 21 and 22 for 25 deg */ + 0,0,0,0,0,1,0,0,0,0,0,0 /* Totth 23 and MISSING 24th */ + //0,0,0,0,0,1,0,0,0,0,0,1 /* Totth 23 and WITHOUT MISSING 24th */ + }; + + /* Ford V10 version of EDIS with 40 teeth instead of 36, 50% duty cycle during normal teeth.. */ + const unsigned char fourty_minus_one[] PROGMEM = + { /* 40-1 */ + 0,1,0,1,0,1,0,1,0,1, /* Teeth 1-5 */ + 0,1,0,1,0,1,0,1,0,1, /* Teeth 6-10 */ + 0,1,0,1,0,1,0,1,0,1, /* Teeth 11-15 */ + 0,1,0,1,0,1,0,1,0,1, /* Teeth 16-20 */ + 0,1,0,1,0,1,0,1,0,1, /* Teeth 21-25 */ + 0,1,0,1,0,1,0,1,0,1, /* Teeth 26-30 */ + 0,1,0,1,0,1,0,1,0,1, /* Teeth 31-35 */ + 0,1,0,1,0,1,0,1,0,0 /* Teeth 36-39 and MISSING 40th tooth */ + }; + + /* 50deg off, 40 deg on dissy style signal */ + const unsigned char dizzy_four_trigger_return[] PROGMEM = + { /* dizzy trigger return */ + 0,0,0,0,0,1,1,1,1l /* Simple off/on signal, 50deg off, 40 deg on */ + }; + + /* Oddfire V twin 135/225 split */ + const unsigned char oddfire_vr[] PROGMEM = + { /* Oddfire VR */ + 1,0,0,0,0,0,0,0,0,1,0,0, /* Tooth 1 and 2 at 0 deg and 135 deg, then 225 off */ + 0,0,0,0,0,0,0,0,0,0,0,0 + }; + + /* GM LT1 360 and 8 wheel, see http://powerefi.com/files/opti-LT1-count.JPG */ + const unsigned char optispark_lt1[] PROGMEM = + { /* Optispark 360 outside teeth, 8 varying inside teeth */ + /* 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 */ + 0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1, + 0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1, + 0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1, /* 0-30 */ + 0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1, + 0,1,0,1,0,1,2,3,2,3,2,3,2,3,2,3,2,3,2,3, + 0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1, /* 31-60 */ + 0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1, + 0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1, + 0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,2,3,2,3, /* 61-90 */ + 0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1, + 0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1, + 0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1, /* 91-120 */ + 0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1, + 0,1,0,1,0,1,2,3,2,3,2,3,2,3,2,3,2,3,2,3, + 2,3,2,3,2,3,2,3,2,3,0,1,0,1,0,1,0,1,0,1, /* 121-150 */ + 0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1, + 0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1, + 0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,2,3,2,3, /* 151-180 */ + 0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1, + 0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1, + 0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1, /* 181-210 */ + 0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1, + 0,1,0,1,0,1,2,3,2,3,2,3,2,3,2,3,2,3,2,3, + 2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3, /* 211-240 */ + 0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1, + 0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1, + 0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,2,3,2,3, /* 241-270 */ + 0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1, + 0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1, + 0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1, /* 271-300 */ + 0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1, + 0,1,0,1,0,1,2,3,2,3,2,3,2,3,2,3,2,3,2,3, + 2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3, /* 301-330 */ + 2,3,2,3,2,3,2,3,2,3,0,1,0,1,0,1,0,1,0,1, + 0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1, + 0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,2,3,2,3 /* 331-360 */ + }; + + const unsigned char twelve_minus_three[] PROGMEM = + { /* 12-3, http://www.msextra.com/doc/triggers/12_3_wheel_133.jpg */ + 1,0,0,0,1,0,0,0, /* Teeth 1-2 */ + 1,0,0,0,1,0,0,0, /* Teeth 3-4 */ + 1,0,0,0,1,0,0,0, /* Teeth 5-6 */ + 1,0,0,0,1,0,0,0, /* Teeth 7-8 */ + 1,0,0,0,0,0,0,0, /* Tooth 9 and MISSING 10th */ + 0,0,0,0,0,0,0,0 /* MISSING Teeth 11-12 */ + }; + + const unsigned char thirty_six_minus_two_two_two[] PROGMEM = + { + 1,0,1,0,1,0,1,0,1,0, + 1,0,1,0,1,0,1,0,1,0, + 1,0,1,0,1,0,0,0,0,0, + 1,0,0,0,0,0,1,0,1,0, + 1,0,1,0,1,0,1,0,1,0, + 1,0,1,0,1,0,1,0,1,0, + 1,0,0,0,0,0,1,0,1,0, + 1,0 + }; + + const unsigned char thirty_six_minus_two_two_two_with_cam[] PROGMEM = + { /* 36-2-2-2 with cam */ + 1,0,0,2,0,0,1,0,0,0, /* Tooth one, missing teeth 2,3 and 5, 2nd trigger during teeth 2 and 3 */ + 0,0,1,0,1,0,1,0,1,0, /* Missing tooth 6, then 7-10 */ + 1,0,1,0,1,0,1,0,1,0, /* Teeth 11-15 */ + 1,0,1,0,1,0,1,0,1,0, /* Teeth 16-20 */ + 1,0,1,0,0,2,0,0,1,0, /* Teeth 21-2sing 23-24, then 25, 2nd trigger during teeth 23 and 24 */ + 1,0,1,0,1,0,1,0,1,0, /* Teeth 26-30 */ + 1,0,1,0,1,0,1,0,1,0, /* Teeth 31-35 */ + 1,0, /* 36th Tooth */ + 1,0,0,0,0,0,1,0,0,0, /* Tooth one, missing teeth 2,3 and 5 */ + 0,0,1,0,1,2,1,0,1,0, /* Missing tooth 6, then 7-10 */ + 1,0,1,0,1,0,1,0,1,0, /* Teeth 11-15 */ + 1,0,1,0,1,0,1,0,1,0, /* Teeth 16-20 */ + 1,0,1,0,0,0,0,0,1,0, /* Teeth 21-22 missing 23-24, then 25 */ + 1,0,1,0,1,0,1,0,1,0, /* Teeth 26-30 */ + 1,0,1,0,1,0,1,0,1,0, /* Teeth 31-35 */ + 1,0 /* 36th Tooth */ + }; + + + const unsigned char fourty_two_hundred_wheel[] PROGMEM = + { /* 4200 wheel http://msextra.com/doc/triggers/4200_timing.pdf */ + /* 55 deg high, 5 deg low, 55 deg high, 5 deg low, + * 5 deg high, 5 deg low, 45 deg high, 5 deg low, + * 55 deg high, 5 deg low, 65 deg high, 5 deg low, + * 45 deg high, 5 deg low, (360 degreees ) */ + 1,1,1,1,1,1,1,1,1,1, + 1,0,1,1,1,1,1,1,1,1, + 1,1,1,0,1,0,1,1,1,1, + 1,1,1,1,1,0,1,1,1,1, + 1,1,1,1,1,1,1,0,1,1, + 1,1,1,1,1,1,1,1,1,1, + 1,0,1,1,1,1,1,1,1,1, + 1,0 + }; + + /* Mazda F3 36-1 with cam */ + const unsigned char thirty_six_minus_one_with_cam_fe3[] PROGMEM = + { /* 36-1 with cam, 3 cam teeth, 2 180deg from each other */ + 1,0,1,0,1,0,1,0,1,0,1,0, /* 0-55 deg */ + 1,0,1,0,1,0,3,2,3,0,1,0, /* 60-115 deg cam tooth at 90 deg crank for 15 crank degrees */ + 1,0,1,0,1,0,1,0,1,0,1,0, /* 120-175 deg */ + 1,0,1,0,1,0,1,0,1,0,1,0, /* 180-235 deg */ + 1,0,1,0,1,0,1,0,1,0,1,0, /* 240-295 deg */ + 1,0,1,0,1,0,1,0,1,0,0,0, /* 300-355 deg Crank missing tooth at end */ + 1,0,1,0,1,0,1,0,1,0,1,0, /* 360-415 deg */ + 3,2,3,0,1,0,3,2,3,0,1,0, /* 420-475 deg 2 more cam teeth at 420 and 450 deg, 15 crank degrees each */ + 1,0,1,0,1,0,1,0,1,0,1,0, /* 480-535 deg */ + 1,0,1,0,1,0,1,0,1,0,1,0, /* 540-595 deg */ + 1,0,1,0,1,0,1,0,1,0,1,0, /* 600-655 deg */ + 1,0,1,0,1,0,1,0,1,0,0,0 /* 660-715 deg Crank missing tooth at end */ + }; + + /* Mitsubishi 6g72 crank/cam */ + const unsigned char six_g_seventy_two_with_cam[] PROGMEM = + { /* Mitsubishi 6g72 */ + /* Crank signal's are 50 deg wide, and one per cylinder + * Cam signals have 3 40 deg wide teeh and one 85 deg wide tooth + * Counting both From TDC#1 + * Crank: 40 deg high, 70 deg low (repeats whole cycle) + * Cam: 70 deg high, 80 deg low, 40 deg high, 150 deg low, + * 40 deg high, 130 deg low, 40 deg high, 155 deg low + */ + 3,3,3,3,3,3,3,3,3,2, + 2,2,2,2,0,0,0,0,0,0, + 0,0,0,1,1,1,1,1,1,1, + 3,3,3,2,2,2,2,2,0,0, + 0,0,0,0,0,0,0,1,1,1, + 1,1,1,1,1,1,1,0,0,0, + 0,0,0,0,0,0,0,0,2,2, + 2,3,3,3,3,3,1,1,1,1, + 1,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,1,1,1,1,1, + 1,1,3,3,3,2,2,2,2,2, + 0,0,0,0,0,0,0,0,0,1, + 1,1,1,1,1,1,1,1,1,0, + 0,0,0,0,0,0,0,0,0,0, + 0,2,2,3 + }; + + const unsigned char buell_oddfire_cam[] PROGMEM = + { /* Buell oddfire cam wheel */ + /* Wheel is a cam wheel (degress are in crank degrees + * 36 deg high, 54 deg low, + * 36 deg high, 54 deg low, + * (Rear at TDC) 36 deg high, + * 1889 deg low, 36 deg high + * 54 deg low, 36 deg high, + * 54 deg low, (Front at TDC), + * 36 deg high, 99 deg low + */ + 1,1,1,1,0,0,0,0,0,0, /* Tooth 1 (36 deg) and 54 deg space */ + 1,1,1,1,0,0,0,0,0,0, /* Tooth 2 (36 deg) and 54 deg space */ + 1,1,1,1,0,0,0,0,0,0, /* Tooth 3 (36 deg) and begin of 189 deg space */ + 0,0,0,0,0,0,0,0,0,0, /* Part of 189 deg space */ + 0,0,0,0,0,1,1,1,1,0, /* Tail of 189 deg space, 36 deg tooth, begin of 54 deg space */ + 0,0,0,0,0,1,1,1,1,0, /* Tail of 54 deg space, 36 deg tooth, begin of 54 deg space */ + 0,0,0,0,0,1,1,1,1,0, /* Tail of 54 deg space, last 36 deg tooth, begin of 99 deg space */ + 0,0,0,0,0,0,0,0,0,0 /* Tail of 99 deg space */ + }; + + const unsigned char gm_ls1_crank_and_cam[] PROGMEM = + { /* GM LS1 24 tooth crank snd 1 tooth cam */ + /* 12 deg low, 3 deg high, 3 deg low, + * 12 deg high, 3deg low, 12 deg high, + * 3 deg low, 12 deg high, 3 deg low, + * 12 deg high, 3 deg low, 12 deg high, + * 12 deg low, 3 deg high, 3 deg low, + * 12 deg high, 3 deg low, 12 deg high, + * 3 deg low, 12 deg high, 12 deg low, + * 3 deg high, 12 deg low, 3 deg high, + * 3 deg low, 12 deg high, 3 deg low, + * 12 deg high, 12 deg low, 3 deg high, + * 12 deg low, 3 deg high, 12 deg low, + * 3 deg high, 12 deg low, 3 deg high, + * 3 deg low, 12 deg high, 12 deg low, + * 3 deg high, 3 deg low, 12 deg high, + * 12 deg low, 3 deg high, 12 deg low, + * 3 deg high, 12 deg low, 3 deg high + * Second rotation is the SAME pattern + * with cam signal held high for 360 + * crank degrees */ + 4,0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,0,0,1,1, + 1,1,1,1,1,1,1,1,1,1,0,0,0,1,1,1,1,1,1,1, + 1,1,1,1,1,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1, + 0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,1,1, + 1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0, + 0,0,1,1,1,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1, + 0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,1,1, + 1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0, + 0,0,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1, + 0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,1,1, + 1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0, + 0,0,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1, + 0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,0,0,1,1, + 1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0, + 0,0,1,1,1,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1, + 0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0, + 0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,0,0, + 0,0,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1, + 2,2,2,2,2,2,2,2,2,2,2,2,3,3,3,2,2,2,3,3, /* Second rotation with */ + 3,3,3,3,3,3,3,3,3,3,2,2,2,3,3,3,3,3,3,3, /* Cam tooth enabled */ + 3,3,3,3,3,2,2,2,3,3,3,3,3,3,3,3,3,3,3,3, + 2,2,2,3,3,3,3,3,3,3,3,3,3,3,3,2,2,2,3,3, + 3,3,3,3,3,3,3,3,3,3,2,2,2,2,2,2,2,2,2,2, + 2,2,3,3,3,2,2,2,3,3,3,3,3,3,3,3,3,3,3,3, + 2,2,2,3,3,3,3,3,3,3,3,3,3,3,3,2,2,2,3,3, + 3,3,3,3,3,3,3,3,3,3,2,2,2,2,2,2,2,2,2,2, + 2,2,3,3,3,2,2,2,2,2,2,2,2,2,2,2,2,3,3,3, + 2,2,2,3,3,3,3,3,3,3,3,3,3,3,3,2,2,2,3,3, + 3,3,3,3,3,3,3,3,3,3,2,2,2,2,2,2,2,2,2,2, + 2,2,3,3,3,2,2,2,2,2,2,2,2,2,2,2,2,3,3,3, + 2,2,2,2,2,2,2,2,2,2,2,2,3,3,3,2,2,2,3,3, + 3,3,3,3,3,3,3,3,3,3,2,2,2,2,2,2,2,2,2,2, + 2,2,3,3,3,2,2,2,3,3,3,3,3,3,3,3,3,3,3,3, + 2,2,2,2,2,2,2,2,2,2,2,2,3,3,3,2,2,2,2,2, + 2,2,2,2,2,2,2,3,3,3,2,2,2,2,2,2,2,2,2,2, + 2,2,3,3,3,2,2,2,2,2,2,2,2,2,2,2,2,3,3,3, + }; + + /* Lotus 36-1-1-1-1 wheel, missing teeth at + * 36,32,17 and 14 + */ + const unsigned char lotus_thirty_six_minus_one_one_one_one[] PROGMEM = + { /* 36-1 */ + 1,0,1,0,1,0,1,0,1,0, /* teeth 1-5 */ + 1,0,1,0,1,0,1,0,1,0, /* teeth 6-10 */ + 1,0,1,0,1,0,0,0,1,0, /* teeth 11-15 */ + 1,0,0,0,1,0,1,0,1,0, /* teeth 16-20 */ + 1,0,1,0,1,0,1,0,1,0, /* teeth 21-25 */ + 1,0,1,0,1,0,1,0,1,0, /* teeth 26-30 */ + 1,0,0,0,1,0,1,0,1,0, /* teeth 31-35 */ + 0,0 /* MISSING 36th tooth */ + }; + const unsigned char honda_rc51_with_cam[] PROGMEM = + { /* Honda RC51 oddfire 90deg Vtwin with cam */ + 0,1,0,1,0,1,0,1,0,1, /* teeth 1-5 */ + 0,3,0,1,0,1,0,1,0,1, /* teeth 6-10, cam triggers on tooth 6 */ + 0,1,0,1, /* Teeth 11-12 */ + 0,1,0,1,0,1,0,3,0,1, /* 2nd rotation, teeth 1-5 (13-17), cam trigger on tooth 4(16)*/ + 0,3,0,1,0,1,0,1,0,1, /* teeth 6-10 (18-22), cam trigger on tooth 18 */ + 0,1,0,1 /* teeth 11-12, (23-24) */ + }; + + /* 36-1 with second trigger pulse across teeth 33-34 on first rotation */ + const unsigned char thirty_six_minus_one_with_second_trigger[] PROGMEM = + { /* 36-1 */ + 1,0,1,0,1,0,1,0,1,0, /* Teeth 1-5 */ + 1,0,1,0,1,0,1,0,1,0, /* Teeth 6-10 */ + 1,0,1,0,1,0,1,0,1,0, /* Teeth 11-15 */ + 1,0,1,0,1,0,1,0,1,0, /* Teeth 16-20 */ + 1,0,1,0,1,0,1,0,1,0, /* Teeth 21-25 */ + 1,0,1,0,1,0,1,0,1,0, /* Teeth 26-30 */ + 1,0,1,0,3,2,3,2,1,0, /* Teeth 31-35, second trigger during 33-34 */ + 0,0, /* 36th tooth MISSING */ + 1,0,1,0,1,0,1,0,1,0, /* Revolution 2 Teeth 1-5 */ + 1,0,1,0,1,0,1,0,1,0, /* Teeth 6-10 */ + 1,0,1,0,1,0,1,0,1,0, /* Teeth 11-15 */ + 1,0,1,0,1,0,1,0,1,0, /* Teeth 16-20 */ + 1,0,1,0,1,0,1,0,1,0, /* Teeth 21-25 */ + 1,0,1,0,1,0,1,0,1,0, /* Teeth 26-30 */ + 1,0,1,0,1,0,1,0,0,0, /* Teeth 31-35 */ + 0,0 /* 36th MISSING tooth */ + }; + + const unsigned char thirty_six_minus_one_plus_one_with_cam_ngc4[] PROGMEM = + { /* 36-1+1 NGC-4 needs 1 deg resolution, chrysler 2.0/2.4 engines + * cam edges are at 26,62,98,134,170,314,350,368,422,458,494,530,674 and 710 dev + * crank is 36-1 with alarge window at one end 2.5 teeth cycles (25 deg) wide and alosed + * at 180deg apart for 2 teeth cycles (20 deg) + */ + /* Crankshaft degrees + 1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 33 35 37 39 41 */ + 0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,3,3,3,3,3,2,2,2,2,2,3,3,3,3,3, /* degrees */ + 2,2,2,2,2,3,3,3,3,3,2,2,2,2,2,3,3,3,3,3,2,0,0,0,0,1,1,1,1,1,0,0,0,0,0,1,1,1,1,1, /* 41-80 */ + 0,0,0,0,0,1,1,1,1,1,0,0,0,0,0,1,1,3,3,3,2,2,2,2,2,3,3,3,3,3,2,2,2,2,2,3,3,3,3,3, /* 81-120 */ + 2,2,2,2,2,3,3,3,3,3,2,2,2,0,0,1,1,1,1,1,0,0,0,0,0,1,1,1,1,1,0,0,0,0,0,1,1,1,1,1, /* 121-160 */ + 0,0,0,0,0,1,1,1,1,3,2,2,2,2,2,3,3,3,3,3,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2, /* 161-200 */ + 2,2,2,2,2,3,3,3,3,3,2,2,2,2,2,3,3,3,3,3,2,2,2,2,2,3,3,3,3,3,2,2,2,2,2,3,3,3,3,3, /* 201-240 */ + 2,2,2,2,2,3,3,3,3,3,2,2,2,2,2,3,3,3,3,3,2,2,2,2,2,3,3,3,3,3,2,2,2,2,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; + + + const unsigned char weber_iaw_with_cam[] PROGMEM = + { /*Weber marelli (Cosworth/Lancia) from jimstim + 80 deg low, 10 deg high, Tooth 1 + 20 deg low, 45 deg cam pulse, 15 deg low, 10 deg high, Cam tooth 1 and crank tooth 2 + 80 deg low, 10 deg high, Crank tooth 3 + 20 deg low, 45 deg cam pulse, 15 deg low, 10 deg high, Cam tooth2 and crank tooth 4 + 80 deg low, 10 deg high, Crank tooth 5 + 80 deg low, 10 deg high Crank tooth 6 + 80 deg low, 10 deg high, Crank tooth 7 + 80 deg low, 10 deg high Crank tooth 8 */ + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,2,2,2,2,0,0,0,0,0,0,0,0,1,1, /* Teeth 1 and 2 & cam1 */ + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,2,2,2,2,0,0,0,0,0,0,0,0,1,1, /* Teeth 3 and 4 & cam2 */ + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1, /* Teeth 5 and 6 */ + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1 /* Teeth 7 and 8 */ + }; + + const unsigned char fiat_one_point_eight_sixteen_valve_with_cam[] PROGMEM = + { + /* Starting from TDC #1 + * Cam is high for 40 deg, low for 20, high 170deg, low for 170, high for 20, + * low for 170, then high for 130 + * Crank is low for 97, high for 5, low for 27, high for 5, low for 50, high for 5, + * low for 102, high for 5, low for 27, high for 5, low for 50, high for 5, + * low for 102, high for 5, low for 27, high for 5, low for 50, high for 5, + * low for 102, high for 5, low for 27, high for 5, low for 50, high for 5, low for 5 + * http://msextra.com/doc/triggers/fiat1.8-16v.jpg + */ + /* Crankshaft degrees + 1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 33 35 37 39 */ + 2,2,2,2,2,2,2,2,2,2,2,2,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0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,2,2,2,2,2,2,2,2,2, + 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,3,3,3,3,3,2,2,2,2,2,2,2,2,2,2,2,2, + 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,3,3,3,3,3,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2, + 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,3,3,3,3,3,2,2,2,2,2 + }; + + const unsigned char three_sixty_nissan_cas[] PROGMEM = + /* This version has the 360 teeth on the cam + { + 1,2,0,2,0,2,0,2,0,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3, // 1-40 deg + 1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3, // 41-80 deg + 1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3, // 81-120 deg + 1,2,0,2,0,2,0,2,0,2,0,2,0,2,0,2,0,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3, // 121-160 deg + 1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3, // 161-200 deg + 1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3, // 201-240 deg + 1,2,0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,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3, // 681-720 deg + };*/ + { + /* Home teeth every 120 degrees in increasing widths (8,16,24,32,40,48) */ + /* Crankshaft degrees + 1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 33 35 37 39 */ + 2,1,0,1,0,1,0,1,0,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3, /* 1-40 deg */ + 2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3, /* 41-80 deg */ + 2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3, /* 81-120 deg */ + 2,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3, /* 121-160 deg */ + 2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3, /* 161-200 deg */ + 2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3, /* 201-240 deg */ + 2,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3, /* 241-280 deg */ + 2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3, /* 281-320 deg */ + 2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3, /* 321-360 deg */ + 2,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,3,2,3,2,3,2,3, /* 361-400 deg */ + 2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3, /* 401-340 deg */ + 2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3, /* 441-480 deg */ + 2,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1, /* 481-520 deg */ + 0,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3, /* 521-560 deg */ + 2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3, /* 561-600 deg */ + 2,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1, /* 601-640 deg */ + 0,1,0,1,0,1,0,1,0,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3, /* 641-680 deg */ + 2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3,2,3, /* 681-720 deg */ + }; + + const unsigned char twenty_four_minus_two_with_second_trigger[] PROGMEM = + { + /* See http://postimg.org/image/pcwkrxktx/, 24-2 inner ring, single outer pulse */ + 1,0,0,1,0,0,1,0,0,1,0,0,1,0,0,1,0,0,1,0,0,1,0,0,1,0,0,1,0,0,3,2,2,2,2,2, /* 11 teeth then outer and missing */ + 3,0,0,1,0,0,1,0,0,1,0,0,1,0,0,1,0,0,1,0,0,1,0,0,1,0,0,1,0,0,1,0,0,0,0,0, /* 11 more teeth then missing */ + }; + + /* eight tooth with 1 tooth cam */ + const unsigned char yamaha_eight_tooth_with_cam[] PROGMEM = + { /* Yamaha R1 (02-03) 8 tooth crank with 1 tooth cam */ + 0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,1, /* Teeth 1-4, 11.25 deg per step */ + 0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,1, /* teeth 5-8 */ + 0,2,2,3,2,0,0,1,0,0,0,1,0,0,0,1, /* Cam tooth on 9 */ + 0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,1 /* Teeth 13-16 */ + }; + + /* 50% dutycle, 4 tooth + 1 cam */ + const unsigned char gm_four_tooth_with_cam[] PROGMEM = + { /* 4 cylinder with 1 cam pulse for 360 crank degrees */ + 1,0,1,0,3,2,3,2 /* two pulses per crank revolution (one per cylinder) */ + }; + + /* 50% dutycle, 6 tooth + 1 cam */ + const unsigned char gm_six_tooth_with_cam[] PROGMEM = + { /* 6 cylinder with 1 cam pulse for 360 crank degrees */ + 1,0,1,0,1,0,3,2,3,2,3,2 /* three pulses per crank revolution (one per cylinder) */ + }; + + /* 50% dutycle, 8 tooth + 1 cam */ + const unsigned char gm_eight_tooth_with_cam[] PROGMEM = + { /* 8 cylinder with 1 cam pulse for 360 crank degrees */ + 1,0,1,0,1,0,1,0,3,2,3,2,3,2,3,2 /* four pulses per crank revolution (one per cylinder) */ + }; + + const unsigned char volvo_d12acd_with_cam[] PROGMEM = + { /* Volvo 6 cylinder dieslet 17-1-17-1-17-1 (60 overall teeth) */ + 0,1,1,1,0,1,1,1,0,1,1,1,0,1,1,1, /* Teeth 1-4 */ + 0,1,1,1,0,1,1,1,0,1,1,1,0,1,1,1, /* Teeth 5-8 */ + 0,1,1,1,0,1,1,1,0,1,1,1,0,1,1,1, /* Teeth 9-12 */ + 2,1,1,1,0,1,1,1,0,1,1,1,0,1,1,1, /* Teeth 13-16 */ + 0,1,1,1,2,1,1,1,1,1,1,1,1,1,1,1, /* Teeth 17-20 1 normal, 1 long (3 teeth wide) */ + 0,1,1,1,0,1,1,1,0,1,1,1,0,1,1,1, /* Teeth 21-24 */ + 0,1,1,1,0,1,1,1,0,1,1,1,0,1,1,1, /* Teeth 25-28 */ + 0,1,1,1,0,1,1,1,0,1,1,1,0,1,1,1, /* Teeth 29-32 */ + 0,1,1,1,0,1,1,1,0,1,1,1,0,1,1,1, /* Teeth 33-36 */ + 0,1,1,1,2,1,1,1,1,1,1,1,1,1,1,1, /* Teeth 37-40 1 normal, 1 long (3 teeth wide) */ + 0,1,1,1,0,1,1,1,0,1,1,1,0,1,1,1, /* Teeth 41-44 */ + 0,1,1,1,0,1,1,1,0,1,1,1,0,1,1,1, /* Teeth 45-48 */ + 0,1,1,1,0,1,1,1,0,1,1,1,0,1,1,1, /* Teeth 49-52 */ + 0,1,1,1,0,1,1,1,0,1,1,1,0,1,1,1, /* Teeth 53-56 */ + 0,1,1,1,2,1,1,1,1,1,1,1,1,1,1,1, /* Teeth 57-60 1 normal, 1 long (3 teeth wide) */ + 0,1,1,1,0,1,1,1,0,1,1,1,0,1,1,1, /* Teeth 1-4 */ + 0,1,1,1,0,1,1,1,0,1,1,1,0,1,1,1, /* Teeth 5-8 */ + 0,1,1,1,0,1,1,1,0,1,1,1,0,1,1,1, /* Teeth 9-12 */ + 0,1,1,1,0,1,1,1,0,1,1,1,0,1,1,1, /* Teeth 13-16 */ + 0,1,1,1,2,1,1,1,1,1,1,1,1,1,1,1, /* Teeth 17-20 1 normal, 1 long (3 teeth wide) */ + 0,1,1,1,0,1,1,1,0,1,1,1,0,1,1,1, /* Teeth 21-24 */ + 0,1,1,1,0,1,1,1,0,1,1,1,0,1,1,1, /* Teeth 25-28 */ + 0,1,1,1,0,1,1,1,0,1,1,1,0,1,1,1, /* Teeth 29-32 */ + 0,1,1,1,0,1,1,1,0,1,1,1,0,1,1,1, /* Teeth 33-36 */ + 0,1,1,1,2,1,1,1,1,1,1,1,1,1,1,1, /* Teeth 37-40 1 normal, 1 long (3 teeth wide) */ + 0,1,1,1,0,1,1,1,0,1,1,1,0,1,1,1, /* Teeth 41-44 */ + 0,1,1,1,0,1,1,1,0,1,1,1,0,1,1,1, /* Teeth 45-48 */ + 0,1,1,1,0,1,1,1,0,1,1,1,0,1,1,1, /* Teeth 49-52 */ + 0,1,1,1,0,1,1,1,0,1,1,1,0,1,1,1, /* Teeth 53-56 */ + 0,1,1,1,2,1,1,1,1,1,1,1,1,1,1,1, /* Teeth 57-60 1 normal, 1 long (3 teeth wide) */ + }; + const unsigned char mazda_thirty_six_minus_two_two_two_with_six_tooth_cam[] PROGMEM = + { /* Mazda 36-2-2-2 with 6 tooth cam */ + 1,1,0,0,0, 1,1,0,0,0, 1,1,0,0,0, /* Teeth 1-3*/ + 1,1,0,0,0, 1,1,0,0,0, 1,1,0,0,0, /* Teeth 4-6*/ + 1,1,0,0,0, 1,3,2,2,2, 3,3,2,2,2, /* Teeth 7-9 , second trigger on tooth 9 */ + 3,1,0,0,0, 1,1,0,0,0, 0,0,0,0,0, /* Teeth 10,11, missing 12 */ + 0,0,0,0,0, 1,3,2,2,2, 2,2,2,2,2, /* Missing 13, 14, Missing 15 , second trigger on missing tooth 15 */ + 2,0,0,0,0, 1,1,0,0,0, 1,1,0,0,0, /* Missing 16, 17-18m 2nd trigger ends on tooth 16 */ + 1,1,0,0,0, 1,1,0,0,0, 1,1,0,0,0, /* Teeth 19-21 */ + 1,1,0,0,0, 1,1,0,0,0, 1,1,0,0,0, /* Teeth 22-24 */ + 1,1,0,0,0, 1,3,2,2,2, 3,3,2,2,2, /* Teeth 25-27, second trigger on tooth 26-27 */ + 3,1,0,0,0, 1,1,0,0,0, 0,0,0,0,0, /* Teeth 28-29, missing 30 */ + 0,0,0,0,0, 1,3,2,2,2, 3,3,2,2,2, /* Missing 31, Tooth 32, 33, 2nd trigger within tooth 32 */ + 3,1,0,0,0, 1,1,0,0,0, 1,1,0,0,0, /* Teeth 34-36, 2nd trigger ends just after tooth 32 starts*/ + /* SECOND ROTATION */ + 1,1,0,0,0, 1,1,0,0,0, 1,1,0,0,0, /* Teeth 1-3 */ + 1,1,0,0,0, 1,1,0,0,0, 1,1,0,0,0, /* Teeth 4-6 */ + 1,1,0,0,0, 1,1,0,0,0, 1,1,0,0,0, /* Teeth 7-9 */ + 1,1,0,0,0, 1,1,0,0,0, 0,0,0,0,0, /* Teeth 10,11, missing 12 */ + 0,0,0,0,0, 1,3,2,2,2, 2,2,2,2,2, /* Missing 13, 14, Missing 15 , second trigger on 14-15 */ + 2,0,0,0,0, 1,1,0,0,0, 1,1,0,0,0, /* Missing 16, 17-18 */ + 1,1,0,0,0, 1,1,0,0,0, 1,1,0,0,0, /* Teeth 19-21 */ + 1,1,0,0,0, 1,1,0,0,0, 1,1,0,0,0, /* Teeth 22-24 */ + 1,1,0,0,0, 1,1,0,0,0, 1,1,0,0,0, /* Teeth 25-27 */ + 1,1,0,0,0, 1,1,0,0,0, 0,0,0,0,0, /* Teeth 28-29, missing 30 */ + 0,0,0,0,0, 1,3,2,2,2, 3,3,2,2,2, /* Missing 31,Tooth 32-33, 2nd trigger on 32-33*/ + 3,1,0,0,0, 1,1,0,0,0, 1,1,0,0,0, /* Teeth 34-36, 2nd trigger ends jsut after tooth 34 starts */ +}; + + /* Mitsubish 4g63 aka 4/2 crank and cam */ + const unsigned char mitsubishi_4g63_4_2[] PROGMEM = + { //Split into 5 degree blocks (12 per line) + 2,2,2,2,2,2,2,2,2,2,2,0, + 0,0,0,0,0,0,0,0,0,1,1,1, //Start edge 6 + 1,1,1,1,1,1,1,1,1,1,1,0, + 0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,2,2,2,3,3,3, + 3,3,3,3,3,3,3,3,1,1,1,0, + 0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,1,1,1, + 1,1,1,1,1,1,1,1,1,1,1,0, + 0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0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0,1,1,0,0,1,1,0,0,1,1, + 0,0,1,1,0,0,1,1,0,0,1,1,0,0,1,1,0,0, + 1,1,0,0,1,1,0,0,1,1,0,0,1,1,0,0,1,1, + 0,0,1,1,0,0,1,1,0,0,1,1,0,0,1,1,0,0, + 1,1,0,0,1,1,0,0,1,1,0,0,1,1,0,0,1,1, + 0,0,1,1,0,0,1,1,0,0,1,1,0,0,1,1,0,0, + 1,1,0,0,1,1,0,0,1,1,0,0,1,1,0,0,1,1, + 0,0,1,1,0,0,1,1,0,0,1,1,0,0,1,1,0,0, + 1,1,0,0,1,1,0,0,1,1,0,0,1,1,0,0,1,1, + 0,0,1,1,0,0,1,1,0,0,1,1,0,0,1,1,0,2, + + }; + + /* Honda D17 12+1. 5 degree per entry*/ + const unsigned char honda_d17_no_cam[] PROGMEM = + { //0 - 360 degrees + 1,0,0,0,0,0,1,0,0,0,0,0, + 1,0,0,0,0,0,1,0,0,0,0,0, + 1,0,0,0,0,0,1,0,0,0,0,0, + 1,0,0,0,0,0,1,0,0,0,0,0, + 1,0,0,0,0,0,1,0,0,0,0,0, + 1,0,0,0,0,0,1,0,1,0,0,0, + + //360 - 720 + 1,0,0,0,0,0,1,0,0,0,0,0, + 1,0,0,0,0,0,1,0,0,0,0,0, + 1,0,0,0,0,0,1,0,0,0,0,0, + 1,0,0,0,0,0,1,0,0,0,0,0, + 1,0,0,0,0,0,1,0,0,0,0,0, + 1,0,0,0,0,0,1,0,1,0,0,0 + + }; + + /* + * http://imgur.com/a/ynLWp + */ + const unsigned char mazda_323_au[] PROGMEM = + { + 0,0,0,0,0,2,0,0,1,0,0,0, + 0,0,1,0,0,0,0,0,2,0,2,1, + 0,0,0,0,0,1 + }; + + /* + * http://www.msextra.com/doc/triggers/daihatsu-trigs.txt + * http://www.msextra.com/doc/triggers/daihatsu3cyla.jpg + * http://jbperf.com/JimStim/wheels_default.jsw + * 5 degree per entry + * + */ + const unsigned char daihatsu_3cyl[] PROGMEM = + { //0 - 360 degrees + 1,1,0,0,0,0,1,1,0,0,0,0, //0-60. Primary pulse plus the additional 1 at 15 crank degrees / 30 cam degrees + 0,0,0,0,0,0,0,0,0,0,0,0, //60-120 + 0,0,0,0,0,0,0,0,0,0,0,0, //120-180 + 0,0,0,0,0,0,0,0,0,0,0,0, //180-240 + 1,1,0,0,0,0,0,0,0,0,0,0, //240-300 + 0,0,0,0,0,0,0,0,0,0,0,0, //300-360 + + //360 - 720 + 0,0,0,0,0,0,0,0,0,0,0,0, //360-420 + 0,0,0,0,0,0,0,0,0,0,0,0, //420-480 + 1,1,0,0,0,0,0,0,0,0,0,0, //480-540 + 0,0,0,0,0,0,0,0,0,0,0,0, //540-600 + 0,0,0,0,0,0,0,0,0,0,0,0, //600-660 + 0,0,0,0,0,0,0,0,0,0,0,0 //660-720 + }; + + /* Mitsubish 4g63 aka 4/2 crank and cam */ + const unsigned char miata_9905[] PROGMEM = + { //Split into 5 degree blocks (12 per line) + 0,0,0,0,0,0,2,2,0,0,0,0, //Single cam tooth + 0,0,0,0,0,0,0,1,1,0,0,0, //Pulse at 100* + 0,0,0,0,0,0,0,0,0,1,1,0, //Pulse at 170* + 0,0,0,0,0,0,0,0,0,0,0,0, //No pulse + 0,0,0,0,0,0,0,1,1,0,0,0, //Pulse at 280* + 0,0,0,0,0,0,0,0,0,1,1,0, //Pulse at 350* + 0,0,2,2,0,0,2,2,0,0,0,0, //Double cam pulses + 0,0,0,0,0,0,0,1,1,0,0,0, //Pulse at 460* + 0,0,0,0,0,0,0,0,0,1,1,0, //Pulse at 530* + 0,0,0,0,0,0,0,0,0,0,0,0, //No pulse + 0,0,0,0,0,0,0,1,1,0,0,0, //Pulse at 640 + 0,0,0,0,0,0,0,0,0,1,1,0 //Pulse at 710 + }; + + /* 25 deg low, 5 deg high, #12 is missing, cam is high for 25 deg on second crank rotation just after tooth 21 (9) */ + const unsigned char twelve_with_cam[] PROGMEM = + { /* 12-1 with cam */ + 0,0,0,0,0,1,0,0,0,0,0,1, /* Teeth 1 and 2 */ + 0,0,0,0,0,1,0,0,0,0,0,1, /* Teeth 3 and 4 */ + 0,0,0,0,0,1,0,0,0,0,0,1, /* Teeth 5 and 6 */ + 0,0,0,0,0,1,0,0,0,0,0,1, /* Teeth 7 and 8 */ + 0,0,0,0,0,1,0,0,0,0,0,1, /* Teeth 9 and 10 */ + 0,0,0,0,0,1,0,0,0,0,0,1, /* Tooth 11 and 12 */ + 0,0,0,0,0,1,0,0,0,0,0,1, /* 2nd rotation: Teeth 13 and 14 */ + 0,0,0,0,0,1,0,0,0,0,0,1, /* Teeth 15 and 16 */ + 0,0,0,0,0,1,0,0,0,0,0,1, /* Teeth 17 and 18 */ + 0,0,0,0,0,1,0,0,0,0,0,1, /* Teeth 19 and 20 */ + 0,0,0,0,0,1,2,2,2,2,2,1, /* Tooth 21 and 22, 2nd trigger on cam between teeth 21 and 22 for 25 deg */ + 0,0,0,0,0,1,0,0,0,0,0,1 /* Totth 23 and 24th */ + }; + + /* 25 deg low, 5 deg high, #12 is missing, cam is high for 25 deg on second crank rotation just after tooth 21 (9) */ + const unsigned char twenty_four_with_cam[] PROGMEM = + { /* 24/1 with cam */ + 0,0,1,0,0,1,0,0,1,0,0,1, /* Teeth 1 and 2 */ + 0,0,1,0,0,1,0,0,1,0,0,1, /* Teeth 3 and 4 */ + 0,0,1,0,0,1,0,0,1,0,0,1, /* Teeth 5 and 6 */ + 0,0,1,0,0,1,0,0,1,0,0,1, /* Teeth 7 and 8 */ + 0,0,1,0,0,1,0,0,1,0,0,1, /* Teeth 9 and 10 */ + 0,0,1,0,0,1,0,0,1,0,0,1, /* Tooth 11 and 12 */ + 0,0,1,0,0,1,0,0,1,0,0,1, /* 2nd rotation: Teeth 13 and 14 */ + 0,0,1,0,0,1,0,0,1,0,0,1, /* Teeth 15 and 16 */ + 0,0,1,0,0,1,0,0,1,0,0,1, /* Teeth 17 and 18 */ + 0,0,1,0,0,1,0,0,1,0,0,1, /* Teeth 19 and 20 */ + 0,0,1,0,0,1,2,2,3,2,2,1, /* Tooth 21 and 22, 2nd trigger on cam between teeth 21 and 22 for 25 deg */ + 0,0,1,0,0,1,0,0,1,0,0,1 /* Totth 23 and 24th */ + }; + + const unsigned char subaru_six_seven[] PROGMEM = + { /* 6/7 */ + /* Cyl 1 TDC */ + 0,0,0,0,0,2,2,2,0,0, 0,2,2,2,0,0,0,2,2,2, /* 00-19 degrees - cam 1-2-3: 5* ATDC */ + 0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0, /* 20-39 degrees */ + 0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0, /* 40-59 degrees */ + 0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0, /* 60-20 degrees */ + 0,0,0,1,1,1,0,0,0,0, 0,0,0,0,0,0,0,0,0,0, /* 80-99 degrees - crank 1: 83* ATDC */ + 0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,1,1,1,0,0, /* 100 degrees - crank 2: 115* ATDC */ + 0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0, /* 120 degrees */ + 0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0, /* 140 degrees */ + 0,0,0,0,0,0,0,0,0,0, 1,1,1,0,0,0,0,0,0,0, /* 160 degrees - crank 3: 170* ATDC */ + + /* Cyl 2 TDC */ + 0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0, /* 180 degrees */ + 2,2,2,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0, /* 200 degrees - cam 4: 20* ATDC (200*) */ + 0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0, /* 220 degrees */ + 0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0, /* 240 degrees */ + 0,0,0,1,1,1,0,0,0,0, 0,0,0,0,0,0,0,0,0,0, /* 260 degrees - crank 4: 83* ATDC (263*) */ + 0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,1,1,1,0,0, /* 280 degrees - crank 5: 115* ATDC (295*) */ + 0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0, /* 300 degrees */ + 0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0, /* 320 degrees */ + 0,0,0,0,0,0,0,0,0,0, 1,1,1,0,0,0,0,0,0,0, /* 340 degrees - crank 6: 170* ATDC (350*) */ + + /* Cyl 3 TDC */ + 0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0, /* 360 degrees */ + 2,2,2,0,0,0,2,2,2,0, 0,0,0,0,0,0,0,0,0,0, /* 380 degrees - cam 5-6: 20* ATDC (380*) */ + 0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0, /* 400 degrees */ + 0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0, /* 420 degrees */ + 0,0,0,1,1,1,0,0,0,0, 0,0,0,0,0,0,0,0,0,0, /* 440 degrees - crank 1: 83* ATDC (443*) */ + 0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,1,1,1,0,0, /* 460 degrees - crank 2: 115* ATDC (475*) */ + 0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0, /* 480 degrees */ + 0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0, /* 500 degrees */ + 0,0,0,0,0,0,0,0,0,0, 1,1,1,0,0,0,0,0,0,0, /* 520 degrees - crank 3: 170* ATDC */ + + /* Cyl 4 TDC */ + 0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0, /* 540 degrees */ + 2,2,2,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0, /* 560 degrees - cam 7: 20* ATDC (560*) */ + 0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0, /* 580 degrees */ + 0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0, /* 600 degrees */ + 0,0,0,1,1,1,0,0,0,0, 0,0,0,0,0,0,0,0,0,0, /* 620 degrees - crank 4: 83* ATDC (623*) */ + 0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,1,1,1,0,0, /* 640 degrees - crank 5: 115* ATDC (655*) */ + 0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0, /* 660 degrees */ + 0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0, /* 680 degrees */ + 0,0,0,0,0,0,0,0,0,0, 1,1,1,0,0,0,0,0,0,0 /* 700 degrees - crank 6: 170* ATDC (710*) */ + }; + + /* GM 7X for 6 cylinder engines */ + /* https://speeduino.com/forum/download/file.php?id=4743 */ + const unsigned char gm_seven_x[] PROGMEM = + { /* Every number represents 2 degrees */ + 0,0,0,0,0,0,0,0,0,0, /* Degrees 0-20 */ + 0,0,0,0,0,0,0,0,0,0, /* Degrees 20-40 */ + 0,1,1,0,0,0,0,0,0,0, /* Degrees 40-60. Tooth #1 at 42* for 4* duration. These are actually 5* duration, but close enough */ + 0,0,0,0,0,0,0,0,0,0, /* Degrees 60-80 */ + 0,0,0,0,0,0,0,0,0,0, /* Degrees 80-100 */ + 0,1,1,0,0,0,1,1,0,0, /* Degrees 100-120. Tooth #2 at 102* for 4* duration. "Extra" tooth at 112* */ + 0,0,0,0,0,0,0,0,0,0, /* Degrees 120-140 */ + 0,0,0,0,0,0,0,0,0,0, /* Degrees 140-160 */ + 0,1,1,0,0,0,0,0,0,0, /* Degrees 160-180. Tooth #3 at 162* for 4* duration */ + 0,0,0,0,0,0,0,0,0,0, /* Degrees 180-200 */ + 0,0,0,0,0,0,0,0,0,0, /* Degrees 200-220 */ + 0,1,1,0,0,0,0,0,0,0, /* Degrees 220-240. Tooth #4 at 222* for 4* duration */ + 0,0,0,0,0,0,0,0,0,0, /* Degrees 240-260 */ + 0,0,0,0,0,0,0,0,0,0, /* Degrees 260-280 */ + 0,1,1,0,0,0,0,0,0,0, /* Degrees 280-300. Tooth #5 at 282* for 4* duration */ + 0,0,0,0,0,0,0,0,0,0, /* Degrees 300-320 */ + 0,0,0,0,0,0,0,0,0,0, /* Degrees 320-340 */ + 0,1,1,0,0,0,0,0,0,0 /* Degrees 340-360. Tooth #6 at 342* for 4* duration */ + }; + + /* DSM 420a Eclipse */ + /* https://github.com/noisymime/speeduino/issues/133 */ + const unsigned char four_twenty_a[] PROGMEM = + { /* Every number represents 5 degrees */ + 0,0,0,0,0,0,0,0,0,0,0,2, + 2,2,2,2,2,2,2,2,2,3,3,2, + 2,3,3,2,2,3,3,2,2,3,3,2, + 2,2,2,2,2,0,0,0,0,0,0,1, + 1,1,1,1,1,1,1,1,1,1,1,0, + 0,1,1,0,0,1,1,0,0,1,1,0, + 0,0,0,0,0,0,0,0,0,0,0,2, + 2,2,2,2,2,2,2,2,2,3,3,2, + 2,3,3,2,2,3,3,2,2,3,3,2, + 2,2,2,2,2,2,2,2,2,2,2,3, + 3,3,3,3,3,1,1,1,1,1,1,0, + 0,1,1,0,0,1,1,0,0,1,1,0 + }; + + const unsigned char ford_st170[] PROGMEM = + { + 0,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,0,0,0,0,0,1,1,1,1,1,0,0,0,0,0, + 1,1,1,1,1,0,0,0,0,1,1,1,1,1,0,0,0,0,0,1,1,1,1,1,0,0,0,0,0,3,3,3,3,3,2,2,2,2,2,3, + 3,3,3,3,2,2,2,2,2,3,3,3,3,3,2,2,2,2,2,3,3,3,3,1,0,0,0,0,0,1,1,1,1,1,0,0,0,0,0,1, + 1,1,1,1,0,0,0,0,0,1,1,1,1,1,0,0,0,0,0,1,1,1,1,1,0,0,0,0,0,1,1,1,1,1,0,0,0,0,0,1, + 1,1,1,3,2,2,2,2,2,3,3,3,3,3,2,2,2,2,2,3,3,3,3,3,2,2,2,2,2,3,3,3,1,1,0,0,0,0,0,1, + 1,1,1,1,0,0,0,0,0,1,1,1,1,1,0,0,0,0,0,1,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+ }; + + const unsigned char mitsubishi_3A92[] PROGMEM = + { + 3,2,3,2,2,2,3,2,1,0,1,0, + 1,0,3,2,1,0,3,2,3,2,3,2, + 3,2,3,2,2,2,3,2,3,2,3,2, + 3,2,3,2,3,2,3,2,3,2,3,2, + 3,2,2,2,2,2,3,2,3,2,1,0, + 1,0,1,0,3,2,3,2,3,2,3,2, + 3,2,3,2,2,2,3,2,3,2,3,2, + 3,2,3,2,3,2,3,2,3,2,3,2, + 3,2,3,2,2,2,3,2,1,0,1,0, + 1,0,3,2,3,2,3,2,3,2,3,2, + 3,2,2,2,2,2,3,2,3,2,3,2, + 3,2,3,2,3,2,3,2,3,2,3,2 + }; + +/* Rover K series engine tooth patterns. 4 available. 1st isn't commoon (24-1-1). 2,3 and 4 are the most common. Don't have details on the camshaft hence a 360 degree pattern + * Pattern 1 is MEMS 1.0,1.3, 1.6 36-1-1 with the teeth grouped 17-17- with gaps (i believe) at 0 and 180 degrees. Guess VR sensor is 55 BTDC + * Pattern 2 is MEMS 1.9 36-1-1-1-1 with the teeth grouped 12-4-11-5 with gaps at 100, 180, 310 and 0. VR sensor 55DTDC + * Pattern 3 is MEMS 2.0 36-1-1-1-1 with the teeth grouped 14-3-13-2 with gaps at 30,60, 210 and 250 VR sensor 55 BTDC + * Pattern 4 is MEMS 3.0 36-1-1-1-1 with the teeth grouped 14-3-13-2 - ie same as MEMS 2.0 but the location on the wheel is different, 40 degrees sooner. VR sensor 55 BTDC + */ + + const unsigned char rover_k_mode1_thirtysix_minus_one_one [] PROGMEM = + { + 0,1,0,1,0,1,0,1,0,1, + 0,1,0,1,0,1,0,1,0,1, + 0,1,0,1,0,1,0,1,0,1, + 0,1,0,1,0,0,0,1,0,1, + 0,1,0,1,0,1,0,1,0,1, + 0,1,0,1,0,1,0,1,0,1, + 0,1,0,1,0,1,0,1,0,1, + 0,0 + }; + + const unsigned char rover_k_mode2_thirtysix_minus_one_one_one_one [] PROGMEM = + { + 0,1,0,1,0,0,0,1,0,1, + 0,1,0,1,0,0,0,1,0,1, + 0,1,0,1,0,1,0,1,0,1, + 0,1,0,1,0,1,0,1,0,0, + 0,1,0,1,0,1,0,1,0,1, + 0,0,0,1,0,1,0,1,0,1, + 0,1,0,1,0,1,0,1,0,1, + 0,1 + }; + + const unsigned char rover_k_mode3_thirtysix_minus_one_one_one_one [] PROGMEM = + { + 0,1,0,1,0,1,0,1,0,1, + 0,1,0,1,0,1,0,0,0,1, + 0,1,0,0,0,1,0,1,0,1, + 0,1,0,1,0,1,0,1,0,1, + 0,1,0,1,0,1,0,1,0,1, + 0,1,0,0,0,1,0,1,0,1, + 0,0,0,1,0,1,0,1,0,1, + 0,1 + }; + + const unsigned char rover_k_mode4_thirtysix_minus_one_one_one_one [] PROGMEM = + { + 0,1,0,1,0,1,0,1,0,1, + 0,1,0,1,0,0,0,1,0,1, + 0,0,0,1,0,1,0,1,0,1, + 0,1,0,1,0,1,0,1,0,1, + 0,1,0,1,0,1,0,1,0,1, + 0,1,0,0,0,1,0,1,0,1, + 0,0,0,1,0,1,0,1,0,1, + 0,1 + }; + + + + #endif