Odd behavior if too many instructions


Closed Thread
Results 1 to 14 of 14

Hybrid View

  1. #1
    Join Date
    Feb 2010
    Posts
    11


    Did you find this post helpful? Yes | No

    Default

    Thanks! That seems to have done the trick. I'm using MicroCode Studio Plus, is there anyway to see what variables are stored in what banks?

    Also, more importantly, I'm not currently saving/restoring the FSR register when I go into my interrupt service routine. I'm not sure if any of the PBP commands use indirect addressing, do they?

    If they do, I can do the following:

    Code:
    'create fsrsave
    fsrsave VAR byte bank0 system 'What does the "system" do anyways?
    
    ...
    
    ASM
    ...
    movf FSR,W
    movwf fsrsave
    
    ...do the routine
    
    ...at the end, restore stuff, and then before retfie
    movf fsrsave,W
    movwf FSR
    retfie
    Right? I'm learning so damn much from this project. It's not even an electrical engineering project, it's a mechanical engineering project, but I like to take it to the next level to learn more .

    Thanks,
    Matt

  2. #2
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    You can look in the .LST file to see the addresses where each variable is assigned.

    You can also File > Import the .cof file into MPLAB then View > File Registers > Symbolic Tab.
    It's a lot easier to read than the .lst file.
    Of course, you need the datasheet to figure out where the banks are.

    And there are many PBP commands that use the FSR.
    But none of the statements in your ISR do, so right now there's no need to save/restore it.

    Cheers,
    DT

  3. #3
    Join Date
    Feb 2010
    Posts
    11


    Did you find this post helpful? Yes | No

    Default

    If I go over 1 page of code (2k words, right?) is there anything I need to worry about w/my current code? I know the pbp code will take care of itself, but my ASM ISR might not. I do use PCLATH for the table jump, so that should be fine. And my GOTO's should be fine so long as the entire ISR is in page0, right?

    Thanks,
    Matt

  4. #4
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    I do use PCLATH for the table jump, so that should be fine. And my GOTO's should be fine so long as the entire ISR is in page0, right?
    You do have PCLATH pointing to the Jump Table. But it doesn't take into account the Jump it makes FROM the table.

    If _No_Change, _Decrement, _Increment or _Error end up on the other side of a boundary, it will jump to the wrong place.

    As long as the entire ISR is in the same page (doesn't have to be page 0), then it won't have a problem.
    The trick is knowing when there is a problem, which you can do easily by adding these lines to the end of the ISR ...

    Code:
            retfie                  ; Return from interrupt
      if ((high($) & 18h) != (high(ISR) & 18h))
        error ISR crosses page boundary
      endif
    ENDASM
    If the ISR ends up crossing a boundary, that will flag an error to let you know something needs to be moved.

    HTH,
    DT

  5. #5
    Join Date
    Feb 2010
    Posts
    11


    Did you find this post helpful? Yes | No

    Default

    Thanks for all the help. Because of it I was able to finish the robot project I was working on using optical encoders (instead of potentiometers... PID + nonlinear, 270 degree pots ==slow || messy).

    The robot contest was for my senior design class at UCSD (Mechanical Engineering). We had to build a robot to move small pieces of PVC pipe from one rotary table to another rotary table, as fast as possible. The recieving table was at least 1 inch higher than the starting table. Also, the receiving table started out with some positions filled, so you had to at least detect if there was space to move cargo there.

    My turntables were stacked. IR sensors were used to detect the presence of pipes on both the top and bottom tables. As soon as a PVC pipe was detected (bottom) or an empty slot detected (top), the PIC would rotate the turntable to that position to align with an air nozzle. The air nozzle shot air between 45-60 PSI at the PVC pipe (there was a round cover for the bottom to prevent the air from just going through the pipe).

    My PID was very slow (I was running my motor at around 40% duty cycle MAX) because I was having problems getting my derivative term working well at high speed (worked fine at low speed). I've identified the problem, but it's too late. Our robot was the fastest in the class anyways . We transferred 3 PVC pipes in 1.19-1.86 seconds. I think the second fastest time was on the order of 6 seconds.

    Here is a highspeed video of our robot (I think this was our 1.86 second time).



    Thanks so much,
    Matt

  6. #6
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    Congratulations on the Win!

    Looks like it was fun.
    Maybe I should go back to school. (Just for the challenges)
    <br>
    DT

Similar Threads

  1. PBP Using too many instructions
    By The Master in forum mel PIC BASIC Pro
    Replies: 14
    Last Post: - 21st December 2009, 23:24
  2. Difference between modes in serial instructions
    By amindzo in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 16th September 2008, 15:40
  3. Is Number Odd?
    By T.Jackson in forum Off Topic
    Replies: 29
    Last Post: - 11th June 2008, 17:53
  4. List of instructions used in PBP ?
    By AndrewC in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 2nd November 2007, 11:22
  5. Need more speed in Lookdown and Branchl instructions
    By Pedro Santos in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 18th August 2006, 23:04

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts