Menu

Variable overwrite issue? I'm at a loss...

Chay Foss
2019-01-19
2019-02-06
  • Chay Foss

    Chay Foss - 2019-01-19

    Hi all. i have not been here for a while. I'm getting back to a project I was working on some time ago. It's a guage 'pod' which will read RPM and also a temperature and I hope to add a pressure as well. It's for a boat engine I'm installing.

    I'm using compiler version 0.97.00 2017-02-20.

    I'm using a 16F74 chip with 4k of memory and 192 bytes of ram.

    I had the code working very well. I added some variables for averaging the rpm. It worked well. Then I added some variables for averaging the temperature, and the rpm values went to 0. Like they are being overwritten?? The only difference between working and not working is that I have used one or two additional word variables. If I assign them (dim temperature_2, as word), there is no issue. But if I use it (Like initilize it to 0) then the rpm gets stuck at 0.

    GCBasic indicates that with the working code has 2248 out of 4096 words used, and 115/192 ram bytes used.

    The non working code has 2278/4096 and 117/192 used. Doesn't seem like it should be a space issue but I'm at a loss.

    When the RPM is stuck at 0, the temperature will still change (Have the a-d input simulated with a pot). When I turn off the rpm squarewave the display reads 'engine off' as expected. When I turn the waveform back on it registers at 0 again.

    The working code is version k.

    The non working code is version l.

    The only difference is the commented out 'Temperature_2 = 0' and 'Temperature_3 = 0'

    Also, I upgraded to the lastest version....no change.

    Any ideas??

    Thanks,

    Chay Foss

     

    Last edit: Chay Foss 2019-01-19
  • Anobium

    Anobium - 2019-01-20

    Welcome back.

    I would look at this code. Add some debug (via the LCD to prove).

    calc = rpm1+rpm2+rpm3     ;Averaging math
    calc = calc/3
    

    I do not know what is the root cause, but, you have found an issue. Use.

    calc = rpm1
    calc=calc+rpm2'+rpm3
    calc=calc+rpm3
    calc = calc/3
    
     
    • Anobium

      Anobium - 2019-01-20

      I will discuss with Hugh to resolve. This looks like an issue specific to the 16f low end parts.

      I created a quick project to prove the issue. Attached.

       

      Last edit: Anobium 2019-01-20
  • Chay Foss

    Chay Foss - 2019-01-21

    Thanks appreciate the help

    Chay

     
    • Anobium

      Anobium - 2019-01-21

      Hugh has reviewed and confirmed the issue.

      This is not an issue seen before, only occurred on 16F when a high byte was 255, and the result of the addition was not stored back into the original variable. calc = calc + rpm2 would be fine, but calc = rpm2 + rpm3 would not.

      Will be include in the next release, we need to test first.

      :-)

       
  • Chay Foss

    Chay Foss - 2019-01-27

    That is interresting Its not exactly the failure Im seeing. If I dont have the additional temp variables defined then calc = rpm1 + rpm2 + rpm3 works fine. The issue for me is when I define additional variables then I get the unusual operation. I tried the alternate calc=rpm1, calc = calc+rpm2 etc and it worked but when I added the extra variables in I lost the RPM again. Ill continue to troubleshoot and see what I can figure out

    Chay

     
    • Anobium

      Anobium - 2019-01-27

      Send me a Personal Message as we have, hopefully, resolved with a new compiler. We did find a bug......

       
  • Chay Foss

    Chay Foss - 2019-02-06

    I send a pm but perhaps I did it wrong...have not yet received a response.

    I did a bunch more troubleshooting with very limited success. I did find that when the rpm failed to register rpm1,2,3 and the averaged value in calc had a value of 14, and that value does not change with the input frequency.

    Originally I didn't see the 14 due to my code to limit changes to 25 rpm incements.

    Thanks for any help,

    Chay

     
  • Chay Foss

    Chay Foss - 2019-02-06

    Also, I tried to do the simulator but couldn't make it work...I've never used it before...

    Chay

     
  • Anobium

    Anobium - 2019-02-06

    I have just sent this personal message to you.

    Hello Chay,
    Send me an email to [email address deleted]a nd I can let you have the latest version of the compiler with a fix.
    Cheers,
    Evan

     
  • Chay Foss

    Chay Foss - 2019-02-06

    man i feel like a tool but i dont see it how does one access pms on this site? I've used them in the past on other sites but dont get the trick on this one I logged in but nothing pops up?

    thx

    Chay

     
  • Anobium

    Anobium - 2019-02-06

    If your profile is setup correctly you will receive an email notification.
    If your profile is setup correctly, then, check your spam filters and trash in your email.

    As I get always get them via email - I cannot share another way of get at these messages.

    Check your settings etc. Then, I can test send you a message.

     
  • Chay Foss

    Chay Foss - 2019-02-06

    aha.. Didnt know about he email. Yup there the emails were. I sent one back thx

    Chay

     

Log in to post a comment.