A motorcycle ignition project - Picaxe18M2

PeterMooney

New Member
I'm trying to replace an old points based motorcycle ignition by using Hall effect trigger and PICAXE18M2 to provide variable advance/retard intervals. I have tried "pulsein" and "pauseus" hoping to get intervals of about 0.12 milliseconds but the interpreted Basic on the chip seems to be way to slow - taking half a second to respond...
main:

pulsin c.7,1,w1 ; look for pickup low to high transition and store time in w1
;now check this time interval against the retard table...
;if no high to low transition or longer than 0.64 second then w1=0
select w1
case = 0 ;rpm < 500 so full retard 36 degrees
retardDelay = 12000 ;36 degrees
case < 7317 ;rpm > 4100 so full advance
; do nothing gosub spark
retardDelay = 0
case < 7895 ;rpm > 3800 so delay 0.132 millisecs
retardDelay = 132 ; 3 degrees
case < 8571 ;rpm > 3500 so delay 0.286 millisecs
retardDelay = 286 ; 6 degrees
case < 9375 ;rpm > 3200 so delay 0.469 millisecs
retardDelay = 469 ; 9 degrees
case < 10345;rpm > 2900 so delay 0.690 millisecs
retardDelay = 690 ; 12 degrees
case < 11538;rpm > 2600 so delay 962 millisecs
retardDelay = 962 ; 15 degrees
case < 13043;rpm > 2300 so delay 1.304 millisecs
retardDelay = 1304 ; 18 degrees
case < 15000;rpm > 2000 so delay 1.750 millisecs
retardDelay = 1750 ; 21 degrees
case < 17647;rpm > 1700 so delay 2.353 millisecs
retardDelay = 2353 ; 24 degrees
case < 21429;rpm > 1400 so delay 3.214 millisecs
retardDelay = 3214 ; 27 degrees
case < 27273;rpm > 1100 so delay 4.545 millisecs
retardDelay = 4545 ; 30 degrees
case < 37500;rpm > 800 so delay 6.875 millisecs
retardDelay = 6875 ; 33 degrees
else ; rpm < 800 so delay 12.000 millisecs
retardDelay = 12000 ;36 degrees
end select

pauseus retardDelay

makeSpark:
;now make_spark
;break LT circuit
high B.0

'delay for dwell
if w1 = 0 then
dwellLength = retardDelay
else
dwellLength = w1/2 ;1/4 revolution (90 degrees)
endif
pauseus dwellLength

low B.0 ; close LT circuit again

goto main

Where am I going wrong?:confused:
 

Jamster

Senior Member
I would suggest posting in the Active Forum, You will get far more responses there than you will here.
If you use an X2 chip you are able to use an external resonator which will increase accuracy and, should you wan't it, speed up code to 64Mhz.

It would also be good if we could see your circuit (photos or schematic) and if you could supply the full code in [noparse]
Code:
[/noparse] tags (makes it neater)

Jamster
 
Top