1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Project Turbo Honda CUB. DIY EFI.

Discussion in 'Other Projects - Other Bikes (non 250's)' started by gyro gearloose, Jan 8, 2024.

  1. gyro gearloose

    gyro gearloose Active Member

    Messages:
    96
    Likes Received:
    92
    Trophy Points:
    103
    Joined:
    Feb 27, 2023
    Gender:
    Male
    Location:
    sydney
    My Bike:
    variable
    where to start? definitely not at the beginning as this project was started... awe hell... a decade ago? when did the VZ21 start being available cheap cheap?

    setbacks, learning curves, depression, waiting for the postie to show up with pressies... and a few exhilarating moments! like having the throttle stick and bailing as it ploughed WOT into the garden... WEEEEE!

    will it even get finished? i hope so, im getting close now!

    i might dig through my old hard-drives and find early pics, but unlikely...

    so.

    started off as a cub 50 sitting in a shed.
    rusty orange/red.

    back when i was on a honda/c90 phase.

    i discovered that the lifan/china clones would bolt into the 50 and 70 frames, not the 90 or 110 frames.

    so it got a lifan 140 shoved in. and man, lifan 140's really take some abuse. once had a road legal pitbike (deathtrap "Yamoto Explorer" if anyone has ever heard of them... shouldnt have ever even gotten compliance! and, omfg, the drama of getting rego, um... tier2 inspection? sold from QLD, so interstate...) and with a set of highlift cams... it pulled 140km/h. and that was with half the spokes snapped in the rear rim! (felt it was a bit wobbly one day? and that started a whole different saga of trying to find parts for a bike that seemed to have no standard part on it... at ALL! even its poxy 125 engine had a different rod and cylinder to all comparable pitbike engines... meaning it had different stud bolts, and yeah... never found replacements, and it was only after destroying it attempting to put the longer M8 studs from the 140s in rather than the M6 that i discovered the hondas used M7! sigh... whatever... another story)

    so, at some point, i got a VZ21. threw it on... and learnt all about setting up blow through carbs.

    ditched that idea, got myself an ecotrons EFI kit.

    set it up all dodgy like... some of the only decent runs i got on the thing. only reason i have persevered! freaking awesome, turbo spooling up, whistling through the corners at WOT (who needs rego when you got rural roads?), getting peaks of 16+psi... (later determined to be a load of BS as it was simply the lack of plenum chamber, the small volume of the intake manifold gives a false reading, as one figures out after going through datalogs).

    harness was junk. some roll of multi coloured wire, new plugs, lots of crimping... new harness!
    made the mistake of assuming the two black power grounds were well connected in the ECU. one very simple mistake. worked fine... until i put FUEL in it! the extra load on the pump fried whatever link it had internally, one dead ECU...

    got a new one. it wasnt a genuine ecotrons, was the ebay special, but it WAS the ecotrons, just sold direct rather than their overpriced online store (trust me, you get an email back from them with the same address? its the same people!) the guy sent me a whole bunch of TBs and other stuff along with it... and hasnt answered an email since...

    so, it lasted fifteen minutes before it decided to go the same way, wouldnt connect to the PC, and yeah... no more tuning from there on.

    sits in shed for five years.

    decided i would go back to carb.

    pressurised tank, blow off valve, intercooler... sorted out issues with say, when backing off the TANK HAS TO VENT!!!! otherwise, you get a blast of raw fuel straight back into the manifold.

    need a BIG line, 1/2 inch at least. baffles. surge tank. stuffed the ct110 tank i had bought, should have welded rather than brazed... plus the ct110 tank is ugly and too fat...

    and that was when i put it into the garden.

    and that, with a plenum chamber of PVC, was a GENUINE 10psi at just half throttle, getting up to over a bar on the few WOTS i managed. oh yeah! clutch slip all the way! she SCREAMED!!!!

    so. then i had this niggly feeling it may not pass the engineers check, having a pressurised tank...

    move onto putting a fuel pump in the tank... REALLY made a mess of it at that point...

    oh? its really hard to get a regulator to deal with carbs from a 45psi pump?
    no issue if it was a V8, but on a postie? ROOM IS SCARCE!

    sigh.

    and so, i moved onto to something that lurked in my head since '99, highschool, early internet days...

    (um...why does insert link redirect me then not redirect me back? the story of my life!)
    https://rjhowlett.co.uk/papers/2004-2.pdf

    so i got into programming a "pic chip" and learning what this fuzzy logic was all about! ive forgotten more than i learnt!

    the program from that paper, it had a demo version, let me get an idea of the maps one may expect...
    they also wanted 5000 euro for the software!!!! um? are you for real?

    matlab? nope. gotta pay!

    mr howlett... any chance you still have the source code?
    "no... sorry"
    erm... so yes. fuzzy logic...

    i figured it out...

    and how to write it in assembly language. im no programmer. i hate technology unless it has carbs...


    ok, and now im getting java script errors and my pics arent uploading so i better hit "create thread" and break this into chapters...
     
    • Like Like x 1
    Last edited: Jan 8, 2024
  2. gyro gearloose

    gyro gearloose Active Member

    Messages:
    96
    Likes Received:
    92
    Trophy Points:
    103
    Joined:
    Feb 27, 2023
    Gender:
    Male
    Location:
    sydney
    My Bike:
    variable
    oh. it had logged me out....

    so, the rustbucket el deathtrap as it is right now...
    RH.jpg

    yes, that is the front end off of an R15 on there. no, they are not bolt on, the head tube needs a longer shaft, chop chop, turn turn, weld weld...)

    decided im going to keep the stock tank until a ct90 of the right year shows up. the first two years had the same style tank, just an extra 2L. the ct110and the later ct90s have the ugly tank... look at a postie, youll see what i mean. the c90 has an internal tank, with the frame being one big smooth curve... and yeah, the engines dont bolt straight in... just the 50s and the 70s... (also the SL which is the IDEAL frame, imho! and appear to be made from unobtainium in australia? ive only ever seen one and how i wish i had grabbed it! sigh. windsor wreckers, long gone... i miss wreckers where you could clamber over precarious piles of junk, mixing and matching and poking your nose into things... penrith and st marys were the same... you could make hella frankenstein builds back then!)
    so, where was i?
    i learnt to cast aluminium, make a pattern and greensand and all that jazz...
    first_casting.jpg
    made an intercooler. that took some hunting to find the ideal core! found pitot tubes dont work on bends... need pitot tubes to do blowthrough carbs properly, and they need smooth laminar flow. i could only get carbs to run on a PVC plenum, with the IC it just refused to play ball...
    the things been chopped and modified several times, and its going to get chopped again...
    InterCooler.jpg


    and so, we are back to the EFI, fuzzy logic, pic chips.
    ECU+header.jpg
    my latest board, with debugging header and chip.
    may never need the debugger, but theyre rare as, and you have to use the header as the chip has extra legs so it can actually communicate when debugging... the actual chip, pic12f683, has 8 pins. super restrictive!
    debug_header.jpg
    so why such an awkward chip? well, along with that paper on fuzzylogic, i recall someone mentioning making an ECU from an 8 pin device. i think it was the same guy that developed megasquirt.
    and if im going to learn how to code, why do something easy?
    >masochistic bastard<
    why not mega/microsquirt? why not speeduino?

    why linux and not win11?
    BLOAT!
    extra unwanted features!
    code that for the life of me, i cant figure out how to hack and re-write!

    such as, how to alter the way it detects crank angles, and associated timers? i figured out how to NOT need a toothed wheel, or a second trigger on the camshaft. but i cant figure out how to implement it on speeduino...

    i dont WANT OBDII. i dont need scanning, or canbus, or eight injectors, or a board that costs me $300+, or drivers for coils on plugs...
    im not going to use IAT, or ECT, or knock sensors, or O2 sensors. im not even going to use a TPS unless i find its absolutely necessary!
    (refer back to paper... MAP, and crank/RPM... and no more!)
    https://rjhowlett.co.uk/papers/2004-2.pdf
    ooooh, it worked this time! lesson learned... make sure logged in ;)

    no, all i want is a little board that i can jimmy onto basically anything, and at best, has two trimpots for hi/lo so its much like tuning a chainsaw carb... THEY dont need no IAT or knock sensor!


    anyway. my first code, my first "hello world", was simple. detect the crank trigger, and turn injector on for 1mS. no more, no less.

    she fired up and spluttered away on the first kick. hell rich as it was injecting every revolution... but WOW!

    so the next morning?

    ecotrons strikes again!!!!!!!

    the pump failed. the last remaining piece from that POS kit, and it failed....

    a few more years in the shed!

    and here we are today...

    ive already posted a few pics elsewhere as i make a little external subtank for the pump i have, but hey, heres where its at at the mo, waiting for an end plate and a (rusty? wtf? how does acrylic RUST? i LOVE rust! :oops:) chunk of perspex to act as a fuel gauge come access hatch...

    rustyacrylic.jpg
    i knew i was low on gas! five minutes after i put the torch down a mate rings, needs a sump from a truck fixed up quick, sure! yep... i ran out of gas with half the weld done... EFFIN! its always something! oh well. i finished THAT with the stick, no probs.
    at least when you run out on steel, its just a bit of foam to grind out. on ali? BLACK SMUT! (i always think of the ad for the black stump restaurant chain when "welding" ali!

    so now i have gas, and yeah... other things. i might get this tank finished tonight, at least, and then...

    THEN IM FINALLY BACK TO WHERE I LEFT OFF!!!!!!

    except... i serviced the R15... and saw what it uses as a pump? i couldnt help myself!

    R15pump.jpg
    that is TINY!!!!!!

    the ecotrons used much the same as the larger one, but had it jammed in an utterly useless case with a stupid 1/2" line that required an adapter and yeah, was a complete PITA, so im glad it died when it did, in hindsight.

    regards that R15 pump? its brushless, aka bldc, aka 3-phase. needs an ESC. hunted around a bit, no luck finding one that just turns on at full speed when powered up... then it clicked... the PLUG is the ESC!
    anyway, it may not have the flow rate but it can sit in the parts box and i will look into that one day...

    for now... i gotta finish this pump i started, (made sure i got a spare one of those!) and yeah... throw some code onto the pic-chip (changed pinouts, gotta do some re-writing...)

    and then, it will be alive once again! albeit coughing, spluttering, with no mixture control or anything, still only at the "hello world" phase :)

    and then i can actually start playing with interrupts and dealing with actual data inputs, like ADC for the MAP, interrupts... methods of controlling the injector...

    next chapter... some valuable information about EFI ;) things ive learned that you wont find anywhere else! (unless i wrote it?)
     
    • Like Like x 1
    Last edited: Jan 8, 2024
  3. gyro gearloose

    gyro gearloose Active Member

    Messages:
    96
    Likes Received:
    92
    Trophy Points:
    103
    Joined:
    Feb 27, 2023
    Gender:
    Male
    Location:
    sydney
    My Bike:
    variable
    things always take longer than expected...

    a major issue with EFI... how to get power to the pump? grounds easy. just earth one terminal inside. but to get positive in there?
    20240119_165432.jpg
    enter PEEK, ermmm... polyether ether ketone or something? whatever. recess for the O-rings, allowing for "squish", DRO comes in handy, makes it a five minute job :)

    part off brass and curse. still needed an M5 thread at one end... meh, wasnt actually an issue, just use a different collet to what i was planning.

    finally use that hex collet block to make a nice 10mm hex so i can get a spanner on it...


    and i was about to weld all this stuff together, but yeah... somethings still missing...
    20240119_170031.jpg
    two things... 8mm hole for the bulkhead penetration, and the holes to attach that acrylic? meh. gotta clear some junk off the mill.
    two barbs, one is for getting air out? just hook it up to the reserve line, plan is the acrylic becomes the fuel gauge... if theres air, its empty! lol...

    and then clench glutes and cross fingers hoping i weld this rather than make a mess... sigh. sometimes, welding ali requires getting mentally prepared?

    i said i was going to talk about certain design elements of EFI software, wasnt i?
    well, i'm not... yet.
    once i got a vid of it at least spluttering away on the basic "hello world" code again. THEN i will be in the mood. because thats when i have to actually dig back through my notes...
     
    • Like Like x 1
  4. gyro gearloose

    gyro gearloose Active Member

    Messages:
    96
    Likes Received:
    92
    Trophy Points:
    103
    Joined:
    Feb 27, 2023
    Gender:
    Male
    Location:
    sydney
    My Bike:
    variable
    well, now it really IS time to get the welder going... sigh... this is the scary part, destroy all my good work...

    a while ago i invested in a bunch of collet chucks for my (still in pieces) CNC mill... man, they are a gamechanger!
    colletchucks.jpg
    so, one has to practice the task of doing CNC work on a manual machine...
    that is, putting tools back in the same spot every time, and running through a standard set of processes... as if one actually has the auto toolchanger set up... ha ha!
    would be a bit different on CNC, just run through all the holes then change tools. but yeah, manual involves counting out turns on wheels... a simple job like this was a complete nightmare using a standard chuck and swapping bits every time... either inconsistent tool depths, or stuff up at least ONE hole position...

    so. pilot/center drill.
    pilot.jpg
    tapping drill for M3, punch through into acrylic saves reloading the center drill.
    tap_drill.jpg
    clearance drill for acrylic. 1/8" aka 3.2mm
    clearance_drill.jpg
    counterbore for head of bolt. 6mm endmill. set stop for consistent depth...
    counterbore.jpg
    looks almost profushenal, except something feels wrong...
    uhoh.jpg
    well, that proves its at least accurate? round the right way now! always check for correct orientation BEFORE drilling holes!
    phew.jpg
    just gotta tap them holes, and then...

    welding time! thats everything...
    welditupalready.jpg


    except a mounting lug to bolt the thing in place but that can come later...
     
    • Like Like x 2
  5. gyro gearloose

    gyro gearloose Active Member

    Messages:
    96
    Likes Received:
    92
    Trophy Points:
    103
    Joined:
    Feb 27, 2023
    Gender:
    Male
    Location:
    sydney
    My Bike:
    variable
    pump in, no leaks. so far so good.
    pump_front.jpg
    sort of wish i had welded threaded bungs in, instead?
    pump_rear.jpg
    holds fuel. thats good.
    pump_firstfuel.jpg
    pump runs. better.
    pump_run.jpg
    carefully mounted in frame, ha ha.
    pump_full.jpg
    yep, still holds fuel. still no leaks.
    pump_inside.jpg
    really had to search to find the bit of hose...where was it? on the bike. lol.
    no point cutting to length until everythings actually located properly.
    pump_outlethose.jpg
    mmmm, throttle body....


    oh well. i guess its time to pop up a video...
    https://www.youtube.com/shorts/FcJ83VtzrEY

    fine. "cant embed media"... link will suffice, i suppose.

    right. next time she will be running...
     
    • Like Like x 3
  6. gyro gearloose

    gyro gearloose Active Member

    Messages:
    96
    Likes Received:
    92
    Trophy Points:
    103
    Joined:
    Feb 27, 2023
    Gender:
    Male
    Location:
    sydney
    My Bike:
    variable
    SHE RUNS!!!!!!

    ok, had an issue with the injector driver... not sure what i did there but once it turned on it sure didnt want to turn off.

    got some things out the way around the place, tore some components out, procrastinated... then back to the soldering iron.

    was it worth it?

    i guess so!


    making sure the driver works...

    https://youtube.com/shorts/FHB4LgVm36U?feature=share

    and now, the culmination of much swearing, hair pulling, screaming, throwing things around... its party time!

    https://youtube.com/shorts/KvjeJCDlaC4?feature=share

    i really did not expect it to fire on the first freaking kick!
    :imtheking:

    time to go party...:party:

    because... i really need a break and to get in the right head space for whats about to come... this is NOT going to be easy!:headbang:
     
    • Like Like x 1
  7. ruckusman

    ruckusman White Mans Magic Master Premium Member Dirty Wheel Club

    Messages:
    3,237
    Likes Received:
    1,423
    Trophy Points:
    918
    Joined:
    Oct 1, 2013
    Gender:
    Male
    Location:
    Narrabeen, NSW Australia
    My Bike:
    Yamaha FZR250 3LN1
    That's impressive first kick
     
  8. gyro gearloose

    gyro gearloose Active Member

    Messages:
    96
    Likes Received:
    92
    Trophy Points:
    103
    Joined:
    Feb 27, 2023
    Gender:
    Male
    Location:
    sydney
    My Bike:
    variable
    well, time for an update. whats happened thats new?

    nothing :)
    not one line of code yet. lol.

    so, i got the first hello world program.
    in assembly language, on a pic chip, this is what you have to deal with...

    #include "p12f683.inc "
    ; __config 0xF0D4
    __CONFIG _FOSC_INTOSCIO & _WDTE_OFF & _PWRTE_OFF & _MCLRE_OFF & _CP_OFF & _CPD_OFF & _BOREN_OFF & _IESO_OFF & _FCMEN_OFF


    ;scratch starts at 20h
    cblock 20h
    COUNTA
    COUNTB
    endc

    ORG 0x00 ;processor reset vector
    BANKSEL GPIO ;00h
    CLRF GPIO ;all pins clear to 0(except gp3)
    CLRW
    MOVLW b'00000111'
    MOVWF CMCON0 ;comparator OFF, all pins IO.
    CLRW
    MOVLW b'10110101'
    MOVWF T1CON ;tmr1=ON,activehigh,1:8prescale,intclk(fosc/4)
    BANKSEL TRISIO ;80h
    MOVLW b'00011100'
    MOVWF TRISIO ;GP5,1,0=output,GP4,3,2=input
    CLRW
    MOVLW b'00010100'
    MOVWF ANSEL ;Fosc/8, AN2 analog.
    CLRW
    BSF GPIO,5 ;injector OFF (negative logic on FETdriver)


    start: CLRF COUNTA
    CLRF COUNTB
    CLRF TMR1L
    CLRF TMR1H ;clear files.
    BANKSEL GPIO ;00h
    pollHi:
    BTFSS GPIO,4
    GOTO pollHi
    pollLo:
    BTFSC GPIO,4
    GOTO pollLo
    CLRW
    MOVF TMR1H,0 ;move timer1 count to W
    MOVWF RPM ;move W to RPM
    COMF RPM,1 ;high value=lowRPM. invert so low value=low rpm

    CLRW
    MOVLW .10 ;delay loop repeat
    MOVWF COUNTA
    CLRW
    BCF GPIO,5 ;injector=ON
    loop:
    MOVLW .50 ;delay loop base
    MOVWF COUNTB
    dc:
    DECFSZ COUNTB,F
    GOTO dc ;decrement COUNTB unless=0
    DECFSZ COUNTA,F ;decrement COUNTA unless=0
    GOTO loop ;repeat COUNTB times
    BSF GPIO,5 ;injector=OFF
    GOTO pollHi ;return to poll

    end


    simple, huh?

    that is, basically a loop checking for a crank signal.
    then checking to see that there is no longer a crank signal.

    then open injector, and a loop of two registers being decremented. first register reaches zero, second register gets decremented, then first register is decremented to zero, and then when both registers reach zero, turn injector off, and go back to waiting for a crank signal.

    no tuning, no nothing. it was supposed to be 1mS per injection.... and after scoping, it ends up being 1.5ish mS per injection. 3mS per cycle... no wonder she belches black smoke! not sure what went on with the maths there...

    and well, that approach gets it running but is a total dead end. basically... i get into the loop of PollLo, or PollHi, or "injector on", etc... i cannot do ANYTHING ELSE. so i have t assign values to a timer, and whenthat timer hits zero, THEN i get an interrupt and its time to turn the injector off... or deal with data... or do an ADC, etc.

    i now have to deal with interrupts, and a whole new way of doing this. uh oh...

    so...
    i have a gated timer from the crank signal. when input is HI, its timing. tick tick tick... and when its low, its finished timing, and i have a value stored in registers i can deal with...

    a gentle crank by hand gives me approx 150mS between pulses, or approx 400RPM. any lower and im not even getting a signal, and yeah, if youve ever kicked a pitbike over really slow? its not a good idea, even when they DO have decomp and antikickback mechanisms fitted! one firm, HARD kick!
    so. 400RPM would appear to be a good "min speed", and that makes thingg reasonably easy...ish...


    at 4MHz, timer counts at 1/4 of that. 1MHZ.
    that gives me 1000 counts/mS.
    i can scale that down. 500-2:1. 250-4:1 125-8:1.

    prescaled at 8:1, it basically means that if i count 750 pulses, 6mS has elapsed, and that equates to approx 400RPM. neat, huh?

    then, it also means...
    375=800RPM.
    187=1,600RPM
    94=3,200RPM
    47=6,400RPM
    23=12,800RPM...

    notice how the resolution HALVES, for every DOUBLING of the RPM? this sort of doesnt matter though, as one really only needs the resolution of the actual RPM at lower speeds...

    the timer is 16 bit. two registers, HI and LOW.

    if the high register even gets a count, then ive counted at least 256 pulses, and that comes to approx 1200RPM, or about somewhere between 187 to 375 counts.. it basically means its idling, or just above idle. any RPM higher than this, i can discard tmr1H, and only have to worry about TMR1L.

    now some challenging stuff.

    i load the high register with binary 1111,1100. or FC for those that like hex? or 252 for those that stick to decimals...
    the timer starts timing.
    IF it overflows, i get an interrupt, and that means i have over 750 pulses.
    and that means its BELOW 400RPM, and to not bother doing anything at all. just go back to waiting for some type of interrupt, a crank signal, etc.
    but. if i count (binary) 0000,0011... then i have anywhere from 768 to 1023 pulses (its 16 bit, but theres no point dealing with the lower 8 bits in TMR1L yet). its still below 400RPM, still dont bother doing anything.

    the most important thing is to determine if its actually revving its tits off...

    so, it seems i have to do this...

    subtract my original value of 1111,1100 to get back to the actual count, i only stuffed that in there to force an overflow and interrupt if it isnt turning over at all...
    decrement register by 1, skip next instruction if "zero".
    the next instruction being "goto RPM_MATH", or...

    it is cranking, it is above idle, and the high register has no count in it at all, and can now safely be ignored, so main priority is to determine if its revving its tits off...
    OR, tmr1H did get a count... IF it was 0000,00011, then a decrement will give 0000,0010. if it counted 0000,0010, then decrement will give 0000,0001)
    BTFSS (or) BTFSC TMR1H either bit 0, or bit 1...

    again, skip next instruction depending which bit i check, and if its "set" or "clear"... can do either here.

    see how much of a head trip this actually is? i have to move values around, determine if theyre within a range, determine what that value is, as fast as possible, as it may very well be redlining, and when one is doing 12K rpm, there is 5mS a revolution. and an injector generally can only open for 85%, so i have to stay within those limitations...

    anyway, my next step, my second "hello world", is asically going to be some sort of refinement of

    CLRF TMR1H
    MOVLF '1111,1100" TMR1H
    GOTO INT_LOOP (a short loop where it just waits for some sort of interrupt... ANY interrupt...)
    upon exiting the interrupt loop, and knowing that TMR1 has finished timing the crank trigger pulse without actually overflowing, i can now do something with that data...
    SUBLF 1111,1100 TMR1H
    MOVF TMR1H, RPM_RAW. (dont want to mess with the value in TMR1H, so i gotta copy it to a new file)
    DECFSZ RPM_RAW
    GOTO RPM_MATH (this will be a new path in the code to determine just how fast its spinning, as i have determined that it IS OVER approx 1200RPM, and this is the priority)
    BTFSC RPM_RAW, 1
    GOTO INT_LOOP (do this as if bit 1 is set, it means i am still below min cranking speed, and dont need to inject etc... vice versa, BTFSS, 0 will give the same result )

    NOW, i have to load a value into a different timer, and wait a while, before doing an ADC on my MAP sensor. basically, about 8-10 times the length of my crank pulse puts me at a good spot on the intake stroke to get a good MAP reading.
    so that will be something like
    MOVLW 127
    MOVWF TMR0

    or basically, shove a value into TMR0 register, so that when it hits zero, it throws an interrupt, and at that point, i can start my ADC for the MAP signal... of course, when i am over idle, or, TMR1H has no count... i can just use the 8x value in TMR1L for this delay.

    and this is before doing anything involving "tuning"... this is SIMPLY TO GET A CRANK TRIGGER! and also sort it out if its "no crank", "IDLE", "MID RPM", or "HIGH RPM", that sort fo ties in with later stuff dealing with the fuzzy logic...



    ARRRRGHHHH!!!!!!!!!

    if you thought this was confusing? you should see just how many pages of notes and calculations i have written down over the last few days to get to this point!


    oh well. for now, the second "hello world" will still have no tuning, im just going to get to the point that im either not injecting below "min speed", and am still just firing off the injector for 1mS when i DO have to inject... make sure that i AM getting a crank signal, and my logic is working, and i dont simply get stuck in a loop "of no return"... make sure interrupts work as expected...


    im no programmer. this is my first project ever on a pic chip... i did a bit of arduino, but thats in C, and thats just tuning in a 3d printer, all the codes written down already...

    why the masochism? why assembly? why a pic chip?

    because 1, C can be "bloated", it has some peculiar procedures at times, and with limited space in memory, a program it creates may be too large to even load.
    2, i dont know C. the first instruction is almost always "void", and when i see "void", i think of lottery tickets, lol... or "warranty void"...

    assembly actually sort of makes sense, and i was always the type of person that likes to know how something REALLY WORKS. this modern age, too many people just rely on some program to do everything for them...

    and well, pic chips? i just have this determination to do it on a device that to all intents and purposes shouldnt be capable...

    big learning curve!

    one
    step
    at
    a
    time.
     
    Last edited: Feb 11, 2024
  9. Murdo

    Murdo The Good Doctor Staff Member Contributing Member Ride and Events Crew

    Messages:
    6,400
    Likes Received:
    4,788
    Trophy Points:
    1,148
    Joined:
    May 4, 2013
    Gender:
    Male
    Occupation:
    Retired
    Location:
    Tamworth, NSW
    My Bike:
    1937 Royal Enfield 250, CF Moto 250 V5, Honda's XL250, CBR250, FT500 plus a few others.
    Now I remember why I stick to carburettors. :idk:
     
    • Agree Agree x 3
  10. gyro gearloose

    gyro gearloose Active Member

    Messages:
    96
    Likes Received:
    92
    Trophy Points:
    103
    Joined:
    Feb 27, 2023
    Gender:
    Male
    Location:
    sydney
    My Bike:
    variable
    indeed!
    only going this route as the alternative is oversized automotive (and expensive) regulators for carbs under boost, and or running pressurised tanks, which i think i mentioned... wont get engineer approval for registration. with the pump set up, i could just strap a carb on, but yeah... boost. regulator. a holley dual stage is huge. and expensive. the bike is small. and was "free" at one point :)

    that leads to the drawbacks of EFI, that most people dont get... it definitely is not the "wonderful cure-all" that we are brainwashed to believe...
    take that souped up ricebox to the tuners. plug it into a dyno. belch up cash and theyll plug in their OBDII "tuner studio".

    show you all the graphs, nice fancy pictures. tweak this, adjust that... aww, just advance the ignition at 4,150 RPM a few degrees, add some fuel at 3,400...

    ALL OF THAT EQUIPMENT HAD TO BE DEVELOPED IN THE FIRST PLACE. just like the puter or phone youre using right now... people like steve wozniak spent years in a garage tinkering with logic gates and transistors to get to the point where we are, GUIs masking everything, simply getting a mouse do the simple job of moving a cursor is a freaking task in itself at the basic circuit level... we simply dont notice it... plug in that 128GB SDcard, maybe go and have a chuckle at old 3.5" "floppy discs" with their "100MB", or "DVDs", or even... oh my... 5.25" "floppies"... how about PUNCH CARDS? "but they got to the moon on something with less computing power than my mobile phone"... yeah, with data stored in little ferrite rings... and a really weird "language" to program it... voyager I and II need "specialists" that can deal with "obsolete" programming languages and hardware... and those things have been floating around in space for what, fifty years or more now?

    off topic! lol. naw, its true... we get spoiled. just a flatscreen "oled" tv screen is an amazing amount of digital code, little transistors doing their thing... that the average person has no inkling of... "but i used a HDMI port!"

    :confused:


    so EFI... its about time constraints.

    the chip? they run fast. real fast. i can push this thing of mine up to 8MHz. it can do 20MHz with an external oscillator. and thats actually still SLOW by modern standards.
    it doesnt make life easier. it doesnt improve performance. if anything, it makes it HARDER. suddenly, my numbers get twice as large. you start getting overflows in registers that are counting, have to perform 16 bit maths on 8 bit devices, and the programming side of it all gets more and more complex.

    a computer CANNOT SUBTRACT. or DIVIDE. well, it CAN divide by TWO? thats actually easy. but to divide by three? seventeen? ARRRGH!!!!

    to perform a subtraction with digital, you actually ADD. called "the compliment of 9s"

    0=9,1=8,2=7, 3=6, 4=5.

    say 73-57.
    we whip out a piece of paper and a pencil.

    3-7...cant do. cross out the 7 of 73, replace it with 6. we have 13-7. =6
    the 6 we scribbled in (remember "borrowing" from primary school?) 6-5...=1

    in the end... 73-57=16. tada!

    the puter cant scribble things down and jot in a new number. it needs a file to store that in, somewhere to tell itself what its doing... it cant "see" the entire number, it doesnt know what the next number is... it only is working on the digit it is working on at the time. and that number, in a puter, is just "ON" or "OFF"...

    COMPLIMENTING is dead easy in binary...

    0001 is 1.
    1110 is the compliment, is 14.
    as its four bits, its easier to deal in "hexadecimal".

    compliments of F's!
    0 is F, 1 is E, 2 is D, and so on. (got ahead of myself here...)

    theres a whole series of binary codes that make this easier for decimal, etc... "greys code", or "excess3", but thats another area that would need explaining... just rest assured, its REALLY EASY for a computer to "compliment" a number, and because of this, its REALLY EASY to ADD numbers.

    the programmer has to tell the puter where it will store any "notes" it has to jot down. the puter has to go and access those notes (files)... it cant simply swap back and forth between digits, telling itself its carried, its borrowed... your "8bit" device needs an extra bit to be able to borrow, to carry, and extra instructions to do so. needs extra components, extra transistors and logic gates... very very intelligent men spent years sorting this sort of stuff out, reducing circuits to the bare minimum... :bowdown::bowdown::bowdown:

    it gets really really complex. (and im no programmer, yet if you asked most "modern educated programmers" this stuff they would go into hysterics as theyre taught "languages" like C++ or PyPy... not the fundamentals workings of shift registers and the like)

    back to 73-57.

    compliment 57. it becomes 42.

    73+42=115.
    take the 1(hundred) and add it to the end as we subtracted... to "carry" a 1 in binary/digital, is easy... we "overflowed".
    16.

    in binary its a lot simpler, but harder, and yeah... it does make sense in the end. bit hard to explain in a post?

    ok, thats some of the maths out the way, whats another issue of EFI? the MAJOR issue?

    the injector itself. its a solenoid. a mechanical device with moving parts. they have a "flow rate". fuel pressure is standard at 43 psi.
    the injector can deliver so much fuel per minute, hour, whatever.

    an engine, with varying throttle positions and loads consumes so much fuel per minute, hour, second, cycle....

    stoichiometry... we ideally "want" 14.7 air to fuel ratios. we go down to 12:1 when accelerating, we go up to infinite:1 when backing off (fuelcut on decel). every M^3 of air weighs approx 1.2KG, and that needs about 90grams of fuel for 14.7:1.

    when an engine is idling at say 1000RPM, we have plenty of time for the mechanical injector to deliver the fuel required. 50 or so milliseconds per revolution. 100 milliseconds or more per four stroke cycle. and the injector has a minimum open time of say, 1.2 milliseconds. thats about "standard".

    we actually have the issue that the injector may deliver TOO MUCH FUEL. they have a minimum "ON time", as they bounce and chatter, and or dont even open fully when pulsed too rapidly. and that throws off the amount it delivers. the throttle body itself is designed to get around this, with an "air bypass circuit" rather than adjusting the butterfly or slide like a carb does... and the developer "cheats" by injecting too much fuel, the minimum they can inject reliably, once every three or four "fourstroke cycles"... we hear the engine "loping" and call that "powerful". blame the camshafts for the lumpy idle... thats only part of the story!

    anyway... we need an injector small enough, so at idle, it can open for long enough to open reliably, and deliver the precise amount of fuel. no-one wants an excessively rich idle!

    we go to the other extreme... we rev our little CBR or FZR to 18,000RPM.... now we have 3 MILLISECONDS per revolution... 6 mS per fourstroke cycle...

    there isnt much difference between 1.2mS minimum time, and 3mS of total time available.

    an injector is also rated at "85% duty". it has to close. it takes time. they bounce. they need a "rest" so they can settle down and ensure they actually are closed.

    and that leaves us with say, 2.5mS of open time... only double what we had at idle.

    but the engine itself is now spinning 18 times faster at redline, WOT, "100% volumetric efficiency" than at idle, where it was at approximately "20% VE"
    so we need 18x5 times the fuel at redline, than at idle. that is, up to NINETY TIMES the fuel. and this is only at stoich, ignoring that it needs to be richer. ignoring that it may have boost...

    but our fixed injector can only deliver so much? and now has only twice the time to get that extra fuel in?

    THIS is why modern EFI bikes tend to never exceed 12,000RPM. THIS is why they have "secondaries" or "dual injectors".

    it isnt to "increase performance".

    its simply to get enough fuel into them. you need a large injector, that comes on when required to deliver heaps of fuel, and a small injector for idle, and to "fine tune" the delivery of the big injector.

    and THAT moves on to needing to perform more calculations in the ECU, more software and coding challenges to deal with "blending" these two injector rates, more complexity, more parts to fail and go wrong....

    hence the trend for big fat single and twin cylinder "thumpers" rather than our "pre-EFI" four cylinder "hiroshima screamers"...

    its easier (CHEAPER!) on the production line to make a twin or single, and its easier at the software developers side to make a "slow revving" EFI... less injectors, less ignition drivers, less time constraints, less code/software development...


    all in all, a carburettor IS easier! and BETTER!

    but stupid EPA mandates, and bean counters (accountants), "SHAREHOLDERS" have dictated that the way forward is big fat thumping singles and twins with EFI systems that limit what they can produce, how fast they can go...

    and we all get told by teh magazines and articles and "experts" that "EFI IS BETTER!!!!!"

    it isnt.

    carbs have another benefit as well... they evaporate the fuel in the carb itself, in the intake manifold, and that makes the air denser, and that improves VE... sad, you never see anyone confirm this, would be interesting to see a dyno run with ANY engine, fitted with a simple venturi spraybar versus an injector making full power... which wins?

    i bet its the venturi spraybar. ;)


    now... who wants a lecture on the "lektron" carburettor? dive into issues of carbs?
     
    • Funny Funny x 1
    Last edited: Feb 12, 2024
  11. Mike Green

    Mike Green Well-Known Member Premium Member

    Messages:
    187
    Likes Received:
    259
    Trophy Points:
    273
    Joined:
    May 9, 2020
    Gender:
    Male
    Occupation:
    Taking it easy
    Location:
    Auckland
    My Bike:
    Yamaha FZR250
    Funny. I share your views on carbs vs EFI. Getting my twin running with a couple of carbs would be effortless compared to the grief I've had initially with the Ecotrons system and currently with the Link Atom ECU. The Link is fine, it is just complex to setup. My other turbo used a pressurized tank to feed fuel to the carb and on-boost enrichment system. We pumped it up to 5psi before the race and had a homemade valve to regulate tank pressure using manifold boost. Even with 2 large fuel taps it may have been getting close to limiting when on boost. Now, being older and possibly wiser, I'm horrified at what might have been.
     
    • Like Like x 1
  12. gyro gearloose

    gyro gearloose Active Member

    Messages:
    96
    Likes Received:
    92
    Trophy Points:
    103
    Joined:
    Feb 27, 2023
    Gender:
    Male
    Location:
    sydney
    My Bike:
    variable
    if the ecotrons came with wires, plugs, and not a pre-assembled harness, id probably still be using it... cursed thing, first set-up gave me a taste of boost and whistles...

    "just rebuild the harness" he says... new plugs, sensors, the works. and stuffed up on the earth wires. continuity doesnt mean "high current carrying". not that i consider the 2-3A of the pump "high current" but that was enough. wow, that hurt, frying the ECU by putting fuel in the tank, simply cus i didnt connect two black wires together... sigh...

    you erm... dont happen to still have the ECU do you?


    "older and wiser"... sure do learn a lot over the years, dont we?

    "by the time you learn to do everything, youre too old to do anything".
     
    • Like Like x 1
  13. Mike Green

    Mike Green Well-Known Member Premium Member

    Messages:
    187
    Likes Received:
    259
    Trophy Points:
    273
    Joined:
    May 9, 2020
    Gender:
    Male
    Occupation:
    Taking it easy
    Location:
    Auckland
    My Bike:
    Yamaha FZR250
    I do still have the ECU. My one had the problem where there was leakage to earth from the circuit board touching the case. I figured it out before they admitted the problem and had fixed it with a bit of insulation. My ECU is the model used on the GPz twin cylinder kits. You're welcome to it if it's any use. I'll going to Melbourne next week for the Superbikes at PI. I'm meeting my son who is working in Sydney and could give it to him.
     
    • Like Like x 1
  14. gyro gearloose

    gyro gearloose Active Member

    Messages:
    96
    Likes Received:
    92
    Trophy Points:
    103
    Joined:
    Feb 27, 2023
    Gender:
    Male
    Location:
    sydney
    My Bike:
    variable
    oh yeah, forgot that bit. you ran a twin... different plug, different harness, different different... meh, dont worry ;) but the offer is appreciated.

    lol at ecotrons, even the injector mounts were epoxied to the TBs... what was another "trick" they played? um... oh yeah, the BT dongle... simply swap Tx and Rx around to make it "incompatible"... the whole system was a joke, but the ECU actually did do what it was supposed to do... at first.



    one thing i DID learn from using that system was the importance of plenum chambers? first few runs, did the usual method you see on nearly all YT builds, turbo almost directly on top of TB. WEEEE! 16PSI!!!! all the whistles, yet no real apparent gain in power.

    was after looking at MAP readings you start noticing that that is merely a transient. exhaust opens, spools up... and air has nowhere to go. pressure builds rapidly, turbo goes into surge, then the inlet opens... and pressure very quickly reduces to "normal" sort of vacuum of a NA setup as the only thing driving the compressor at that point is momentum... rather logical when one sits down and thinks about it.

    if i just wanted to do this to a track bike or a pitbike? i would go straight back to the blowthrough carb setup.


    its all a learning experience...
     
    • Like Like x 1
  15. Mike Green

    Mike Green Well-Known Member Premium Member

    Messages:
    187
    Likes Received:
    259
    Trophy Points:
    273
    Joined:
    May 9, 2020
    Gender:
    Male
    Occupation:
    Taking it easy
    Location:
    Auckland
    My Bike:
    Yamaha FZR250
    I have a plenum on both exhaust and intake. Cylinders are 180 apart so there's very odd intervals between events. Logic said a plenum would help to even things like exhaust back pressure/resistance and intake fluctuations
     
    • Like Like x 1
  16. gyro gearloose

    gyro gearloose Active Member

    Messages:
    96
    Likes Received:
    92
    Trophy Points:
    103
    Joined:
    Feb 27, 2023
    Gender:
    Male
    Location:
    sydney
    My Bike:
    variable
    well, at the moment... not much progress. been wracking my head over a new approach to simply acquiring a crank signal. going insane with the ins and outs of programming. and dealing with ambiguous datasheets?
    figure THIS one out?
    "bit 6
    TMR1GE: Timer1 Gate Enable bit
    If TMR1ON = 0:
    This bit is ignored
    If TMR1ON = 1:
    1 = Timer1 is on if Timer1 gate is not active
    0 = Timer1 is on
    "

    well, it would appear that 1=timer gate IS active...
    ffs. that just took me several hours of mucking around to figure out.

    now wrap your head around THIS....

    ;scratch starts at 20h
    cblock 0x20
    TASKS ;bit 0= CALL RPMCHK
    endc

    cblock 0x70
    WISR
    SISR
    endc
    ;initial setup
    ORG 0x00
    NOP ;debug requisite
    CLRF TMR1H
    CLRF TMR1L
    GOTO SETUP ;processor reset vector



    ;ISR
    ORG 0x04
    MOVWF WISR ;store W
    SWAPF STATUS,W ;flip status to W
    MOVWF SISR ;store status now in W
    ;which flag?
    BTFSC INTCON,0
    CALL T1GHL ;IOC?
    BTFSC PIR1,1
    CALL INJEND ;TMR2 MATCH?
    ;all done
    SWAPF SISR,W ;flip stored status to W
    MOVWF STATUS ;restore status
    SWAPF WISR ;flip contents
    SWAPF WISR,W ;flip and restore W
    RETFIE

    ;T1GHL. if high, RETURN to ISR.
    T1GHL
    BCF INTCON,0 ;clear flag
    BTFSS GPIO,4 ;test if TMR1 counting (HI) or done (LO)
    BSF TASKS,0 ;set bit if LOW. data acquired
    RETURN

    ;INJ_OFF TMR2 INTERRUPT
    INJEND
    BCF PIR1,1 ;clear flag
    BSF GPIO,5 ;injector off
    RETURN

    SETUP
    BANKSEL GPIO ;BANK 0
    CLRF GPIO ;pull all pins low.
    MOVLW b'01001000'
    MOVWF INTCON ;peripheral,TMR2 match
    MOVLW b'11110001'
    MOVWF T1CON ;HIGH,enabled,1:8prescale,TMR1 ON
    MOVLW b'00100001' ; 1:5 postcaler,1:4 prescale 20uS-5100uS.
    MOVWF T2CON
    MOVLW b'00000111'
    MOVWF CMCON0 ;comparator OFF, all pins IO.
    BANKSEL ANSEL ;bank 1
    CLRF ANSEL ;digital in/out
    BSF TRISIO,4 ;GP4 input,GP5,3-0 output
    BSF PIE1,1 ;TMR2 match interrupt.
    BSF IOC,4 ;GP4/T1G interrupt
    BANKSEL GPIO
    BSF GPIO,5 ;pull all pins low, except GP5=1=injector OFF
    BSF INTCON,7 ;enable global interrupts


    ;MAIN PROGRAM LOOP
    TODO
    BTFSC TASKS,0 ; can we do a test yet? can we? can we?
    CALL RPMCHK ; yes, yes we can!
    GOTO TODO ; no, we cannot... just be patient...



    ;RPM_CHECK we have a signal, data, and TMR1G is now LOW.
    RPMCHK
    BCF INTCON,7 ;no interrupts in here!
    BCF TASKS,0 ;clear TASKS_RPMCHK bit
    MOVF TMR1H,W ;TMR1H to W.
    BTFSC STATUS,2 ;0?
    GOTO RPMH ;if zero, TMR1H irrelevant
    BTFSS TMR1H,1 ;not zero. may be 3,2,or 1
    DECFSZ TMR1H,W ;it was 1, or 3
    BTFSS TMR1H,0 ;it was 2, or 3
    GOTO IDLE ;it was 1,or 2. its running, needs fuel.
    CLRF TMR1H ;it was 3, below min crank speed.
    CLRF TMR1L ;clear TMR1
    BSF INTCON,7 ;interrupts enabled.
    RETURN

    ;
    IDLE
    BANKSEL PR2
    MOVLW .50 ;1mS
    MOVWF PR2
    BANKSEL TMR2
    CLRF TMR2 ;BANKSEL?
    BSF T2CON,2 ;START COUNTING.
    BSF GPIO,5 ;INJECTOR ON
    CLRF TMR1H
    CLRF TMR1L
    BSF INTCON,7 ;GOTO was cleared...
    RETURN ;straight back to TASKS


    RPMH
    BANKSEL PR2
    MOVLW .75
    MOVWF PR2 ;1.5mS
    BANKSEL TMR2
    CLRF TMR2
    BSF T2CON,2
    BSF GPIO,5
    CLRF TMR1L ;here as TMR1H was already clear.
    BSF INTCON,7 ;GOTO was cleared...
    RETURN ;straight back to TASKS
    END


    so what do we have here?

    a file of "tasks". such as turning an injector on, or performing an analog/digital conversion. (to be implemented...)
    so far, its basically just set up to check if the timer is triggered, and if its finished being triggered.

    and then i sit in a loop, just checking that file, and as certain bits are set, go and perform that task as appropriate, or dealing with "interrupts" as things happen. timers count down, crank signals occur, etc.

    deal with the data acquired, assign it (for now) into groups of "above idle", idle", and "not running".

    some testing with the scope, some number crunching, basically 400RPM will be "min crank speed".

    took a few days ruminating on the "logic" on how to do THAT task... because what happens when it isnt running? when theres no input to deal with?

    then, input acquired... chuck a value into a register, which starts counting down, and finally turns the injector off when finished. the "tuning" will basically be variations on what value is actually chucked into that file. at the moment, i have a 20uS "resolution" on the injection times, ranging from 20uS up to 5mS... can be tweaked and changed as i progress.

    as it is, "50" should give 1mS of open time from 400RPM to about 1600RPM, then kick over to "75", for 1.5mS at anything above 1600RPM. per revolution, so it will still be stinking rich, but its a start? at least with this code, and this approach... i can actually DO something with it and add all the extra features required.

    such as grabbing the data from that timer, and using it to perform an ADC at about halfway through the intake stroke. then figure out if its intake or power stroke... so i can then inject on every second cycle, like it should. and have a manifold pressure reading i can deal with.

    early days still!


    so far, after figuring out how to USE the simulator, it would appear to work. so now the next challenge is to program chip and test it out.

    the real test will be if i get it to start on the first kick again?

    far from finished.

    this is the stuff that you DONT see when you buy that funky aftermarket ECU... what its REALLY doing in there!

    whats fun with this method is seeing the program as its actually stored on the chip. this stuff is obscured in todays modern world.

    man, ive had to read some pretty heavy books from the 70s and 80s on digital design to start getting my head around this stuff.

    using arduino/speeduino/microsquirt just wouldnt be so satisfying....
     
    • Like Like x 1
  17. gyro gearloose

    gyro gearloose Active Member

    Messages:
    96
    Likes Received:
    92
    Trophy Points:
    103
    Joined:
    Feb 27, 2023
    Gender:
    Male
    Location:
    sydney
    My Bike:
    variable
    plenum on the intake, a definite must-have for 3 or less.

    well, 3... maybe no so crucial. they may overlap so theres always an exhaust pulse driving the turbine whilst an intake is open and theres somewhere for air to actually go.

    two on anything but a parallel twin is always a bit of a nasty one. 180 degree and vtwins have to be the worst offenders for uneven boosting.

    basic deal is at least 4 times the swept volume.

    lag is not an issue...

    on the exhaust, my approach is the shortest header possible. need as much heat as possible, the gas expands IN the turbine, and releases its energy, the heat of combustion, where it does the most work. through the turbine. fairly small diameter to get the maximum velocity, along with minimal heat loss. then the largest downtube one can fit. though i never had an issue with the "peashooter" tip on the R15 muffler i had strapped on at one point... i wont say it was even better, as i had so many variations and headaches in other areas i cant say anything definitive...

    so i have the turbo right down low on this engine, about 4 inches at the most of header pipe. below the sump... and that required a scavenge pump, basically an old oil pump from a deceased postie fitted to the camshaft. one day that whole mechanism may need some "tweaking". definitely works though.

    thinking about how it behaved when i last had a good ride, the venting of the fuel tank... it suddenly struck me the other day that the main issue was my BOV being set so low... i was dumping ALL the pressure almost instantly whenever i closed the throttle. and that meant i was getting a big dose of liquid fuel from the fuel tank down the pressure line.

    started off with the "standard" 8mm hose, and THAT made it constantly flood through the carb, as the tank pressure stayed so high for so long.

    changing to 20mm hose, it vented to rapidly. fixed the flooding in one aspect, made it worse in another. lol.

    aand then i completely destroyed the fuel tank as i fitted it with a baffle...

    the other issue with pressurising the tank is that the fuel level, and the volume of air in there is never constant.

    but i never even considered that it was simply due to that BOV...

    lol, it was sort of awesome, coasting downhill having it opening up under manifold vacuum, the whistle softly "weeeeeeeing".


    the whole subject had me thinking of a way to modify a carb so its running a different type of valve, instead of the standard "needle and seat". some type of balanced diaphgram, much like whats on a pressure regulator would do the trick... but yeah. too much thinking, not enough doing.
     
    • Like Like x 1
  18. Mike Green

    Mike Green Well-Known Member Premium Member

    Messages:
    187
    Likes Received:
    259
    Trophy Points:
    273
    Joined:
    May 9, 2020
    Gender:
    Male
    Occupation:
    Taking it easy
    Location:
    Auckland
    My Bike:
    Yamaha FZR250
    I have had the same thoughts about getting the exhaust to the turbine without losing energy. My big turbo 4 cylinder has very short 4:1 and then a smallish pipe around the motor to the turbo. For whatever reason it works great. For the twin I have insulated the exhaust plenum and then put a very thin shield over the insulation. The bit of the plenum I can see has a look about it of something that gets extremely hot. My downpipe needs to expand but currently is a straight pipe. It goes blue right to the tip which surprised me. There's obviously plenty of energy in the exhaust past the turbine which might be developed in the turbine if the exit was free flowing
     
    • Like Like x 1
  19. gyro gearloose

    gyro gearloose Active Member

    Messages:
    96
    Likes Received:
    92
    Trophy Points:
    103
    Joined:
    Feb 27, 2023
    Gender:
    Male
    Location:
    sydney
    My Bike:
    variable
    well, yet another "first kick". :cool:
    realised it will start with no battery as long as theres pressure in the fuel line... dah!


    time to wire up the killswitch, me thinks.

    oh. of course, the rocker switch i stuck onto the PCB decided to play silly buggers on me. it never ends, everything is determined to drive me nuts...

    "ok, inside to load some new code. oh, laptops turned off. :fuckyou:twiddle thumbs as it turns on. :fuckyou:
    oh, now the program has decided it cant find the file. :fuckyou:ok, start a new project and try again.
    hey look, you gotta go back out into the shed to grab a battery...:fuckyou:
    and back again for a screwdriver and a plug... :fuckyou:
    ok, now its saying it cant find device...:fuckyou: hmmm, back to shed for a multimeter... :fuckyou:swear the battery is charged... hey look, only 1.2V where there should be 12... :fuckyou:sigh. stupid switch. :fuckyou:
    heat soldering iron up...
    yay! now the phones ringing and i gotta go help someone load a truck... five hours later... oh, thats right, the switch decided to fail... and the irons burnt a hole in the bench... now wheres the solder? oh, now the irons burnt out and i gotta go buy a new one?"

    never.:headbang:
    bloody.:headbang:
    ends.:headbang:


    besides that? ARRRGH! i have been doing my head in over exactly HOW to do what i have to do now...

    sounds easy. clear timer0 register. load the inverted timer1 value into the timer0 register, set an interrupt, and go for it. simple! and repeat it for two samples.

    why inverted? because timer0 counts UP. so if my RPM/timer1 value is say, 241, then i have to start with 255-241. or if the value is 61, i have to start with 255-61... comprende? at least an inversion (complement) is simple. its even got an instruction for doing it. "COMPF".

    its easy when im above that 1600RPM limit and its only one 8 bit value. yay!


    bit trickier when its below that limit and i have to deal with the extra bits in the other register of timer1. sure, i just clear timer0, let it overflow, and decrement the value in timer1's upper register, until its empty then i can go back to loading the inverted value of the lower register, but i also have to do this twice if i want the "two samples per revolution".

    i also cant stop or start timer0. only enable/disable its interrupt, and load/clear its register. when thats done, it DOES stop... for "two instruction cycles". just long enough to set that interrupt.

    at this point juggling the data is doing my head in, and so far i keep getting myself stuck in a "perpetual loop of doom".... either load the undecremented value, or clear the register before i should, and have nothing to load... me thinks i may have to delete a large section of code and start from scratch, thinking through this "call" and "goto" a bit harder yet... oh well!
     
    • Like Like x 1
    Last edited: Mar 4, 2024
  20. gyro gearloose

    gyro gearloose Active Member

    Messages:
    96
    Likes Received:
    92
    Trophy Points:
    103
    Joined:
    Feb 27, 2023
    Gender:
    Male
    Location:
    sydney
    My Bike:
    variable
    and WTF is the deal with this constant "403 error" ?

    is it google playing silly buggers and the fact i couldnt create an account with my gmail address?

    goes away when i sign out of... "that site of evil".
     
    • Like Like x 1

Share This Page