Page 1 of 1

dual spark mode rpm - megatune

Posted: Sat Oct 04, 2008 3:15 pm
by maxelrad
I am sending two firing signals 180 deg apart one to optoin and the other to vrin2. I have specified 0 teeth. Megatune RPM is exactly 1/2 my actual cranking RPM. Any suggestions?

Re: dual spark mode rpm - megatune

Posted: Sun Oct 05, 2008 7:10 pm
by grippo
Either there is something in your configuration that is incorrect or your setup isn't handled in microsquirt. To determine which, we need to know details of your engine that affect ignition timing like no. cylinders, 2 or 4 stroke, whether tach inputs are from cam or crank. I don't think anyone has run no wheel with two tach inputs. We also need an msq file.

Re: dual spark mode rpm - megatune

Posted: Mon Oct 06, 2008 1:19 pm
by maxelrad
Hi Al

I will try to provide the pertinent information as to what I am doing.

Attached find a photo of logic analyzer output decoding a GM 7 tooth reluctor wheel with "signature" tooth as described in your manual.

First trace processed reluctor output - second trace logic to be input to opto+ - third trace logic to be input to vrin2.

Note the bright signal in the reluctor output is the double 10 degree separated tooth (poor photo technique). Also included is a photo of the AVR 2313 based board with reluctor processing chip NCV1124 .

I have designed and built this to drive a wasted spark system for a four cylinder GM Ecotec engine. Also thought the hardware addition might be useful to others - the software could be modified to provide dual spark outputs in many custom sitiuations.

I am attaching the msq file. I hope we can solve the problem.

Michael

Re: dual spark mode rpm - megatune

Posted: Tue Oct 07, 2008 6:03 am
by grippo
The odd angle in the msq should be 0 degrees in dual tach mode, since the phase offset between the signals is taken care of by the mechanical offset between the 2 sensors. However, this is not the reason for the rpm being half value.

If the signals in traces 2 and 3 are offset by 180 deg, then in each trace the pulses are 360 deg apart. This means you are getting a combined total of 4 pulses per 720 crank deg. From this I assume you have 2 wasted spark coils. I will have to check this on the bench when I get a chance and see what rpm I get.

Re: dual spark mode rpm - megatune

Posted: Wed Oct 08, 2008 6:29 am
by grippo
I looked at the code for your case - dual tach inputs, 4 cylinder, 4 stroke, and the rpm calculation looks correct. From your 2nd and 3rd trace, the pulses are about 225 ms apart. I assume this is the time for one crank rev. That corresponds to 267 rpm, and that is what you should see in MT if I calculate the rpm the way it is in the code.

Re: dual spark mode rpm - megatune

Posted: Wed Oct 08, 2008 4:58 pm
by maxelrad
Your calculation is correct however MT reports 134 RPM.

The software must be waiting until the count stated in your code below is satisified (I believe it wants 2 inputs/rev from at least the first input). Since I only provide one - twice the time would elapse thus half the RPM.

It is difficult to interpret others' code - please forgive if I misread.

Please also note that it will be easy for me to convert to a (six tooth - one missing) format thus avoiding the dual spark complications. I went this way initially since it is intuitively pleasing to me.

// Just received new input pulse - 1/ cyl / 2 crank revs (1 for 2 stroke).
// In wheel decode mode will throw out pulses to achieve this.
if(TFLG1 & 0x01) {
// interrupt from 1st IC sensor
TFLG1 = 0x01; // clear IC interrupt flag
ICint = 0;
if((inpram.DualSpkOptn == 1) || (inpram.DualSpkOptn == 6))
OCint = 0;
tcIC = *pTIC[0];
TCICus = (tcIC/3)<<1;
if(pulse_no == 0) { // 1st input pulse
pulse_no++;
OCint = 0;
ICt_overflow[0] = 0;
ICtt_ovflo = 0;
t_in3[0] = TCICus;
dt2[0] = 0;
dt3[0] = 0; // time difference between pulses, us
outpc.dt3 = dt3[0]; // for HP calculations
dtpred = dt3[0]; // predicted time difference for next pulse
tddtpred = 0;
t2dddts = 0;
ign_state[0] = 0;
missed_pulse[0] = 0;
xtra_pulse[0] = 0;
mask_teeth = 0;
nsynch = 0;
//----------------------------------------------------------------------------------------------------
if(inpram.no_skip_pulses > 2)
no_chk_pulses = inpram.no_skip_pulses;
else
no_chk_pulses = 2; // ??? MA
if((inpram.DualSpkOptn == 1) || (inpram.DualSpkOptn == 6))
no_chk_pulses++; // else have to use pulse_no[ICint] //no_chk_pulses 2 + 1 ??? MA
goto IC_RET;
//-------------------------------------------------------------------------------------------------------
}
}


else if((inpram.DualSpkOptn == 1) || (inpram.DualSpkOptn == 6)) {
// interrupt from 2nd IC sensor (Dual Spark mode)
TFLG1 = ICintmask[1]; // clear IC2 interrupt flag
ICint = 1;
OCint = 1;
tcIC = *pTIC[1];
TCICus = (tcIC/3)<<1;
// wait til synch on 1st IC
if(!synch) {
ICt_overflow[1] = 0;
t_in3[1] = TCICus;
dt2[1] = 0;
dt3[1] = dt3[0];
ign_state[1] = 0;
missed_pulse[1] = 0;
xtra_pulse[1] = 0;
goto IC_RET;
}
}
else {
// interrupt from 2nd IC sensor (cam/crnk_sync)
ICint = 1;
cam_sync = 1;
goto IC_RET;
}
if(synch != END_SYNCH) {
ICtt_ovflo = 0;
}
else { // synched
// if synched in wheel decode - process pulses

Re: dual spark mode rpm - megatune

Posted: Thu Oct 09, 2008 4:31 am
by grippo
The code you show is only executed at the very beginning where it throws out the first few pulses as they can be erratic. But once started, it times every pulse. The relevant code for rpm is at the beginning before entering the main loop:

if(inpram.DualSpkOptn == 1) {
// crank signal
if(inpram.EngStroke == 0) // 4 stroke
if(inpram.no_cyl == 2) // 2 cyl
Rpm_Coeff = 120000000;
else // 4 cyl
Rpm_Coeff = 240000000; // crank signal
else // 2 stroke
Rpm_Coeff = 120000000;
}
else {
// cam signal (4 stroke)
Rpm_Coeff = 240000000;
}
Rpm_Coeff /= inpram.no_cyl;

For your case (DualSpk =1, 4 stroke, 4 cyl) Rpm_Coeff = 240000000 / 4 = 60000000.


Later in TimerIn ISR:

rpm = (unsigned int)(Rpm_Coeff / dt3[ICint]);
where dt3 holds the time difference (in usec) between pulses with ICint being the input channel. THere is no skipping of pulses, that is done only at the very start and after 2 pulses are thrown out, all others are used.

Is it possible the scaling in the MT ini file was changed ? If you fiddle with the cranking rpm it will cause the processor to come out of cranking mode which you can see in MT. So if you set this rpm to say 200, then if the processor is seeing 267 it will come out of cranking mode; if it is seeing 134 it will stay in cranking.

Re: dual spark mode rpm - megatune

Posted: Sat Oct 11, 2008 7:40 am
by maxelrad
I have modified my crank processor to produce two signals 180 deg out of phase to simulate the engine running at 620 RPM 48.5 ms apart. One to opto+ one to vrin2+. Everything works as advertised. The rpm readout is correct - the microsquirt dual ingnition outputs are firing in sych with the inputs.

I was having problems with cranking mode as you suggested.

Thankyou. I am looking forward to continuing adventures with microsquirt.