There comes a time... (DIY Electronic Ignition)

Re: There comes a time...

OK... so I'm onto the stage where I'm teaching myself how to program one of these microcontrollers. The learning curve is pretty steep so I've decided to break this part down into smaller projects that will help me get an idea of what's going on.

Project #1 - Make an LED flash with an accurate half-second delay

Project #2 - Brake light flasher. When the brake lever is pulled, flash the brake light ten times over four seconds before holding steady.

Project #3 - Initial stab at this ignition

Project one is well underway. I have my code done and I'm just waiting on the mail before my chips and programmer get here. I'll save you guys the code for projects two and three, but here's just a taste of what's necessary to get a single LED to flash with a half second delay:


;=-=-=-=-=-= SETUP THE CONSTANTS =-=-=-=-=-=

STATUS equ 03h ;address of the STATUS register
TRISA equ 85h ;address of the tristate register for port A
PORTA equ 05h ;address of Port A
COUNT1 equ 0Ch ;first counter for our delay loop, address to 0Cx0
COUNT2 equ 0Dh ;second counter for our delay loop, address to 0Dx0
COUNT3 equ 0Eh ;third counter for delay loop, address to 0Ex0
org 0h ;start program section


;=-=-=-=-=-= SETUP THE PORT =-=-=-=-=-=
MAIN clrwdt
bsf STATUS,5 ;switch to bank 1
movlw 0h ;set port A
movwf TRISA ;to output
bcf STATUS,5 ;back to bank 0
movlw 02h ;turn on LED by first putting it into the W register
movwf PORTA ;and then onto the port

;=-=-=-=-=-= FLIP LED AND THEN DELAY =-=-=-=-=-=
START xorwf PORTA,1 ;flip PORTA from on to off or off to on depending on current status
call DELAY ;delay for half a second

;=-=-=-=-=-= RESTART PROGRAM =-=-=-=-=-=
goto START

;=-=-=-=-=-= SUBROUTINES =-=-=-=-=-=
DELAY

movlw 0x03
movwf COUNT1
movlw 0x18
movwf COUNT2
movlw 0x02
movwf COUNT3
Delay_0
decfsz COUNT1, f
goto $+2
decfsz COUNT2, f
goto $+2
decfsz COUNT3, f
goto Delay_0

;6 cycles
goto $+1
goto $+1
goto $+1
return ;end DELAY

end ;end PROGRAM
 
Re: There comes a time...

Ok, I'm on board. You should change the title. You might get more fans! Anyway, I'm an electrical engineer by day with some embedded C. I've thought about a fully electronic controller too. I can try to help but looks like you're farther ahead. If there is some circuit you are not sure about, try simulating it.

Here is a free basic one I use a lot:
http://www.linear.com/designtools/software/#LTspice

I know you are on your way using a PIC but have you thought about Atmel? I have experience with that micro and I like it. The new RadioShack Arduino is based on it. I will likely use this micro but the code will be similar.

I'm not yet at the point to design it but will be soon. The coding will take the biggest amount of time. The hardware is pretty straightforward. It's controlling it accurately that will be challenging. I was thinking of way to record data thru the micro as well to lay down a baseline curve. You'll probably need a dyno service handy to help with the dynamic tuning once it's built and ready to debug.

Eric
 
Re: There comes a time...

A couple of suggestions for your plan:

1. An output for a timing LED. This way you don't need to hook up a timing light.
2. Throttle input. So you can determine load. Advance is based on RPM and load.
3. Auto shutoff. Prevent coil drain.
 
Re: There comes a time...

Actually, the Atmel was suggested by another friend of mine but I choose the PIC because there is an absolute mountain of support available for it. As this is one of my first electronics projects, I wanted to ensure there would be enough documentation or online resource to which I could turn.

As for coding, I definitely agree. At high RPMs, a couple of µs off and it starts to matter, so I'm going to need a fairly accurate way to time not only the RPM but also the numbers of instructions I'm executing during all the calculations. It's looking pretty tricky at the moment.

As for the curve itself, I was thinking about using a stepped system rather than a true line. That is kinda of a datatable where a range of RPM values are mapped to a range of degrees of advance. Something like this for my 360:

0+ 10°
500+ 20°
600+ 22°
700+ 24°
800+ 26°
900+ 28°
1000+ 30°
1100+ 31°
1200+ 32°
1300+ 33°
1400+ 34°
1500+ 35°
1600+ 36°

This is just some initial thoughts though and I'm more than open to changing this to get the most out of it. I'm hoping to start very low on initial advance so as to make the bike kick over a bit easier. Then I want the timing curve to rise sharply so that I'm sitting at around 20° of advance at idle. By 2000 RPM or so I'd like to be sitting in the mid 30s.
 
Too complicated for me ;D
I'll just grab parts off various bikes and make it work the way I want. ;)
Suzuki have used digital ignition since 1987 8)
I think going to 36 degrees @1,600 rpm may be a bit OTT?
The steps from 500 to 1100 are pretty unnecessary idle speed is around 1,000~1,200
I would expect 36~38 deg around 3~3,500rpm for a street motor so it will be more drivable (if you let rpm drop too far and give full throttle, it won't be pretty with full advance at that low rpm)
Maybe 250 rpm steps would be a better bet?
With higher compression you may need less full advance, but it sounds reasonably easy to change things.
High dome pistons usually need more advance as they have a 'slow' burn at high rpm
I do want full electronic control for my re-phased XS'800' though ::)
 
Thanks for the weigh-in, pj. I was hoping to get some feedback like that. I do feel I need more advance at lower RPMs due to the additional overlap on my cam though. Less dense mixture at low RPM means it burns slower and so throttle response just isn't there unless I dial it up a few notches. I'm currently running at 22° of initial advance and that feels about right. The rest I will certainly take to heart when I get to that stage.
 
Just an idea regarding the tail light, if you had a speed sensor, you could set it up so the tail light will flash with zero speed and brake applied.

The intent would be to prevent you getting rear ended whilst stationary at a red light.
 
Good idea! Sonrier, just make sure you have enough i/o on your selected micro. With all these ideas, you can run out of i/o and memory quick!


Check these guys out:
http://www.elektronik-sachse.de/index_en.htm

They've built similar systems already. Check out the curves they've posted. It may be a helpful starting point.

curves_1_3_standard.gif


curves_8_9_standard.gif


Eric
 
Hi Sonreir,

Which PIC will you be using? The instruction set is different for each PIC. Also, have you considered alternatives to programming in assembler, like using C or BASIC? While the assembler language has relatively few instructions to learn, the more ambitious the project , the more (much more) painful the coding is.
 
I'll be using C. I haven't written assembly language for 20 some years. C is way easier to write, follow and debug.
 
I'd quite like to use C, but my (very basic) understanding is that it's difficult to account for all of the cycles the controller is using unless you write in anything other than assembly. In assembly, each instruction (excepting those that change the program counter) take only a single cycle. If I can get that level of resolution using C or even BASIC I'd much rather use those, yeah.
 
I got to thinking... Maybe I can do all of the necessary calculations within a single subroutine and just time the routine using TMR0? Time for more research...
 
Yeah, I think you have time within one loop. At 12k rpm, the cycle time is only 5ms. (1/(12000/60)). Use interrupts to service the inputs immediately.
 
eyhonda said:
Yeah, I think you have time within one loop. At 12k rpm, the cycle time is only 5ms. (1/(12000/60)). Use interrupts to service the inputs immediately.

My thoughts exactly. I'm only running at 4Mhz and so I've chosen a very low ppm oscillator to help keep things accurate. Although the original plan was to run things from the crank with a wasted spark, I can run from the cam instead and effectively double the time I have available for calculations and the like.
 
I didn't want to threadjack, so I started another thread about an LED timing light idea. I'd like to know what you guys think.

http://www.dotheton.com/forum/index.php?topic=34185

Thanks.

Carry on.
 
I'm running at 1.0 MIPS, so 4 µs per instruction. I think the 16F84A can handle up to 20Mhz and 5.0 MIPS, but I need to do some more research. I only planned to go down that route if the current speed can't handle the application.
 
eyhonda said:
So, internally, it is divide by 4 (1 Mhz)? That's quite fast enough.

Yeah, that's what I figured. At 15,000 RPM each rotation is taking 4000 microseconds, so that allows me (potentially) around 1000 instructions between rotations. Double it if I run from the cam instead of the crank.
 
Back
Top Bottom