Timing different events on PBC vs. PBP


Closed Thread
Results 1 to 5 of 5

Hybrid View

  1. #1
    Join Date
    Dec 2007
    Posts
    4

    Default Timing different events on PBC vs. PBP

    Hi Forum,

    I hope this is the right place to post. I am new to all this, I don't even have the compiler yet. I need to determine if I need Pro version to do what I want to do. I've written the psuedo-code, here's what i plan to do:

    I have 3 things I am timing, that overlap and will be tested for 250ms < X < 900ms, Y<5000ms and Z < 1-30minutes.

    My thought, to make use of PBC rather than spend the money on PBP was to not use timers, rather use timing variables and pauses. So, I thought I'd end each loop with a TimerInc routine that would pause 5-10ms increment each active timer by that amount.

    My first question is this: The accuracy of this method is going to be dependent on the ratio of the loop runtime vs. the pause length. If the loop takes 1ms to run and I pause 5ms, I will be 20% off. If the loop takes 100uS, I'm only 2% off. I'm still new to the concept of the speed at which these controllers are running. I am expecting that the loop runtime will be more on the order of uS's. Obviously, the loop runtime is dependent on the number of instructions in the loop. But, What's the reality here? What's the best way to make a ballpark stab at how long a section of PBC code is going to run?

    Second: In making the decision of PBC vs. PBP. Most of the programs I am going to write are this simple. If I am not needing to make special use of Timers, etc. Should I be fine with PBC? Would there be any compelling reason to spend the extra money on PBP???

    Thanks much,
    - Rif

  2. #2
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    if you need real accuracy, you want to use internal Timer, unless some pause Loops are still viable solutions.

    For what you want to do PBC or PBP won't make any difference. But i always persist to say, PBP worth the investment. At least for better IF-THEN structure and various other built-in feature which simply the use of... reduce your headaches.

    Yeah i know, Aspirins are cheap.. but nervous depress is way much expensive than PBP-PBC cost
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  3. #3
    Join Date
    Dec 2007
    Posts
    4


    Did you find this post helpful? Yes | No

    Default

    One thought I had, after reading through the forums some, would be to reset and start TMR0 at the beginning of each loop, then increment the individual timer variables by the value of TMR0 at the end of each loop. The code examples for that look easy enough.

    I am assuming that PBC has simple access to the timer. Is access to the internal timers any easier with PBP?

  4. #4
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    Ahhh you're using PBC... so i think you have to use w0 instead of b0

    Easier??? yes or no, let's say... to me PBP syntax is way easier. No poke/peek, no need to define Symbols for PIC register... and so on.

    Software loops such as PAUSE/PAUSEUS don't use the PIC TIMER, but are still efficient enough for most Timing needs.

    Polling Timer register or a overflow flag is really viable, for accuracy, that's what i would use. To override the INT latency... it's another nice way.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  5. #5
    Join Date
    Dec 2007
    Posts
    4


    Did you find this post helpful? Yes | No

    Default

    Wellll.... I am not using ANYTHING yet. I have so far read through a PICBasic book that covers both PBC and PBP, but didn't do ANYTHING with timers. I've also written the psuedo-code for a couple of the projects I'll be working on, based on my interpretation of the code structures for PBC. In the case of this one program, I have to keep track of a few different simutaneous timers, so simple wait and check with pause structures wont work.

    I'll probably end up going with PBP, since at least one of my bigger projects will be using A/D and be accessing many of the ports (other than B), often. Just at this point, I'm on a budget so the extra 150 is a little tough to swallow without knowing for sure how much I'm going to be doing these kinds of projects...

    I'm actually on vacation now... but I'm looking forward to getting home and tinkering with all this stuff. Should be a lot of fun.

Similar Threads

  1. PBP Book
    By Bruce in forum Off Topic
    Replies: 83
    Last Post: - 4th October 2021, 12:55
  2. PBP, ASM and LST files
    By HenrikOlsson in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 12th January 2010, 13:43
  3. Extensions to PBP variables
    By John_Mac in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 23rd October 2009, 05:21
  4. Compiler differences between PBP 2.33 & 2.46
    By nikopolis in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 2nd May 2006, 19:01
  5. Newby- PBP wont compile for 18F (MPLAB)
    By jd76duke in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 17th December 2005, 23:30

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