Time taken to do mainloop


Results 1 to 5 of 5

Threaded View

  1. #5
    Join Date
    Mar 2023
    Location
    Cape Town, South Africa
    Posts
    26


    Did you find this post helpful? Yes | No

    Default Re: Time taken to do mainloop

    Quote Originally Posted by HenrikOlsson View Post
    The program runs as fast as it can and the execution time of each iteration thru the loop depends on the code that is executed at that iteration. In other words, which IF statements evaluates to true and which doesn't.

    For example:
    Code:
    Main:
      TOGGLE GPIO.0
      PAUSE 1  
    GOTO Main
    This will take the same amount of time each iteration and it's 1ms (which is the PAUSE statement) + however long the TOGGLE command takes (a couple of instruction cycles) + another two instruction cycles for the GOTO command.

    For those that sent private messages; I have a trigger button near my hand. A short press makes an immediate 3.5 second video and restarts the mainloop at the beginning of the 57 sec "mute" time. A long press records until the trigger is released. If mainloop is busy recording, the trigger extends that recording.

    If the PIC runs at 4MHz each instruction cycle is 1us. Most ASM commands executes in one cycle, some (like jumps) takes two. Each PBP statements gets translated into several ASM instructions and there's no list of how many that is because it varies depending on various things.

    If you want to KNOW how fast your program runs the easiest way is to measure it. If you NEED it to run at specific pace you should resort to using a timer.

    /Henrik.
    Thank you Henrik. I get a very repeatable 3 seconds of video recording every minute. I used a video of a "stopwatch" to calibrate the numbers:
    This does not need to be very precise. I just wanted to understand it better. When I get back from a long roadtrip in May, I will experiment further with the code, primarily to add watchdogs for things going wrong. Eg. No recording for 2 minutes, a recording longer than 20 seconds. The primary purpose of the system is to be able to use one SD card in the camera for 3 weeks and not fill it in a day or two.
    Last edited by Gerald; - 29th March 2023 at 14:22.

Similar Threads

  1. Outside the Mainloop
    By pescador in forum General
    Replies: 10
    Last Post: - 26th April 2016, 17:34
  2. PIC 18F1330 - first time, hard time - blink that LED
    By flotulopex in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 1st March 2015, 22:33
  3. How best to time a pin state for extended periods of time
    By Hylan in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 10th March 2011, 11:20
  4. DS1904 RTC - How to Convert Binary Time into Real Time/Date?
    By Ioannis in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 2nd December 2010, 10:45
  5. Linx RF -> HSERIN time delay / time critical app...
    By batee in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 15th October 2004, 15:04

Members who have read this thread : 1

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