Shop OBEX P1 Docs P2 Docs Learn Events
Interrupt programming with BS2 — Parallax Forums

Interrupt programming with BS2

TheoTheo Posts: 7
edited 2009-09-26 16:16 in Learn with BlocklyProp
Does anyone know if it's possible to use interrupts in PBASIC on the BS2 ?

Thx,
Theo

Comments

  • frasencifrasenci Posts: 34
    edited 2004-09-01 13:00
    NO , IT IS not !!
  • BeanBean Posts: 8,129
    edited 2004-09-01 13:40
    What did you have in mind ?
    Maybe it can be done another way.

    Terry
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2004-09-01 14:21
    Terry is right. With good coding, behaviors that many want to default to interrupts can be handled in PBASIC (or any micro, for that matter).

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
    Dallas Office
  • frasencifrasenci Posts: 34
    edited 2004-09-01 14:37
    And you are right too Jon

    In my Tachometer app I initialy missed so much an interrupt as to poll the pulses of the sensor on the spinning rotor of my heli...... The COUNT command would take to much time to get a meaning sample to indicate the RPM. Almost all designs i whent trough , relied on an interrupt to the micro.

    But there was a solution and it was by changing the sensor. I Used PULSIN instead . That way , in only a very short time I can measure the speed of the rotating triggering device ( Light reflection on an optical switch in this case. )

    So with a little imagination there should be an workaround for the missing interrupts ... YES !!!

    The wonderfull developing tool the editor is for the Basic Stamp , made the initial tests a breeze ,... just by trial and error procedure.


    Francisco
  • OTC InstructorOTC Instructor Posts: 6
    edited 2004-09-01 19:20
    Hi.

    I've·worked with what I call "STAMP Pseudo Interrupts" in the past. It takes a little external circuitry and some code trickery. I have a paper I wrote (long Word document) on the concept that I'd be glad to e-mail to anyone who wants it. (The figures are separate files in CorelDraw)

    Basically, you must have external circuitry trigger the STAMP's reset line, and you write your code such that the first line of code is the "interrupt vector"; an unconditional branch to the interrupt service routine. Your main routine needs to be a loop that never normally goes to the first part of the program. When something needs to interrupt, external logic decodes and prioritizes which device has interrupted, pulls the reset line low, and the stamp resets. The program then jumps to an interrupt service routine which might read some input lines to determine what caused the interrupt and service it accordingly.

    After the ISR executes, it must reset the external circuitry and return to the main routine.· The only catch is how to download the code initially and get into the main routine loop and bypass the interrupt vector on initial startup. This can be done by having the initial ISR look for yet another input like a pushbutton, and if set, go to the main routine.· The user simply has to hold down the button when the program is first downloaded, and you're off.

    Sound complicated? It is! But it does work and was fun to work out. The paper and diagrams make the concept manageable.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Bruce Clemens, CET Sr.

    Instructor, Electronics and Computer Repair Technology
    Ozarks Technical Community College
    www.otc.edu
  • Beau SchwabeBeau Schwabe Posts: 6,566
    edited 2004-09-02 05:01
    Here is a "Pseudo STAMP Interrupt" approach that I have used in the past. It may fit your needs.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Beau Schwabe - Mask Designer III

    National Semiconductor Corporation
    (Communication Interface Division)
    500 Pinnacle Court, Suite 525
    Mail Stop GA1
    Norcross,GA 30071

    Post Edited (Beau Schwabe) : 9/2/2004 3:03:31 PM GMT
    800 x 704 - 15K
  • KenMKenM Posts: 657
    edited 2004-09-02 14:52
    Nice interrupts!
  • RoboticsProfessorRoboticsProfessor Posts: 54
    edited 2009-09-18 04:11
    I'm thinking of a robot to wander around my classroom while I'm teaching robotics/BS2.
    Every other uprocessor I've used had interrupts, so I'll try this on the whiskers.
    This way, the bot can be in the "search and avoid" mode always until the whiskers are hit.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Richard Vannoy

    Programming and Electronics Instructor
    www.RichardVannoy.info
    ·
  • vaclav_salvaclav_sal Posts: 451
    edited 2009-09-26 16:16
    I have been using the following as a substitute for real time interrupt.
    Just change the TestInput to whatever INx you need and adjust the WHILE condition.



    ' {$STAMP BS2e}
    ' {$PBASIC 2.5}
    TestInput VAR Nib

    Main:
    DO
    DO
    'PAUSE 1000
    DEBUG BIN4 ? TestInput,CR
    DEBUGIN HEX1 TestInput
    DEBUG CR
    LOOP WHILE TestInput = $f
    DEBUG "Pseudo interrupt processing ",CR
    DEBUG ? TestInput,CR
    LOOP
    END
Sign In or Register to comment.