Shop OBEX P1 Docs P2 Docs Learn Events
Code does not execute — Parallax Forums

Code does not execute

I am using making some sort of obstacle avoiding robot using ultrasonic sensors. It worked well until I added a function to the code. Then, it did not even start. The function is not called at the beginning of the code and it compiles successfully.

The weirdest thing is that I deleted the content of another function and found that the code started to run.

Comments

  • kwinnkwinn Posts: 8,697
    Perhaps you have run out of memory? More info is needed. Check for error messages when compiling code, and do some testing.Ultimately you may have to post the code.
  • kwinn wrote: »
    Perhaps you have run out of memory? More info is needed. Check for error messages when compiling code, and do some testing.Ultimately you may have to post the code.

    I also think it is a memory problem but the code compiles with no error messages.
    Here is the code size.
    300 x 77 - 3K
  • kwinnkwinn Posts: 8,697
    What software are you using to compile and download the code?

    You can always compile and download a simple known working program (led blinker, hello world, etc.) to eliminate the PC, PC to Prop connection, and Propeller chip.
  • RaymanRayman Posts: 14,658
    I had a funny issue with my own Botto code and ultrasonic sensor...
    http://forums.parallax.com/discussion/167218/botto-a-walking-robot-with-3d-printed-parts-and-controlled-by-parallax-propeller-activity-board

    It turned out that, when I tried to clean up my code and remove debugging stuff, I was asking the sensor for updates too fast.

    You need to wait some time between asking the sensor for an update or it doesn't work and the driver stalls...
  • kwinn wrote: »
    What software are you using to compile and download the code?

    You can always compile and download a simple known working program (led blinker, hello world, etc.) to eliminate the PC, PC to Prop connection, and Propeller chip.

    I am using SimpleIDE.
    I tried a working program and it worked well.
  • kwinnkwinn Posts: 8,697
    omarmonzer wrote: »
    kwinn wrote: »
    What software are you using to compile and download the code?

    You can always compile and download a simple known working program (led blinker, hello world, etc.) to eliminate the PC, PC to Prop connection, and Propeller chip.

    I am using SimpleIDE.
    I tried a working program and it worked well.

    OK, so the problem is with the downloaded code. What I often do for this kind of debugging is to add a line at the beginning of each section and subroutine that outputs "Got to sub" to PST, where sub is the name of the section or subroutine.
  • It worked when I tried to use a slightly simpler algorithm. I think the problem was that the micro controller ran out of ram so it messed up. Thank you very much @kwinn and @Rayman for your help.
Sign In or Register to comment.