RE: New CDI - opensource project JMJ and Bigboat
I choose a IGBT I can maybe buy, but you can take any 600 V / 8 A IGBT (even een FET)
At the time be I use a BUT12A to do the job.
I make space on the PCB for C6, you never know, but I don't think you have to use him.
Into the Vellemankit is also a C (0.22uF).
BTW, you can use the Vellemankit too, connect the output of the timerboard on point 2, remove R1 and R2 and replace a dummy R (0 Ohm) for R3
Attention, you have to make some changes into the C-code if you gone use the TCI !!!
A normal sparkcoil will fire-up for 45% of the time, CDI-fire-uptime is 56us to fire-up the scr.
If your engine runs 16000 rpm, the pulstime wiilbe ~4ms for the hole puls.
If we don't change the fire-uptime, the sparkcoil isn't fire-up long enoufg.
The dutycycle we have to make is ~35 till 45% if we change the delay to 1500us
50Hz = 3000 RPM = 20ms = delay_ms(10) or delay_us(10000)
3000 rpm = delay_ms(10)
6000 rpm = delay_ms(5)
9000 rpm = delay_us(3300)
12000 rpm = delay_us(2500)
ONLY CHANGE THE RED TXT INTO YOUR CODE - DON"T COPY THE CODE BELOWE !!!
-
void test() { //Generate test signal
while (1){
PORTB &= 0xee; // sends a ground to the SCR gate
delay_us(1500); // 56 us delay (Change to 1500)
PORTB |= 0x11; // ground off the SCR
if (PORTB & 0x04) delay_ms(200); //300 rpm
else delay_ms(8); //7500 RPM
}
}
void main() {
const char tspark[]={ 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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 3, 5, 5, 7, 7, 9, 9, 10, 12, 12, 12, 14, 14, 14, 17, 17, 17, 20, 20, 20, 22, 23, 25, 25, 28, 28, 31, 31, 34, 34, 37, 38, 40, 41, 44, 44, 44, 48, 48, 48, 51, 52, 52, 53, 56, 56, 57, 57, 61, 61, 62, 62, 63, 63, 63,
64, 64, 68, 68, 69, 69, 70, 70, 71, 71, 72, 72, 73, 73, 74, 74, 75, 75, 79, 80, 80, 81, 81, 82, 82, 83, 83, 84, 84, 85, 85, 86, 90, 91, 91, 92, 92, 93, 93, 94, 94, 95, 96, 96, 97, 97, 98, 98, 99, 99, 100, 100, 101, 106, 106, 107, 107, 108, 108, 109, 110, 110, 111, 111, 112, 112, 113, 113, 114, 115, 115, 116, 116, 117, 117, 118, 118, 119, 120, 120, 121, 121, 122, 122, 123, 123, 124, 125, 125, 126, 126, 127, 127, 128, 128, 129, 130, 130, 131, 131, 132, 132, 133, 133, 134, 134, 135, 136, 136, 137, 137, 138, 138, 139, 140, 140, 141, 141, 142};
short int spark=0;
unsigned int tspk, t0,t1,low;
unsigned int ofc; //Holds number of overflows
const unsigned int LowDelay=25; //Delay <1832 RPM, in degrees
const unsigned int ld=360/LowDelay; //Dont change this
TRISB = 0x0E; // set RB1,2,3 for input, all others for output RB0=SCR RB4=Strobe
PORTB = 0x11; // set gate to SCR high i.e pin 6 of PIC +strobe
OPTION_REG = 0x06; // tmr0 SOURCE INT CLOCK, 1:128 PRESCALER
INTCON = 0x00; //Disable interrupts +Resets interrupt flags
TMR2 = 0; //Reset timer2
TMR0 = 0; //Reser timer0
PR2 = 255; //This is how far timer2 counts before overflow
T2CON = 0x07; // start TMR2 counter 1:16
if (PORTB.F3) test(); //If test jumper is on jump to test function
while(1){ //Loop forever
ofc=0; //Reset overflow counter
INTCON = 0x00; //Disable interrupts +Resets interrupt flags
while(PORTB & 0x02){ //Wait for low pulse on Hall switch
if (INTCON&4) { //Overflow
ofc++; //Increase overflow counter
INTCON = 0x00; //Resets interrupt flags
}
spark = 1;
} //North pole of magnet has passed
if(spark){
t0 = TMR0;
TMR0 = 0; //Start new rev count
if(ofc > 0) { //Overflow timer0, we have < 1832 RPM
if ( ofc >= 36) ofc=36; //Min RPM 50 to avoid big calculations
low=ofc*ld; //Simplified calculation, gives about 25 degrees
delay_cyc (low); //extra delay based on overflow counter
delay_cyc (low);
delay_cyc (low);
delay_cyc (low);
delay_cyc (low); //Repeat 16 times - prescaler
delay_cyc (low);
delay_cyc (low);
delay_cyc (low);
delay_cyc (low);
delay_cyc (low);
delay_cyc (low);
delay_cyc (low);
delay_cyc (low);
delay_cyc (low);
delay_cyc (low);
delay_cyc (low);
} //max255 -> 2550 cycles
tspk = tspark[t0]; //use table lookup for spark delay
T2CON = 0x07; //start TMR2 counter 1:16
TMR2= 0; //clear spark timer
while(TMR2 < tspk);//loop until timeout to send spark
PORTB &= 0xee; //sends a ground to the SCR gate
delay_us(1500); // 56 us delay (Change to 1500)
PORTB |= 0x11; //ground off the SCR
spark = 0;
} //if(spark)
} //while(1)
} //main
////////////////////////////////////////////////////////////////////
//Notes
//
// ; At a engine speed of 1200 RPM;
// ;
// ; 1200 / 60 = 20 revs per second
// ; 1 / 20 = 50mS per rev
// ; 1 rev = 360 degrees
// ;
// ; 36 degrees at 1200 RPM = (36 / 360) X 50 = 5mS
// ;
// ; 100uS loop time
// ; 4MHz clock / 4 = 1MHz instruction cycle
// ; cycle time = 1/1MHz = 100uS
// ; 100uS/100uS = 100 cycles
// ; prescaler set to divide by 4
// ; preset TMR0 = 231, when = 0 = 100uS
// ; 231 to 255 = 25 x 4(prescaler) = 100
// -O-
// RA2 o o RA1
// RA3 o o RA0
// RA4 o o RA7
// RA5 o o RA6
// VSS o o VDD
// SCR RB0 o o RB7
// Hall input USART RX RB1 o o RB6
// Test hi/low USART TX RB2 o o RB5
// Test on/off RB3 o o RB4 Strobelight
// -
//History:
//1.0 1832fix not working