• AVR Freaks

Hot!12f683 timer1 gating questions.

Author
headsmess
New Member
  • Total Posts : 16
  • Reward points : 0
  • Joined: 2019/02/22 03:13:43
  • Location: 0
  • Status: offline
2019/08/31 19:00:32 (permalink)
0

12f683 timer1 gating questions.

howdy...
 
right. this is confusing the hell out of me...
 
bit 6 TMR1GE:
Timer1 Gate Enable bit(2)If TMR1ON = 0:
This bit is ignored If TMR1ON = 1:
(that makes sense...)
1 = Timer1 is on if Timer1 gate is not active (?)
0 = Timer1 is on (??!)
 
(that makes no sense)
ok... so timer is on if gate is not active.
 
does that mean the timer is triggered by a logic low? in which case i just invert with bit 7 and all is dandy? (or i redo my optocoupler to be logic low! after i went and redesigned it and all...)
 
its sorta like a double negative statement there and im bloody confused...
 
next!
 
im trying to time the length of a pulse. i want it as the very start of my code. if theres no signal, it just keeps waiting for one.
then it has to wait until the signal is completed before proceeding. from about 100 to 1000 machine cycles .
 
i cant find any mention of flag bits or the like to tell if the gate is high or low to do this?
 
but i am thinking (excuse my terrible syntax, this is just doodles in notepad...)
 
start
BTFSS GPIO,b'00010000' ;(gp4 is T1g) check for a signal skip if not
goto start
;timer starts,
wait
BTFCS GPIO b'00010000' ; check that signal is over skip if yes
goto wait

MOVF TIMER1HI, RPMRESHI
MOVF TIMER1LO, RPMRESLO ; shove results in handy register...
 
am i approaching this the right way? just check the gpio in a loop for appropriate hi/lo as the timer does its thing?
 
 
oh...lastly...
in ADC i see an option to right or left justify...
is there any such thing with the timer results? ideally i want left justified HI result only... another thing i cant see in the data sheet... meh. i can fiddle with prescalers on that area.
 
cheers! :) sorry for being dumb.
post edited by headsmess - 2019/08/31 19:11:26
#1

16 Replies Related Threads

    ric
    Super Member
    • Total Posts : 23893
    • Reward points : 0
    • Joined: 2003/11/07 12:41:26
    • Location: Australia, Melbourne
    • Status: offline
    Re: 12f683 timer1 gating questions. 2019/08/31 19:31:57 (permalink)
    +1 (1)
    headsmess
    bit 6 TMR1GE:
    Timer1 Gate Enable bit(2)If TMR1ON = 0:
    This bit is ignored If TMR1ON = 1:
    (that makes sense...)

    Yes. Plainly it doesn't matter if the gate is enabled if the timer itself is disabled.


    1 = Timer1 is on if Timer1 gate is not active (?)
    0 = Timer1 is on (??!)
     

     
    (that makes no sense)
    ok... so timer is on if gate is not active.

    I agree it is poor language. I think whoever wrote it got confused by the pin normally being an active low signal.
    If TMR1ON=1 and TMR1GE=0, then the timer counts normally (Gating is not being used.
    If TMR1ON=1 and TMR1GE=1, then the timer counting is controlled by the gate signal
     
    Note that the gate signal can either be the T1G pin, or the comparator output.
    Also note that is has selectable polarity. You can make it active high or active low.
     

    does that mean the timer is triggered by a logic low? in which case i just invert with bit 7 and all is dandy? (or i redo my optocoupler to be logic low! after i went and redesigned it and all...)

    You have control of it, so no hardware change needed.
     


    im trying to time the length of a pulse. i want it as the very start of my code. if theres no signal, it just keeps waiting for one.
    then it has to wait until the signal is completed before proceeding. from about 100 to 1000 machine cycles .
     
    i cant find any mention of flag bits or the like to tell if the gate is high or low to do this?

    You know if it is the pin or the comparator doing the controlling, and you know if you have set it to active high or active low.
    You can read the pin state and the comparator input, so it's easy to test if gating is enabled.
     

    am i approaching this the right way? just check the gpio in a loop for appropriate hi/lo as the timer does its thing?

    Yes, that's all you need to do.
     

    in ADC i see an option to right or left justify...
    is there any such thing with the timer results? ideally i want left justified HI result only... another thing i cant see in the data sheet...

    Because you can't do it. Only the ADC has that, as it's useful to left justify if you only want the 8 most significant ADC results.
     

    I also post at: PicForum
    Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
    NEW USERS: Posting images, links and code - workaround for restrictions.
    To get a useful answer, always state which PIC you are using!
    #2
    headsmess
    New Member
    • Total Posts : 16
    • Reward points : 0
    • Joined: 2019/02/22 03:13:43
    • Location: 0
    • Status: offline
    Re: 12f683 timer1 gating questions. 2019/09/01 01:21:42 (permalink)
    0
    shame about the left justify but oh well. getting rid of pesky LSBs...thats the exact reason.
     
    as i expect 1000cycles to be about my highest count@4MHz (lowest speed), can just prescale for 1:4, gives me 250, anything higher is (s)lower, lower numbers=higher speeds. easy. keep it in one byte... too hard dealing with the extra 8 bits. or 2 as it will be, roughly... grrr. 10 bits. if i ever need better accuracy i ramp the clock up...
     
    thanks. as long as my idea of code gets a thumbs up rather than a WTF... im on the right track!
     
    now to work my way through the maze of setting registers...
     
     
     
     
    #3
    Gort2015
    Klaatu Barada Nikto
    • Total Posts : 3292
    • Reward points : 0
    • Joined: 2015/04/30 10:49:57
    • Location: 0
    • Status: offline
    Re: 12f683 timer1 gating questions. 2019/09/01 03:46:07 (permalink)
    +1 (1)
    WTF [0%].........+.......... AOK [100%]
                                ^
     
    You lost points, that's how the scale works but not bad for a nube.
     
    Point loser.
    1. Gate operation, could have researched that.
    2. Too hard dealing with the extra 8 bits - that is fundamental just like dealing with +-/*

    MPLab X playing up, bug in your code? Nevermind, Star Trek:Discovery will be with us soon.
    https://www.youtube.com/watch?v=Iu1qa8N2ID0
    + ST:Continues, "What Ships are Made for", Q's back.
    #4
    headsmess
    New Member
    • Total Posts : 16
    • Reward points : 0
    • Joined: 2019/02/22 03:13:43
    • Location: 0
    • Status: offline
    Re: 12f683 timer1 gating questions. 2019/09/02 21:45:18 (permalink)
    0
    giggity...
     
    i did research it! thats why i got confused! why cant they just say logic low?mad: mad
     
    anyway...
    i got something to work at long last...
    which is pretty damn good for my first project... yeah, i jumped in the deep end and bypassed all that flashing LED nonsense... this isnt really that hard, when the datasheet makes sense.
     
    so far, just a simple loop to check for signal, waitabit, turn on pin, run a delay, turn off, go back to polling. seems to be doing what it should do. fun day... not a hint of magic smoke yet... getting my head around loops and why i kept latching up...or not...
     
    seemed to get faster switching and a more definite hi/lo with a hardware change. back to logic low optocoupler.
     
    feel free to question my approach... this is my first bit of code too :) (excluding several edits...)
     
    #include   <p12f683.inc>
    __config 0x30D4
    ORG     0x00             ; processor reset vector
    ;poll trigger.
    ;start ~1millisec delay.
    ;return to poll.

    COUNTA EQU       b'00100000'
    COUNTB EQU       b'00100001'
    start

    CLRF     GPIO              ;I/Ooff
    MOVLW   b'00000111'
    MOVWF    CMCON0            ;digitalI/O
    BSF      STATUS, RP0       ;REG1
    BCF      TRISIO,5
    BCF      ANSEL,3
    BCF      WPU,4
    BCF      STATUS, RP0
    BCF      GPIO,5
    MOVLW   b'00001010'        ;10 in countB   
    MOVWF    COUNTB       
     on
    BTFSC    GPIO,4
    GOTO on
    BTFSS    GPIO,4
    GOTO $-1
    BSF      GPIO,5            ;on
     loop
    MOVLW   b'00110010'
    MOVWF    COUNTA            ;50 in countA
    dc
    DECFSZ   COUNTA,F
    GOTO dc                    ;dec to 0
    DECFSZ   COUNTB,F
    GOTO loop                  ;perform 10x
    BCF      GPIO,5
    GOTO on                    ;return
    end       
    post edited by headsmess - 2019/09/02 21:55:19
    #5
    ric
    Super Member
    • Total Posts : 23893
    • Reward points : 0
    • Joined: 2003/11/07 12:41:26
    • Location: Australia, Melbourne
    • Status: offline
    Re: 12f683 timer1 gating questions. 2019/09/02 22:36:37 (permalink)
    +1 (1)
    Format and syntax cleaned up a little.
    #include   "p12f683.inc"
    ; __config 0xF0D4
     __CONFIG _FOSC_INTOSCIO & _WDTE_OFF & _PWRTE_OFF & _MCLRE_OFF & _CP_OFF & _CPD_OFF & _BOREN_OFF & _IESO_OFF & _FCMEN_OFF

    ; poll trigger.
    ;start ~1millisec delay.
    ;return to poll.

    ;scratch starts at 20h    
            cblock      20h
            COUNTA
            COUNTB
            endc
     
            ORG     0x00             ; processor reset vector
    start:    
            CLRF    GPIO            ;I/Ooff
            MOVLW   b'00000111'
            MOVWF   CMCON0          ;digitalI/O
            BANKSEL TRISIO          ;to bank-1
            BCF     TRISIO,5
            BCF     ANSEL,3
            BCF     WPU,4
            BANKSEL GPIO            ;back to bank-0
            BCF     GPIO,5
            MOVLW   .10
            MOVWF   COUNTB       
    on:
            BTFSC   GPIO,4
            GOTO    on
    off:
            BTFSS   GPIO,4
            GOTO    off
            
            BSF     GPIO,5          ;on
    loop:
            MOVLW   .50
            MOVWF   COUNTA
    dc:
            DECFSZ  COUNTA,F
            GOTO    dc              ;dec to 0
            DECFSZ  COUNTB,F
            GOTO    loop            ;perform 10x
            BCF     GPIO,5
            GOTO    on              ;return
            
        end      

     
    post edited by ric - 2019/09/02 22:39:08

    I also post at: PicForum
    Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
    NEW USERS: Posting images, links and code - workaround for restrictions.
    To get a useful answer, always state which PIC you are using!
    #6
    headsmess
    New Member
    • Total Posts : 16
    • Reward points : 0
    • Joined: 2019/02/22 03:13:43
    • Location: 0
    • Status: offline
    Re: 12f683 timer1 gating questions. 2019/09/02 23:02:31 (permalink)
    0
    well that explains why my decimal literals werent working... no "."
     
    dont have much luck with hex either... 0x or h aint working for me. sigh. meh. binary feels easier for me. more like flipping switches.
     
    anyway.
     
    she runs!
     
    the engine, that is...oh yeah... an attempt at a rudimentary EFI... thats what all this was about... notice i never got up to using the timer1 yet... itll be there.
    this was enough to show i can fire an injector for some (unknown really!) time and it will at least kickover and splutter along.
    now this works, all i gotta do is figure out the best manner to compare, classify, and do something useful with a few numbers... without running out of space. attempting the fuzzy logic route rather than set points. all a learning curve.
    next on the list... ADC!
    #7
    ric
    Super Member
    • Total Posts : 23893
    • Reward points : 0
    • Joined: 2003/11/07 12:41:26
    • Location: Australia, Melbourne
    • Status: offline
    Re: 12f683 timer1 gating questions. 2019/09/02 23:16:31 (permalink)
    0
    headsmess
    well that explains why my decimal literals werent working... no "."

    You can edit the project properties, and change the "default radix" to "decimal".
    then "10" will give you ten.
     

    dont have much luck with hex either... 0x or h aint working for me. sigh. meh.

    Note I used hex on the "cblock" parameter.
    It's a trailing "h" in assembler, not leading.
     

    binary feels easier for me. more like flipping switches.

    But then you had to add a comment with the decimal value, which is why I made the two count values decimal and deleted the comment.
    It's much safer the specify the value directly in the appropriate radix, then you don't strike to problem of comments with different values to the code. That can hide all sorts of bugs.
     

    I also post at: PicForum
    Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
    NEW USERS: Posting images, links and code - workaround for restrictions.
    To get a useful answer, always state which PIC you are using!
    #8
    headsmess
    New Member
    • Total Posts : 16
    • Reward points : 0
    • Joined: 2019/02/22 03:13:43
    • Location: 0
    • Status: offline
    Re: 12f683 timer1 gating questions. 2019/09/03 04:30:18 (permalink)
    0
    trailing..leading... iunno what the h is going on... doesnt like me :)
     
    just scoped the output cus of...curiosity... it was hella rich. experience tells me it shouldnt even start at 1mS.
     
    roughly 20mS... ok, i need a new scope. "roughly" doesnt cut it.
     
    so whats going on in my loop?
     
    i notice here (generated from piclist.. and DOES create the delay expected)
    delay                      
        movlw    0x8E
        movwf    COUNTA
        movlw    0x02
        movwf    COUNTB
    Delay_0
        decfsz    COUNTA, f
        goto    $+2
        decfsz    COUNTB, f
        goto    Delay_0
     
    that it doesnt bother "refilling" COUNTA at the start of each cycle like i did. (i think this is a 2mS delay...)
     
    leading me to conclude...
     
    COUNTA as specified by me, to be at 20h, containing 142...
    is not the same "COUNTA" that is actually being decremented but is another register created by assembler as its within a loop? a temporary W if you will.
    iunno. something just made me think i oughta move my literal into COUNTA during the loop rather than before it. the results tell me otherwise... i was expecting approx 1.6ms with my first attempt with fifty and ten (about 150instructions x 10cycles plus a few extra...) not...ten times that.
     
    that DECFSZ should be decrementing it to zero... yet at the beginning of the loop generated elsewhere its miraculously full again...
     
    wish i had fiddled with these about 20 years ago...
    #9
    ric
    Super Member
    • Total Posts : 23893
    • Reward points : 0
    • Joined: 2003/11/07 12:41:26
    • Location: Australia, Melbourne
    • Status: offline
    Re: 12f683 timer1 gating questions. 2019/09/03 06:30:03 (permalink)
    0
    headsmess
    just scoped the output cus of...curiosity... it was hella rich.

    Translated into plain English??
     

    experience tells me it shouldnt even start at 1mS.

    Context?
    Are you talking about the delay from your trigger signal on GPIO4 changing, until the output on GPIO5 changes?
     

    roughly 20mS... ok, i need a new scope. "roughly" doesnt cut it.

     
    The tightest part of your loop should run 10 * 50 = 500 times.
    There's three instruction cycles times for the "normal" execution path (1 for the DECFSZ when it doesn't skip, and 2 for the GOTO)
    You don't touch OSCCON, so should be running with a 4MHz clock, so executing instructions at Fosc/4 = 1MHz.
    So, your delay should be roughly (500 * 3) / 1 MHz = 1.5ms
     
    Could you temporarily enable CLKOUT on GPIO4, and observe that with your scope so as to:
    [1] Verify that you are running with a 4MHz clock ( you should see 1MHz on the pin)
    [2] At the same time verify that you have your scope set correctly. Some analog ones have a switch to expand the horizontal scale.
     

    i notice here (generated from piclist.. and DOES create the delay expected)
    delay                      
       movlw    0x8E
       movwf    COUNTA
       movlw    0x02
       movwf    COUNTB
    Delay_0
       decfsz    COUNTA, f
       goto    $+2
       decfsz    COUNTB, f
       goto    Delay_0
     
    that it doesnt bother "refilling" COUNTA at the start of each cycle like i did. (i think this is a 2mS delay...)

    That will run the innermost loop 0x018e = 398 times.
    The COUNTA variable starts at 0x8E the first time round, then just rolls over from 0x00 to 0xFF on subsequent loops, giving a count of 256 for the second iteration. Note that COUNTB gets decremented the first time round, which is why the total is 0x18e, not 0x28e.
     

    leading me to conclude...
     
    COUNTA as specified by me, to be at 20h, containing 142...
    is not the same "COUNTA" that is actually being decremented but is another register created by assembler as its within a loop? a temporary W if you will.

    This is a pile of rubbish. Assembler does NOT do that sort of thing behind your back.
    Wierd effects are usually down to incorrect bank selection, but you are doing it correctly.
    I suspect you're not reading the scope correctly, or there's some other problem with your method of testing.
     
     
    post edited by ric - 2019/09/03 06:34:03

    I also post at: PicForum
    Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
    NEW USERS: Posting images, links and code - workaround for restrictions.
    To get a useful answer, always state which PIC you are using!
    #10
    Gort2015
    Klaatu Barada Nikto
    • Total Posts : 3292
    • Reward points : 0
    • Joined: 2015/04/30 10:49:57
    • Location: 0
    • Status: offline
    Re: 12f683 timer1 gating questions. 2019/09/03 06:47:02 (permalink)
    +1 (1)
    "dont have much luck with hex either... 0x or h aint working for me. sigh. meh. binary feels easier for me. more like flipping switches."
     
    Bucko is back - Binary is bad-ass.
     
    I had the same experience with the letter, 'C' so I replaced it with the letter, 'K'.
    What a stupid kunt.
    post edited by Gort2015 - 2019/09/03 06:49:32

    MPLab X playing up, bug in your code? Nevermind, Star Trek:Discovery will be with us soon.
    https://www.youtube.com/watch?v=Iu1qa8N2ID0
    + ST:Continues, "What Ships are Made for", Q's back.
    #11
    mpgmike
    Super Member
    • Total Posts : 286
    • Reward points : 0
    • Joined: 2014/01/23 17:27:06
    • Location: NJ
    • Status: offline
    Re: 12f683 timer1 gating questions. 2019/09/03 07:51:45 (permalink)
    0
    I would like to make a few suggestions.  First, replace the antiquated & limited PIC12F683 with the newer PIC16F18313 (it is also an 8-pin PIC in spite of the PIC16F part number).  This will get you 7 Timers, PPS, IOC, and many other enhancements (room to grow).
     
    I have driven automotive injectors in many projects.  Set up one of your TMR2/4/6 Timers for the Injector Pulse Width resolution you need.  To clarify, if your resolution is 0.01 ms, then T2PR can give you 0.01 to 2.55 ms injector firing time.  At 0.1 ms resolution, your range is <25.5 ms IPW.
     
    Surely you have some sort of crank trigger, cam sensor, magneto, or other firing signal.  If you are using a TDC indicator (like a magneto on a small engine) you get 1 signal per revolution.  Crank triggers will give you more than 1 per rev, while cam typically gives one signal every other revolution.  Input this signal (with hardware filters so you don't fry the PIC) to INT0 or IOC.  When the signal triggers your IOC interrupt, turn the injector ON and start your Timer 2/4/6 and enable TMRxIE.  When the Timer times out, turn your injector back off, clear the IFlag & IE, and turn the Timer off.  With this approach, no trigger, no fuel.  Prevents flooding issues.
     
    Adding an analog input you control by turning a pot can allow you to tune your IPW: T2PR = ADC-8 value.
     
    Hope this helps.
    post edited by mpgmike - 2019/09/03 07:54:45

    I don't need the world to know my name, but I want to live a life so all my great-grandchildren proudly remember me.
    #12
    headsmess
    New Member
    • Total Posts : 16
    • Reward points : 0
    • Joined: 2019/02/22 03:13:43
    • Location: 0
    • Status: offline
    Re: 12f683 timer1 gating questions. 2019/09/18 22:31:58 (permalink)
    0
     
    just scoped the output cus of...curiosity... it was hella rich.
    ric

    Translated into plain English??

     
     a 20mS pulse rather than 1mS makes for 20x the expected fuel= filthy stinking rich with raw fuel spraying out the exhaust...
     
     
    experience tells me it shouldnt even start at 1mS.
    Context?
    Are you talking about the delay from your trigger signal on GPIO4 changing, until the output on GPIO5 changes?
     

    nope. im talking about minimum injector pulse time of 1mS shouldnt deliver enough fuel to even start, let lone run. especially when cold. and with the injector i was using.
     
     

    So, your delay should be roughly (500 * 3) / 1 MHz = 1.5ms
     

    thats what i was expecting...
     

    Could you temporarily enable CLKOUT on GPIO4, and observe that with your scope so as to:
    [1] Verify that you are running with a 4MHz clock ( you should see 1MHz on the pin)
    [2] At the same time verify that you have your scope set correctly. Some analog ones have a switch to expand the horizontal scale.
     
     
     

    leading me to conclude...
     
    COUNTA as specified by me, to be at 20h, containing 142...
    is not the same "COUNTA" that is actually being decremented but is another register created by assembler as its within a loop? a temporary W if you will.

    This is a pile of rubbish. Assembler does NOT do that sort of thing behind your back.
    Wierd effects are usually down to incorrect bank selection, but you are doing it correctly.
    I suspect you're not reading the scope correctly, or there's some other problem with your method of testing.
     
     


    actually...this is what it did... in a way. you may notice i failed to specify where the decremented result is sent... W by default, not back into countA (or B). from what i can make out, i was simply incrementing by 20 (or whatever it was) until it wrapped back around eventually to zero. the decremented result was simply going to W...then being overwritten.
    end result, unpredictable delay (unless i sit down and do the maths and say its exactly what i wanted!)
     
    anyway. with a new scope, and a new 1ms delay from piclist (which DOES specify)...i get exactly 1mS. perfect. fiddling with values loaded into the registers does as expected to my delay times.
     
    and of course, my fuel pump decided to stop making pressure the next morning so i havent even been able to test if it (wont) run with a 1mS pulse. another months delay waiting for parts. yay!
     
     
    post edited by headsmess - 2019/09/18 23:19:24
    #13
    headsmess
    New Member
    • Total Posts : 16
    • Reward points : 0
    • Joined: 2019/02/22 03:13:43
    • Location: 0
    • Status: offline
    Re: 12f683 timer1 gating questions. 2019/09/18 23:14:25 (permalink)
    0
    mpgmike
    I would like to make a few suggestions.  First, replace the antiquated & limited PIC12F683 with the newer PIC16F18313 (it is also an 8-pin PIC in spite of the PIC16F part number).  This will get you 7 Timers, PPS, IOC, and many other enhancements (room to grow).

     
    arrrrrgh! dont say that! my first selection was the 675, mainly because thats what jaycar down the road has in stock...someone pointed out the 683 has twice the room... as it stands...more timers and doodads means more datasheet to read through and more areas to make stupid mistakes in!
     
    when i move on to something a bit more grunty...ima increasing my pin count at the same time! this is just an experiment on how insane i can drive myself!

     
    I have driven automotive injectors in many projects.  Set up one of your TMR2/4/6 Timers for the Injector Pulse Width resolution you need.  To clarify, if your resolution is 0.01 ms, then T2PR can give you 0.01 to 2.55 ms injector firing time.  At 0.1 ms resolution, your range is <25.5 ms IPW.

     
    even easier actually. min pulse is automatically 1mS due to injector constraints. and from the datalogs i made when my original ECU was working...and various calculators... 3mS is about my max pulse. (at 12000 rpm, i only have 5mS per revolution anyway...) so i only need a base of 1mS, with a 0-2mS addition in 255 steps.

    Surely you have some sort of crank trigger, cam sensor, magneto, or other firing signal.  If you are using a TDC indicator (like a magneto on a small engine) you get 1 signal per revolution.  Crank triggers will give you more than 1 per rev, while cam typically gives one signal every other revolution.  Input this signal (with hardware filters so you don't fry the PIC) to INT0 or IOC.  When the signal triggers your IOC interrupt, turn the injector ON and start your Timer 2/4/6 and enable TMRxIE.  When the Timer times out, turn your injector back off, clear the IFlag & IE, and turn the Timer off.  With this approach, no trigger, no fuel.  Prevents flooding issues.

     hardware filter=optocoupler. the first parts i soldered in place.
     
    im approaching it a bit differently...
    i have one pulse, sure enough, but in reality i have two. leading and trailing edge. for now, im just seeing if i can count the clock cycles between input reading low (logic low...) and high..., or, basically, reading the duration of my zero crossing...
    from what i could scope in the few seconds i did have it running faster than cranking speed, my input signal length is proportional to the RPM. so i do have a definite timebase i can measure.
     
    if, in the near future, it proves to be not such a good approach...the trigger tooth has more than enough length to file it into two teeth.
     
    i just want to get the RPM value in as short a time as possible, rather than wait an entire revolution of several million clock cycles for each successive pulse. even with prescalers, i fear overflows...
     
    and with as little modification to the engine itself as possible. ie, no extra sensors (im trying to get RID of the pesky things here!) and no parts i may have to make (plus i covered up my cam sprocket with an oil pump so its no longer accessible...)
     
    as for flooding and starting/choke/enrichment... i envision two simple buttons. one is fuel cut. one is choke. press whilst cranking for no fuel/extra fuel. may run the choke idea on a timer for say, 1 minute... so if it floods you can dry it out, and when cold...it may actually start!

    Adding an analog input you control by turning a pot can allow you to tune your IPW: T2PR = ADC-8 value.
     

    lol, this is what the MAP/TPS is for!
     
    (actually, it sounds like an attempt i made once using a 555... quite good for a generator or similar constant load/rpm system...akin to adjusting a jet.)
     
    the whole approach is fuzzy. fuzzy! nothing has to be absolute, just approximations.
     
    two interesting papers...
    the one i read way back in highschool...98 i think.  yeah, im slow!
     
    https://www.researchgate....trol_using_fuzzy_logic
     
    the one i found a few weeks ago that finally solved the conundrum i faced now ive started applying myself...how to implement fuzzy logic in actual CODE?
    http://phaedsys.co.uk/principals/bytecraft/bytecraftdata/bcfuzlogic.pdf
    every thing else ive found on fuzzy logic obfuscates the basic idea in a plethora of jargon without ever explaining just how SIMPLE it actually is! definitely make no mention of basic coding methods. its just comparisons and a bit of basic number crunching...
     
    #14
    mpgmike
    Super Member
    • Total Posts : 286
    • Reward points : 0
    • Joined: 2014/01/23 17:27:06
    • Location: NJ
    • Status: offline
    Re: 12f683 timer1 gating questions. 2019/09/19 06:52:29 (permalink)
    0
    I confess, I use some type of Human Interface Device (HID) for tuning.  I create X-Y tables, where X = RPM and Y = TPS/MAP/Load.  The first block is cranking, so that's where I put my "choke".  Compensation tables add warm-up schedules (gradually remove the choke).  You can do this without a HID by creating a table in your firmware.  You have to reflash the PIC every time you want to make a change, though.  With an 8 X 8 table, choosing the correct cell is (Y * 8) + X.  A switch (Select Case) in C (BASIC) sorts through current values to find the correct cell.  In ASM, subtract your current value from the first threshold and check your STATUS.Carry/Borrow bit.  BTFSS or BTFSC command can send the PC to the line of code that contains the correct cell number for your current value (RPM or Load).  Otherwise, up the subtract value to the next threshold & test again.
     
    Blending between tuning blocks is by the Slope formula:
     
    Y = Y1 + ((X - X1) * ((Y2 - Y1) / (X2 - X1)))
     
    Where:
    Y = Desired IPW
    Y1 = IPW Value of lower cell
    Y2 = IPW Value of upper cell
    X = RPM
    X1 = RPM threshold of lower cell
    X2 = RPM threshold of upper cell
     
    Usually the formula can be simplified significantly with basic algebra.  Hope this gives you ideas.

    I don't need the world to know my name, but I want to live a life so all my great-grandchildren proudly remember me.
    #15
    headsmess
    New Member
    • Total Posts : 16
    • Reward points : 0
    • Joined: 2019/02/22 03:13:43
    • Location: 0
    • Status: offline
    Re: 12f683 timer1 gating questions. 2019/09/24 05:15:39 (permalink)
    0
    now ive just confused myself... lol.
     
    dont worry, im taking all this on board. there are dedicated EFI chips and the like for the future. all these snippets are worth tucking away in ones head. but for now im determined to approach it a certain way, and thats the way im sticking to figuring out for myself. fuzzy. i think i got it all sussed...ha ha.
     
    i should start a new thread as this is getting way off topic.
     
    this was about gate triggering, which i havent even started to code for, lol...
     
    new thread...
     
    #16
    headsmess
    New Member
    • Total Posts : 16
    • Reward points : 0
    • Joined: 2019/02/22 03:13:43
    • Location: 0
    • Status: offline
    Re: 12f683 timer1 gating questions. 2019/09/25 01:37:32 (permalink)
    0
    if i could start a new thread. hmmm. access denied on this server...
     
    what have i done?
    #17
    Jump to:
    © 2019 APG vNext Commercial Version 4.5