Model engine CDI Autoadvance


Closed Thread
Results 1 to 23 of 23
  1. #1
    Join Date
    Nov 2008
    Posts
    60

    Default Model engine CDI Autoadvance

    Hello everyone,

    I have been working on a project and I am making some progress,but not as good as I would have liked. I was wondering if I could get some help. Below is some code and it works,but what I would like to know is is there a better / easier way to do what I am doing. In a nutshell what I am trying to do is I see input from a hall sensor I wait a specific amount of time and then toggle a output. Thanks for any help or advice or code(grin)that can be given. It seems that using a lookup table is not the way to go here because I have several and can't seem to get the curve I want.

    Code:
    While 1 = 1                 ' This code measures the low dwell of the input or the time that the input is low.
       
        While GPIO.2 = 1 :TMR0 = 0 :Wend     ' wait for input to go high and clear tmr0
                                      
        While GPIO.2 = 0 :ldwell = TMR0:Wend    ' wait for input to go low and load var with tmr0 value
                
              
                
              If tmr0if = 1 Then           ' check to see if tmr0 rollover flag is set
                tmr0if = 0                  ' if so clear the flag
               PauseUS 21000                ' and delay 21000 micro seconds
                                            ' this retards the timing from 28 degrees
                                            ' to about 5 degrees for starting
                                            
                                        
    
                 Else                      
    '_______________________________________________________________________________________________________________________________________________                                        
                                        ' to change the curve just shift the table to the right or left using 0s.
                                        ' to lower the curve at idle just remove 0s.To increase the curve at idle add 0s. 
                                        ' curve is  5 degrees @ 1300 to 28 degrees @  2500 
                                        ' LDWELL value is 97 @1300 and 32 @4000 rpm  
    '                lookUp ldwell,[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 - 31
    '                              0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,5,7,10,13,16,19,22,26,29,33,_ '32 - 63
    '                              37,42,47,51,57,63,69,75,82,90,98,107,117,128,141,154,169,176,188,188,188,_ ' 63 - 84
    '                             189,190,191,191,191,191,194,195,195,196,196,197,198,212,212,206,208,205,206,_ '85 - 103
    '                             207,208,209,210,211,212,213,214,215,216,216,217,218,220,221,222,223,224,225,226,_ ' 104- 123
    '                             228,229,230,231,232,234,235,236,237,239,240,241,242,244,245,247,248,250,251,253],delayangle    ' 124 - 143
    
    
    
    
                                  ' to change the curve just shift the table to the right or left using 0s.
                                        ' to lower the curve at idle just remove 0s.To increase the curve at idle add 0s. 
                                        ' curve is  5 degrees @ 1300 to 28 degrees @  4000 
                                        ' LDWELL value is 97 @1300 and 32 @4000 rpm  
    
    
    '                          lookUp ldwell,[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,2,3,5,6,7,8,_
    '                               10,11,12,14,15,17,18,20,21,23,24,26,28,30,32,33,35,38,40,42,44,46,49,51,54,56,59,_
    '                               62,65,68,71,74,78,81,85,89,93,97,101,106,110,115,121,126,132,138,144,151,158,166,_
    '                               174,182,191],delayangle
    
    
                                  ' to change the curve just shift the table to the right or left using 0s.
                                        ' to lower the curve at idle just remove 0s.To increase the curve at idle add 0s. 
                                        ' curve is  5 degrees @ 1300 to 28 degrees @  4000 
                                        ' LDWELL value is 97 @1300 and 32 @4000 rpm  
    
    
                              lookUp ldwell,[0,0,0,0,0,1,2,3,4,5,6,7,8,9,10,11,12,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,_
                                             32,33,34,35,37,38,39,41,42,43,45,46,48,49,51,52,54,56,57,59,61,63,65,67,69,71,73,75,77,79,_
                                             81,84,86,89,91,94,97,99,102,105,108,111,114,118,121,125,128,132,136,140,144,148,153,157,162,_
                                             165,169,172,176,179,183,187,191,196,200,205,210,215,221,227,233,239,246,254],delayangle 
                                   
                                   
                EndIf       
                                   
    
    '_______________________________________________________________________________________________________________________________________________                               
                                 
              
              T2CON = 7      ' turn timer2 on ans set prescale to 1:16
              TMR2 = 0         ' clear tmr2
        While TMR2 < delayangle :Wend     ' wait here until timer2 =  delayangle
                npn = 1             ' turn base of npn on
                pauseus 1280        ' pause for 1.280 ms   
                npn = 0           ' turn base of npn off
        
               INTCON = 0         ' just making sure the intcon register is cleared
               
                
          
                                 
       Wend 
           
       end                      ' end of code
    Regards
    CharlieM
    Using PBP3
    MCSPX

  2. #2
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,615


    Did you find this post helpful? Yes | No

    Default Re: Model engine CDI Autoadvance

    Hi,

    I already know everything you could think and write ...

    http://www.justengines.co.uk/acatalo...n_Systems.html

    just think it twice ...

    Alain
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  3. #3
    Join Date
    Nov 2008
    Posts
    60


    Did you find this post helpful? Yes | No

    Default Re: Model engine CDI Autoadvance

    Thanks.I don't need a ignition system. Just some help with the
    Auto advance.
    Regards
    CharlieM
    Using PBP3
    MCSPX

  4. #4
    Join Date
    Sep 2009
    Posts
    737


    Did you find this post helpful? Yes | No

    Default Re: Model engine CDI Autoadvance

    Look here
    http://www.sportdevices.com/ignition...n.htm#download
    You have example in asm and C.

  5. #5
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,615


    Did you find this post helpful? Yes | No

    Default Re: Model engine CDI Autoadvance

    Quote Originally Posted by c_moore View Post
    Thanks.I don't need a ignition system. Just some help with the
    Auto advance.
    All the CDI devices I've seen work with retrieve tables ...

    AND you can get the curves you want.


    and can't seem to get the curve I want.
    Could you explain what's wrong for you ???

    Alain
    Last edited by Acetronics2; - 29th May 2012 at 16:31.
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  6. #6
    Join Date
    Nov 2008
    Posts
    60


    Did you find this post helpful? Yes | No

    Default Re: Model engine CDI Autoadvance

    Thanks Pedja089,

    I tried it. I even went so far as to download a demo version of CCS and it doesn't work.

    Alain,

    OK what the code does is measure the time the input is low using TMR0 and based on that value uses a lookup table to get a delay. the problem is that creating a delay table that will work like I want is causing me to go crazy. The other thing is that I am limited to a narrow range of rpm. for example if I set the tmr0 prescale to 32:1 then I am limited to a rpm range of about 1300 to 4000. That fine.But While starting I need to measure the "dwell" or the time the input is low at 200 rpm. With that prescale tmr0 overflows. One solution I have come up with is set the Tmr0 prescale to 256:1 and at startup(200 rpm) upto 400 rpm measure the time the input is high. After 400 measure the time the input is low. Only problem with that is I can't seem to figure out how to do it. Any advice is greatly appreciated.
    Regards
    CharlieM
    Using PBP3
    MCSPX

  7. #7
    Join Date
    Nov 2008
    Posts
    60


    Did you find this post helpful? Yes | No

    Default Re: Model engine CDI Autoadvance

    Does anyone have any ideas?
    Regards
    CharlieM
    Using PBP3
    MCSPX

  8. #8
    Join Date
    Feb 2006
    Location
    Gilroy, CA
    Posts
    1,530


    Did you find this post helpful? Yes | No

    Default Re: Model engine CDI Autoadvance

    Quote Originally Posted by c_moore View Post
    Hello everyone,
    It seems that using a lookup table is not the way to go here because I have several and can't seem to get the curve I want.
    What curve do you want? Any graph of what it should be? Seems to me DT interrupts and maybe a couple equations for different slopes on the graph could replace the lookup table and pauses.
    http://www.scalerobotics.com

  9. #9
    Join Date
    Nov 2008
    Posts
    60


    Did you find this post helpful? Yes | No

    Default Re: Model engine CDI Autoadvance

    Hi scalerobotics,

    the curve I am trying to obtain is 5 degrees from startup(200) rpm to 1300 rpm. after 1300 the timing advances up to 4000 at 28 degrees.
    Regards
    CharlieM
    Using PBP3
    MCSPX

  10. #10
    Join Date
    Feb 2006
    Location
    Gilroy, CA
    Posts
    1,530


    Did you find this post helpful? Yes | No

    Default Re: Model engine CDI Autoadvance

    I can't seem to find any manufacturer that (officially) prints a timing curve for a model engine. This was the only one that mentioned timing that I could find at: http://tech.flygsw.org/evolution26review.htm, which seems close to your numbers. And this one, perhaps from someone at C&H engines: http://www.rcgroups.com/forums/showthread.php?t=1498669 . Have you found any other example curves?
    Name:  Curve 2.jpg
Views: 1544
Size:  48.1 KB
    http://www.scalerobotics.com

  11. #11
    Join Date
    Feb 2006
    Location
    Gilroy, CA
    Posts
    1,530


    Did you find this post helpful? Yes | No

    Default Re: Model engine CDI Autoadvance

    If you didn't want to do the lookup table, you could calculate for the equation of the line.

    To find the slope of a line, you can enter the two points x1,y1 and x2,y2 on this calculator: http://www.ajdesigner.com/phpline/li...e_equation.php
    For the graph shown above, the slope is (m) = 0.011904761904762, which can be simplified to .012
    y = m * x + b

    We can simplify this to be timing advance (y) = .012 * rpm + .2 or (12 * rpm + 200)/1000 when the rpm is between 400 and 2500
    When the rpm is below 400, timing = 5 degrees
    When the rpm is above 2500, timing = 30 degrees


    http://www.scalerobotics.com

  12. #12
    Join Date
    Nov 2008
    Posts
    60


    Did you find this post helpful? Yes | No

    Default Re: Model engine CDI Autoadvance

    Thanks scalerobotics,

    Thats great info. Its funny that you mention C-H ignition. I actually know the guy that owns the company and this is for some ignitions he is working on. The
    lookup table I am using now advances the timing to 28 degrees around 2500. That is too soon. It really needs to be after 4000 rpm. So with the formula( (12 * rpm + 200)/1000) is this used to figure the delay? Thanks for your help.
    Regards
    CharlieM
    Using PBP3
    MCSPX

  13. #13
    Join Date
    Feb 2006
    Location
    Gilroy, CA
    Posts
    1,530


    Did you find this post helpful? Yes | No

    Default Re: Model engine CDI Autoadvance

    That is funny!

    For the 0 to 1300 rpm at 5 degrees, and 4000 at 28 degrees, with the slope in between, we can calculate it as (85 * RPM)/1000 - 60, with the answer as xxx where it is really xx.x degrees.
    For example (85 * 4000)/1000 - 60 = 280 , or 28.0 degrees. (85 * 1300)/1000 - 60 = 50 , or 5.0 degrees. This will give a little more precision, and makes the math easier.

    For your dwell, you could use 4000/RPM * 32 to get pretty close dwell number. Of course switching it the right way for div32
    Last edited by ScaleRobotics; - 1st June 2012 at 13:24.
    http://www.scalerobotics.com

  14. #14
    Join Date
    Nov 2008
    Posts
    60


    Did you find this post helpful? Yes | No

    Default Re: Model engine CDI Autoadvance

    Thanks Scalerobotics,

    So now I need to convert that to a delay that I can use. Thanks again.
    Regards
    CharlieM
    Using PBP3
    MCSPX

  15. #15
    Join Date
    Feb 2008
    Location
    Michigan, USA
    Posts
    231


    Did you find this post helpful? Yes | No

    Default Re: Model engine CDI Autoadvance

    Hi Scalerobotics,

    Do you mind explaining your formula for me, I'm not sure where y = m * x + b comes from.

    y= advance
    m= slope
    x = rpm to calculate it for
    b= ? That's where I'm missing something.

    thanks
    bo

  16. #16
    Join Date
    Feb 2006
    Location
    Gilroy, CA
    Posts
    1,530


    Did you find this post helpful? Yes | No

    Default Re: Model engine CDI Autoadvance

    Hi bo,

    b is the y intercept, where the line crosses the Y axis. It sort of places the slope on the graph paper if you will. In this picture b = 1. If the line crosses the Y axis at 0, then your b = 0 and you don't need it. http://www.mathsisfun.com/equation_of_line.html

    Name:  y-mxpb-graph.gif
Views: 1029
Size:  5.2 KB
    Last edited by ScaleRobotics; - 11th June 2012 at 13:47.
    http://www.scalerobotics.com

  17. #17
    Join Date
    Feb 2008
    Location
    Michigan, USA
    Posts
    231


    Did you find this post helpful? Yes | No

    Default Re: Model engine CDI Autoadvance

    Thank you.

  18. #18
    Join Date
    Nov 2008
    Posts
    60


    Did you find this post helpful? Yes | No

    Default Re: Model engine CDI Autoadvance

    Ok so using that example how do you figure out a delay needed for a given value at a given rpm? for example

    2000 rpm we want a timing curve of 10 degrees BTDC. how would that work?
    Regards
    CharlieM
    Using PBP3
    MCSPX

  19. #19
    Join Date
    Feb 2006
    Location
    Gilroy, CA
    Posts
    1,530


    Did you find this post helpful? Yes | No

    Default Re: Model engine CDI Autoadvance

    Given your slope of 1300 rpm with 5 degrees advance, and 4000 with 28 degrees of advance, at 2000 rpm the advance would be about 11 degrees. If you wanted this to be 10, then maybe you want to add another slope point at 2000 degrees. This would give you a different slope for 1300 to 2000 rpm, and one for 2000 to 4000 rpm.

    But to go with the current slope in #13 the calculation for 2000 RPM would be: (85 * RPM)/1000 - 60 = 110 , which is for 11.0 degrees. You could use the 110 to set your timer for higher precision for the advance.

    If you wanted a slope for 1300 rpm at 5 degrees, 2000 rpm at 10 degrees, and one slope 2000 rpm at 10 degrees, 4000 rpm at 28 degrees:
    1300 to 1999 rpm: (71 * rpm)/1000 - 43 (this could be made more accurate by changing the multiplication and division factors, but it is within 0.2 degrees at 1999)
    2000 to 4000 rpm: (90 * rpm)/1000 - 80

    Any slope can be calculated pretty easily here: http://www.1728.org/distance.htm . You may have to scroll across the equation to get to the -/+ b part of the equation.
    Last edited by ScaleRobotics; - 12th June 2012 at 12:25.
    http://www.scalerobotics.com

  20. #20
    Join Date
    Nov 2008
    Posts
    60


    Did you find this post helpful? Yes | No

    Default Re: Model engine CDI Autoadvance

    Hi Scalerobotics,

    Ok Thanks. I need to make a graph in excell and plot out the values from 1300 to 4000 using your formula. Then that would give me the numbers I need in my table.
    Regards
    CharlieM
    Using PBP3
    MCSPX

  21. #21
    Join Date
    Feb 2006
    Location
    Gilroy, CA
    Posts
    1,530


    Did you find this post helpful? Yes | No

    Default Re: Model engine CDI Autoadvance

    Yes, you could just use a lookup table, if you want to. I suppose there are advantages and disadvantages to each.

    Calculating with line equation:
    Code:
    variable = 85 * RPM
    delayangle = (div32 1000) - 60
    And for dwell:
    Code:
    variable = 4000 * 32
    dwell = div32 RPM
    Calculating with a lookup table:
    Code:
     
                              lookUp ldwell,[0,0,0,0,0,1,2,3,4,5,6,7,8,9,10,11,12,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,_
                                             32,33,34,35,37,38,39,41,42,43,45,46,48,49,51,52,54,56,57,59,61,63,65,67,69,71,73,75,77,79,_
                                             81,84,86,89,91,94,97,99,102,105,108,111,114,118,121,125,128,132,136,140,144,148,153,157,162,_
                                             165,169,172,176,179,183,187,191,196,200,205,210,215,221,227,233,239,246,254],delayangle
    A lookup table has at least one advantage:
    Code is quicker

    Math equation:
    Code is smaller (usually)
    Quicker to enter new equation than entering a large table (example you want to try a new timing curve)
    Results can be more precise.
    Can change curve on the fly with only two variables.

    I always try to do a math equation. If the math is too dificult, then I default to a table. But that's just my opinion. And there are many, many different ways to solve for "x".
    Last edited by ScaleRobotics; - 13th June 2012 at 05:29.
    http://www.scalerobotics.com

  22. #22
    Join Date
    Nov 2008
    Posts
    60


    Did you find this post helpful? Yes | No

    Default Re: Model engine CDI Autoadvance

    Thanks I think There is enough info. here to get mo going.
    Regards
    CharlieM
    Using PBP3
    MCSPX

  23. #23
    Join Date
    Jul 2005
    Location
    Palmdale, CA
    Posts
    37


    Did you find this post helpful? Yes | No

    Default Re: Model engine CDI Autoadvance

    I'm curious if this project ever came to fruition. I'm currently designing an ignition system for a vintage triumph engine for Bonneville Salt Flats. I started out using an AVAGO encoder because it was small and cheap and provided a digital position via SPI. I machined a replacement for the factory "distributor" to mount the encoder. I missed something on the data sheet however. The specs said the encoder was capable of clocking the SPI at 1MHz. Plenty fast enough. However, after fiddling with it I noticed it had a sample rate limitation of 10kHz. You can clock the data out at a bit of 1MHz but you can only sample it at one reading every 100uS. Not fast enough for high RPM. At 8,000 RPM, the device only gives a reading every 4 or 5 degrees (48,000 deg/sec x 100uS = 4.8deg). I wanted to have at least 1 sample for every degree of rotation. So I tried to interpolate between readings. I kept track of 2 successive readings to get the rotational velocity ((current reading-last reading)/(100uS)). When I was within 1 delta reading of the ignition point I used the velocity to extrapolate the actual desired ignition point to fire (turn off) the coil. Nice theory anyway. I couldn't get the code fast enough to make the interpolation within the 80uS remaining after sampling the encoder. So I tried to pick an arbitrary point well enough in advance if the ignition point to give the PIC enough time for the calculations. The problem with that was interpolating the ignition point from a greater distance caused greater error. This was largely because this simple method does not take acceleration into account. I chose to do a steady state interpolation ignoring acceleration figuring that if I was within 4.8 degrees of the desired ignition point, there would be minimal error due to accelleration. However when moving the point of interpolation way in advance there is plenty of time for the rotational velocity to change significantly.

    I gave up on the digitizing encoder and switched to a quadrature encoder with an index. The one I plan on using gives 2000 pulses/rev with a zero index. It should be easier to reference the index and count pulses. I'm currently machining the distributor to try it out. If anyone is interested, I can post the results later.

    Ed

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts