Shop OBEX P1 Docs P2 Docs Learn Events
Scan time for bs2 — Parallax Forums

Scan time for bs2

J^3J^3 Posts: 121
edited 2007-12-07 19:53 in BASIC Stamp
Good Morning everyone,
I read in the bs2 syntax manual that the bs2 executes ~ 4k instructions p/s.· I would like to calculate the scan time for a code but I am un certian about what the bs2 considers an instruction and what it doesn't.· Any help would be appreciated.· Thank you.· P.S.· If I am understanding this right, each instruction would take ~ 230 micro secs.

Comments

  • Steve JoblinSteve Joblin Posts: 784
    edited 2007-12-07 16:52
    each instruction takes a different amount of time to execute. The manual is providing you with an approximate average. I'm not quite sure what you mean by "what the bs2 considers an instruction and what it doesn't". Things like comments in your program do not actually get tokenized, which is why you can have as many comments as you want and not run out of space.
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2007-12-07 17:34
    This is one of those things you just have to try for yourself. The price of entry is low enough that you're not out much if it doesn't work for you.

    -Phil
  • allanlane5allanlane5 Posts: 3,815
    edited 2007-12-07 17:55
    The BS2 runs "PBasic". This is a 'Basic' language variant, which does not require line numbers (good), but does not have local variables (ouch).

    Each PBasic 'keyword', like "HIGH 15", or "LOW 15", or "GOSUB", is compiled into a 'token' (an integer, basically) by the Parallax provided IDE. These tokens are then 'downloaded' into the BS2 module resident eeprom when you click "Compile". Comments are not tokenized. "Constants" are replaced by the actual value.

    When your program 'runs' in the BS2, the BS2 'runtime engine' (programmed into the 16C57 PIC chip) fetches tokens from the eeprom, and uses the token to select a piece of the 'run-time' code to implement that functionality. And it can do that at about 250 uSec per instruction.

    Now, some instructions have built-in time-delays to them -- like SERIN/SEROUT which take 1 mSec per character at 9600 baud, or PULSIN/PULSOUT, which have to 'wait' for the end of the commanded pulse before going on, or even "PAUSE 100", which will pause 100 mSec. Even the time to execute an IF--THEN can vary, based on if it's true or false.

    This does leave as an open question this "Code" you're trying to read.
  • Mike GreenMike Green Posts: 23,101
    edited 2007-12-07 18:25
    This site (www.emesystems.com) has approximate times for many of the PBasic statements.
  • J^3J^3 Posts: 121
    edited 2007-12-07 19:53
    Thanks guys, appreciate the help.
Sign In or Register to comment.