No announcement yet.

Lesson Learned

  • Filter
  • Time
  • Show
Clear All
new posts

  • Lesson Learned

    I spent over 6 weeks trying to get a PIC16F1828 to control the ignition on a 4-cylinder Honda. No matter what I did; tinkered with the hardware, tinkered with software, converted code to Assembly and back to PBP again one step at a time; no matter what I did it wouldn't run above 2150 RPM. Finally I decided to try a faster clock with more instructions: enter the PIC18F13K22. I wish it had TMR4/6 (sigh). That would have made it much easier (which is why I think I passed on it when choosing a processor over 6 weeks ago). Went from 32 MHz and 35 instructions to 64 MHz and 75 instructions, which equates to going from 2150 RPM to...haven't figured that out yet!

    The frustrating part is when I did the math, there was plenty of processor speed to get the job done, yet it didn't. I didn't take into account the number of instructions cycles it had to be taking with only 35 instructions to work with. Working on transferring the project over to one of the new K40 chips. Just wanted to share. (Was up all last night, didn't sleep at all. Just worked on this sucker! But I got 'er dun.)


  • #2
    If you're doing a lot of multiplications then an 18F part will help alot since it's got a hardware multiplier - which the 16F series parts doesn't so it has to do it in software. Appart from that I wonder just how much more efficient PBP code compiled for 18F is compared to the same code compiled for a 16F part.

    I'd love to know what, more precisely, cause the 16F1828 not to cope in your case. Care to post the section of code where you think most of the cycles are spent?



    • #3
      Henrik, at this point I'm just trying to get the factory ECU coil signal to trigger an IOC interrupt to tell me a cylinder is trying to fire. From there, I load a timer with the ignition retard value (delay, TMR2) and return from the interrupt. Once that expires, another interrupt sends me to turn on the ignition coil (TMR4 with the PIC16F1828, reconfigured TMR2 with the PIC18F13K22) and set the timer for the proper dwell time (2.4 ms in the case of this Honda) and return. Then the next interrupt signals turning off the coil to fire the spark plug. Then it starts all over again. I'm just trying to get my controller to keep up with the Input = Output at this point. Later will come calculations for the amount of delay (retard) based on analog inputs (TPS, IAT, CTS, etc.).

      It ran for about 20 seconds then died. I thought I blew a fuse (which happened before when I set the dwell too long). The new fuse lasted for about as long as the old one...or so I thought. There was nothing wrong with either fuse. I checked to make sure I still had power to the board when the engine died; it die. I checked on an O-scope input vs output to see if the factory ECU was shutting things down. I still had input, but my output flat-lined. I basically had a screamer for about 20 seconds.

      Spoke with Charles Leo today about it. I sent him the code and he gave me direction. For starters, I didn't finish converting everything from "PIC16F1828-ese" to "PIC18F13K22 language". He asked me why I'm accessing Bank 7. That was my first clue I forgot some things. If interested, I can let you know when I can drive the car again.



      • #4
        After many trips through the code, got the engine running strong. I was able to implement the delay factors based on analog inputs. Works great! Time to break out the 5-gas analyzer and do more than seat-of-the-pants tuning (pending weather conditions, of course).