Nissan Timing Wheels
Having looked at the Nissan Silvia and 200SX models (S12, S13 and S14) they all use a cam driven timing wheel with a speed sensor of 2degree resolution and portals of different sizes to denote the current cylinder.
Of all the options a trigger board is a better bet - getting the thin timing wheels will prove costly and may mean that the original ECU cannot be used should the user want to revert.
Trigger board code. This is just a rough idea of how we'd count interrupts on the outside degree wheel, and produce a cylinder trigger on port D0, and a cam sync home on port D1. This code won't work (but it compiles okay) as the interrupts are not setup correctly.\n
#include <inttypes.h> #include <avr/io.h> #include <avr/interrupt.h> #include <avr/signal.h> #include <avr/wdt.h> #define CYLINDER_WINDOW_OPEN 0x02 #define CYLINDER_TRIGGER 0x01 #define CAM_HOME_SYNC 0x02 #define SIGNAL_COUNT 0x05 int windowCount; int camHomeSyncCount; int cylinderTriggerCount; void port_b0_ISR() { // check the cylinder window if (PORTB & CYLINDER_WINDOW_OPEN) { // cylinder window is open windowCount++; } else { // cylinder window is closed, check to see if it was open previously if (windowCount != 0) { // which window is it? 16, 12, 8 or 4? if (windowCount > 12) { // signal cam sync PORTD |= CAM_HOME_SYNC; camHomeSyncCount = SIGNAL_COUNT; } // signal cylinder PORTD |= CYLINDER_TRIGGER; cylinderTriggerCount = SIGNAL_COUNT; // set window count to zero windowCount = 0; } else { // we maintain the cam sync signal for its prescribed count if (camHomeSyncCount > 0) { camHomeSyncCount--; } else { PORTD &= !CAM_HOME_SYNC; } // we maintain the cylinder trigger signal for its prescribed count if (cylinderTriggerCount > 0) { cylinderTriggerCount--; } else { PORTD &= !CYLINDER_TRIGGER; } } } } void system_init() { // setup globals windowCount = 0x00; camHomeSyncCount = 0x00; cylinderTriggerCount = 0x00; // setup ports DDRB = 0xFC; // Pin 0 and pin 1 to input PORTB = 0x00; DDRD = 0xFF; // may as well make all of D output PORTD = 0x00; // enable interrupts wdt_disable(); enable_external_int(0x01); sei(); } void main() { system_init(); for(;;); // Infinite loop }