Shop OBEX P1 Docs P2 Docs Learn Events
Interupt? — Parallax Forums

Interupt?

Paul DPaul D Posts: 2
edited 2006-03-06 22:53 in Robotics
After serching through posts for a couple of hours I have decided to jump in and get my feet wet.· My son and I have purchased a HomeWork Board and have not had much trouble mastering the comands in the work book.
·Now we have built a mobile car built with stepper motor on two drive wheels and it will go where ever we write code to send it.· Next we would like to install a sensor to interupt and jump to sub-rutines.·How do you do an Interupt?· Thanks, Paul

Comments

  • Jon WilliamsJon Williams Posts: 6,491
    edited 2006-03-06 03:44
    No interrupts on the BASIC Stamp.· You can, however construct you code in such a manner that it can be very responsive without the complications of ISR management.· Like this (psuedocode):

    Main:
    · DO
    ·· ·GOSUB Check_Sensors
    ·· ·Act_On_Sensors_If_Needed
    ·· ·ON task GOSUB Task0, Task1, Task2, Task3...
    ·· ·task = task + 1 // NumTasks
    · LOOP

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
  • Paul DPaul D Posts: 2
    edited 2006-03-06 22:53
    Thanks, I am doing the following: Half stepping a bipollar stepper.· I am thinking that by adding a check would cause a delay in rotation.· It is 1.8deg per pulse.· 200 to make one revolution.·· I was looking for a conditional interupt that would stop when ever.· I will write in the "check routine" and see.· Thanks again, Paul

    time CON 4/5
    OUTH = %00000000
    DIRH = %11111111
    counter VAR Word
    cycles VAR Byte
    cycles = 0
    DO
    ·DEBUG "Car Running!",CR
    cycles = cycles +1
    '······ (motor1······· motor2)
    FOR counter = 1 TO 700········· 'Straight 1
    OUTH = %10001000··············· 'Motor 1&2 steps
    · PAUSE time
    OUTH = %11001100··············· 'Motor 1&2 steps
    · PAUSE time
    OUTH = %01000100··············· 'Motor 1&2 steps
    · PAUSE time
    OUTH = %01100110··············· 'Motor 1&2 steps
    · PAUSE time
    OUTH = %00100010··············· 'Motor 1&2 steps
    · PAUSE time
    OUTH = %00110011··············· 'Motor 1&2 steps
    · PAUSE time
    OUTH = %00010001··············· 'Motor 1&2 steps
    · PAUSE time
    OUTH = %10011001··············· 'Motor 1&2 steps
    · PAUSE time
    NEXT
Sign In or Register to comment.