Shop OBEX P1 Docs P2 Docs Learn Events
Parallel Execution Paths Help — Parallax Forums

Parallel Execution Paths Help

LaxAddict08LaxAddict08 Posts: 2
edited 2008-04-01 22:49 in BASIC Stamp
I am new to the world of BASIC STAMP microcontrollers and am using a BSII. I was wondering if it is possible in PBASIC to write two loops or sub-routines that execute simultaneously [noparse][[/noparse]as in sending a PULSOUT to a continuous rotation servo and executing a counter based on a switch]. Thus far I have realized that PBASIC compiles and executes line by line. Any help would be greatly appreciated!

Comments

  • allanlane5allanlane5 Posts: 3,815
    edited 2008-04-01 20:16
    No, the BS2 is a "single tasking" processor and language. However, the essence of multi-tasking is doing a little of A, then a little of B, then a little more of A, then a little more of B -- in other words, even "Real" multi-tasking does time-slicing on a single-tasking processor.

    So, you can call a subroutine that sends the PULSOUT to the servo. Now you have 20 to 50 milliseconds to do something else, before you have to send the PULSOUT again. So during that time you can monitor the switch.
  • LaxAddict08LaxAddict08 Posts: 2
    edited 2008-04-01 20:26
    Thanks that's what I figured would be the solution. Does PBASIC have any variable types that are larger then "Word" or if I have a value exceeding that range should I just subtract the highest value attainable and then store the remainder as a second variable?
  • allanlane5allanlane5 Posts: 3,815
    edited 2008-04-01 20:42
    Yes, a "Word" variable is as big as PBasic gets, 16-bits. And the BS2 only has 13 of them, so use them carefully. On the other hand, you can divide them into bits, nibbles, bytes, and words with almost no restrictions.
  • Mike GreenMike Green Posts: 23,101
    edited 2008-04-01 22:47
    EME Systems' website ([noparse][[/noparse]url]http://www.emesystems.com[noparse][[/noparse]/url]) has some useful information on multiple precision arithmetic using Stamps.· Look under "app-notes".
  • UghaUgha Posts: 543
    edited 2008-04-01 22:49
    You also have arrays if you need to store related data in a single variable.
Sign In or Register to comment.