Interupts in BASIC?
Armored Cars
Posts: 172
Can interupts be programmed in BASIC?· If so how or where can I·find out·how, I havnt seen it anywhere.
Aaron
Aaron
Comments
On the BS2p and BS2pe you have the POLL instructions, though, but no real interrupts.
Maybe there is a way around it.
Terry
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
Dallas Office
What I am doing is controlling a standard RC car, I have so many IFs and Subroutines Im afraid of running out of memory or sensors lagging since it check only one at a time.
Regarding your program, there is a strategy that many use that is the high-level equivalen of the way a lot of assembly programs are designed.· The idea is to create a task switcher such that important code runs every time through the main control loop.· After the important code, then next task is run.· Under normal operation each task simply points to the next, but it has the ability to redirect to a new task if conditions warrant.· Here's a bit of pseudo-code to give you an idea:
By placing your task code in subroutines, the code can be called from anywhere within your program -- including other tasks.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
Dallas Office
www.emesystems.com/BS2pe.htm#spram_specials
The examples in the manual barely scratch the surface, and the tutorial does not get very deep into it either. You have to understand the role of the extra read-only locations in the scratchpad ram, how they can latch the occurance of events that occur on input pins while the program is off doing other things. I have made use of the pollwait command in the context of having the Stamp sleep until any of several different triggering events occur.
If your program is getting too many IFs and branches, it will really be a good idea and follow Jon's advice about program organization.
-- Tracy
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tracy Allen
www.emesystems.com
It's true that this is nowhere near what the interrupt response that you'd get by programming a microcontroller in assembly language or a compiled language but it does give you a reasonable ability to respond to an asynchronous event.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Don Kinzer
·