PDA

View Full Version : Timing different events on PBC vs. PBP



Rifraf
- 4th December 2007, 03:12
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

mister_e
- 4th December 2007, 04:00
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 :D

Rifraf
- 5th December 2007, 19:04
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?

mister_e
- 5th December 2007, 19:10
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.

Rifraf
- 5th December 2007, 22:45
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.