3 Replies Latest reply on Mar 8, 2016 1:34 AM by nick.burns

    Psoc 5LP Custom Function return error

    rdschuler_1565191

      Hello,

         

      We are currently working on a project that is creating a small autonomous vehicle. We are having trouble executing multiple functions that we have written. We are able to execute one full forward function but never return to our main to run the reverse function. Upon debugging we found that we get stuck in a while loop located in Cm3start.c file.  Any ideas/suggestions as to why we are never returning to our main code after completing one movement function?  All help is greatly appreciated.  The File for our project is attached.

         

      Thank you,

         

      Richard

        • 1. Re: Psoc 5LP Custom Function return error
          nick.burns

          I think there's a fault in one of your move functions.. The quadrature decoders generate positive or negative values depending on which direction your motors have spun. This means that one or the other of the while loops will never end in user_movement_functions.c (EDIT: or to be more accurate, it won't end the way you expect it to).

             

          The other thing that strikes me is that there is no endless loop in your main() function. When your code finishes executing, main() returns, and you will wind up in Cm3Start.c at lines 387-390 in the following code:

             

          while (1)
          {
              /* If main returns, make sure we don't return. */
          }

             

          I'd suggest putting the following part of your main() function in an endless loop like so:

             

              while(1)

             

              {

             

                  Move_Forward(50,(2*1920));
                  Move_Reverse(150,(2*1920));
                  CyDelay(5000); 
              }

          • 2. Re: Psoc 5LP Custom Function return error
            rdschuler_1565191

            Thank you PolyVinalDistillat. That fixed our problem. For the Negitive values of the reverse function we are going to edit the code to take that absolute value of the encoder reading.

            • 3. Re: Psoc 5LP Custom Function return error
              nick.burns

              Glad to have helped :)