what's wrong 16F877A simple code?


Closed Thread
Results 1 to 12 of 12

Hybrid View

  1. #1


    Did you find this post helpful? Yes | No

    Question

    Yes, not elegant at all but it should run. The never ending loop is supposed to tell me whether it got to this point and it should dwell there.
    It was supposed to go back originally to checkleaf but that seemed not to work either. The end result is still the same, It would get to the never ending loop and fall out going back to homestart which should never happen since I trap it in the lower loops.

    Just wondering if somehow it is being vectored back to the beginning of the code or what. I turn off analog channels, comps, interrupts are not used, watchdog is off....

    I guess I am having one of those days.

    Nick

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


    Did you find this post helpful? Yes | No

    Default

    Why do you think it's somehow jumping where it shouldn't?
    Are you running it on a simulator?

    The only indication of what the program is doing is a motor running.
    And according to your program it's going to be doing a LOT of running, with no way to stop it.
    DT

  3. #3


    Did you find this post helpful? Yes | No

    Question

    I know it jumps out and goes back to homestart because that button when pressed retriggers the sequence of loops over again when it shouldn't. If I am stuck in an endless loop at checkleaf, homestart shouldn't do anything after the first time it falls through the code upon startup correct?

    As far as motor running, the motor runs only when homestart is triggered, it goes through homestart (1 time upon start up of MCU), then when I hit checkleaf it works correctly (since it sits in a loop)....but after that the motor is off at checkopt and does not sit in that loop. The motor stays off until I hit homestart again (which should never happen except on power up).

    I may start from scratch....I don't know. Any reference code to get started would help since I seem to be stuck in a loop mentally

    Nick

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


    Did you find this post helpful? Yes | No

    Default

    Question ...

    Are the Brake and the Motor supposed to run at the same time?

    ;constants
    brake Con %00000011
    stmot con %00000000
    runmot con %00000001

    The only way I can see that your symptoms can happen is if the PIC gets reset at the point where it applies the brake.
    Possibly from over current (Brake+Motor).

    The code itself will not do that.
    <br>
    DT

  5. #5


    Did you find this post helpful? Yes | No

    Default

    Good point...I think you are correct. After I wrote my previous post, I was thinking about possibly a brown out condition where it would come up in reset mode. I will check it out and post back.

    Thanks!
    Nick

  6. #6


    Did you find this post helpful? Yes | No

    Talking

    Darrel you are correct!! The brake was hosing the MCU....even though I have 1K resistors...strange I will need to dive more into the hardware.

    Thanks for your help!!!

    Nick

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


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Macgman2000 View Post
    The brake was hosing the MCU....
    Hmmm, must be one of those Canadian brakes (Hoser).
    <br>
    DT

Similar Threads

  1. How much code space do PBP statements use.
    By Darrel Taylor in forum Code Examples
    Replies: 5
    Last Post: - 13th February 2009, 21:31
  2. LCD Showes Some Wrong Letters
    By sbobowski in forum General
    Replies: 2
    Last Post: - 23rd September 2008, 19:15
  3. Making Program Code Space your playground...
    By Melanie in forum Code Examples
    Replies: 15
    Last Post: - 19th July 2008, 08:26
  4. hopefully simple code
    By hoyles in forum General
    Replies: 3
    Last Post: - 8th September 2005, 23:24
  5. Problems with 16F877A code
    By NightHawk2 in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 20th August 2003, 01:36

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