Shop OBEX P1 Docs P2 Docs Learn Events
Multi Taking — Parallax Forums

Multi Taking

Robert HodgenRobert Hodgen Posts: 8
edited 2005-03-31 13:59 in Robotics
How can I get the BOE-Bot to multi task, I need it to play audio (using the command FREQOUT) and navigate (with IR) at the same time.


Thanks,
Robert

Comments

  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-03-30 16:41
    You can't. The BS2 is a single-tasking computer. If you can't interrupt the audio output long enough to scan the IR sensors then you'll need to attach some kind of slave audio device that can play your audio while the BASIC Stamp monitors sensors.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
    Dallas, TX· USA
  • Robert HodgenRobert Hodgen Posts: 8
    edited 2005-03-30 17:01
    Thanks, thats what I was thinking, I have an old BS1, I'll use that to play audio.
  • RsadeikaRsadeika Posts: 3,837
    edited 2005-03-30 17:24
    That is one of the reasons why I bought an SX kit. I do not have a BOE BOT, but on my robot, I was using a BS2 as the control unit. I do not know how you have your program set up, but I can give you an idea of how I had my program setup. Basically I have three items that have to be addressed, the dc motors, IR/detect unit, and IR remote control. The DC motors are separately powered, so once they are on, the motors run until it gets a signal to shut off. I use a main loop condition that has two subroutines, one to test for IR signal (IR LED for obsticle detection), and one for IR remote control. When you have the subroutines small enough, the BS2 is fast enough to loop and make it seem like it is "multi tasking", but not in the sense that we understand multitasking. For awhile that was satisfactory, I need the robot to do a lot more.

    BTW, I am pushing hard in the SX forum for example code to do these kinds of things, ie - play audio, IR remote control, IR/detect, .... , etc. Hope this helped.
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-03-30 19:10
    How about posting some example code? -- this is a "give and take" forum.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
    Dallas, TX· USA
  • The Dead BugThe Dead Bug Posts: 73
    edited 2005-03-30 20:29
    I don't know if this'll help but I've experimented quite some time ago with "finite state machine" programming which can emulate (sort of) multitasking. Here's a link to a good explanation with examples:

    http://www.bluebelldesign.com/FSM_explain.htm

    Bruce

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Name: Bruce Clemens

    Work:· Clemensb@otc.edu
    Good Stuff on my Blog: http://theDeadBug.journalspace.com
  • allanlane5allanlane5 Posts: 3,815
    edited 2005-03-30 21:35
    Yes, and Jon has released a Tasking framework (finite state machine) implementation.

    However, you still can't play music AND run a motor at the same time -- just interleaved very rapidly.

    Post Edited (allanlane5) : 3/30/2005 9:38:29 PM GMT
  • Robert HodgenRobert Hodgen Posts: 8
    edited 2005-03-30 21:51
    The IR navigation program out of the book that came with the BOE-Bot. I have some music a from a friend and I would like it to play that and navigate. Like I said earlier, I have a old BS1 that would work (although it may look 'riged').

    Can you also give me a little more information about your task manager?



    Robert
  • allanlane5allanlane5 Posts: 3,815
    edited 2005-03-30 21:56
    It's that link that I added at the bottom of the previous post.

    It lets you implement a finite state machine -- each time through the loop, the CurTask variable causes a GOSUB to a different sub-task subroutine. You'd have to time it to see what the cycle time is -- I assume it's around a milli-second, though.
  • RsadeikaRsadeika Posts: 3,837
    edited 2005-03-31 13:59
    I was looking for my actual code, to my dismay, I think it has gone to never never land. I did find a printout, but I cannot remember what stage of development it covers.

    The general idea for me was that I wanted the robot to start from a remote control -

    Main:

    ·DO

    ·· GOSUB GetRemCode 'Asubroutine that checks for a button push

    · IF (remoteCode > 0) then ProcessCode

    ·LOOP

    ProcessCode:

    IF(remoteCode = 21) then StopMov 'Red button STOP, robot stops

    IF(remoteCode = 11) then Xauto 'This starts the AUTO mode, free roaming

    return

    Within the processCode I would add all of the buttons that I wanted to use. Next came the actual loop, this is where it would check for the different states·-

    Xauto:

    GOSUB GoFore 'Starts the dc motors, free roaming

    Aloop:

    ·IR_outputs =0

    GOSUB CheckRem 'subroutine that checks to if remote control button was pushed

    'In here I had the code for the firing of the IRLED for the detector and detector code to respond to either IRLED or remote IRLED. I guess within this loop you could place all of the things that you would want done. The 'pseudo multitasking'.

    goto Aloop

    All of my subroutines were after this point.

    Basically this was the format that I tried to stick to. But you have to be very carefull with the use of your subroutines, and/or ending up with 'spaghetti code'. I always try to stick with the 'KISS' principal. If you need anything more specific, then feel free to ask, just try to keep the question as suscinct as possiple, that is·so I do not try to second guess you, and end up wasting everybodies time.
Sign In or Register to comment.