Running Subroutines simultaneously
guitarists10
Posts: 1
I am trying to find out how to run subroutines simultaneously but if does not seem to work. If someone could help me out I would greatly appreciate it. Thanks a bunch
Comments
If you would describe what you're trying to accomplish, someone may be able to suggest other ways of doing it that don't require actual simultaneous execution of more than subroutine at a time.
Some simultaneous tasks can be handled by using special purpose external co-processors like a ServoPAL or SoundPAL or any of several 3rd party external co-processors that can do some specific task for the Stamp and be controlled by the Stamp, yet function independently.
I have a "CONTROLLING" Sub-Routine that LOOPs thru itself(DO/LOOP). Each time thru it will GOSUB to each routine below (1,2,3,4), at the start of each Sub-routine I check for a PIN(HIGH/LOW), If all is OK then I bounce back to the "CONTROLLING" Sub-routine for the next one to check. Once all Sub-routines are checked then I just start the "CONTROLLING" sub-routine all over again(I have time delays...DS1302 and there must be and error) so it will not exit from this "CONTROLLING" Sub-Routine. Once the ERROR has Cleared or I press a certain button(then setting a FLAG) the "CONTROLLING" Sub-Routine returns me back to the MainMenu or the MainMonitoring routine(ALL Clear). I found that I had to set FLAGs to know what to do when I got back to the "CONTROLLING" and check those FLAGs.
1) Do Sub-routine(1)...Monitor Pins 2,3,4,5..etc. also. If the state of the other pins change set a Flag(s) while still within Sub-Routine(1)
2) Do Sub-routine(2)...Monitor Pins 1,3,4,5..etc. also. If the state of the other pins change set a Flag(s) while still within Sub-Routine(2)
3) Do Sub-routine(3)...Monitor Pins 1,2,4,5..etc. also. If the state of the other pins change set a Flag(s) while still within Sub-Routine(3)
4) Do Sub-routine(4)...Monitor Pins 1,2,3,5..etc. also. If the state of the other pins change set a Flag(s) while still within Sub-Routine(4)
For what I'm looking to do, this Process works very very well, the BS2/e is more then fast enough. But I'm using timers(3) to the minute though.
1)Start of Program
2)Main Body of program(to do initial check for errors)
3)Gosub to "CONTROLLING" Sub-routine...That will monitor the 2,3, or 4 other Sub-routines
4)Once either one of these Sub-routine(s) are done you always return to the "CONTROLLING" sub-routine.
5)Within the "CONTROLLING" sub-routine check for the same errors or event to if they have cleared and if you can return to STEP 2)
6)If you still have an error stay within the "CONTROLLING" sub-routine
I only monitor the change of state of pins(three of them) and time delays(three of them) and Button Pins so it was easy to do...after starring at the ceiling every night for 2 - 3 hours a night for a week(Ha Ha...laugh now but its true) to get the Logic/ Steps/Process down.
hope this BAD semi-Pseudo code comes close to helping...
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
I'M STILL LEARNING SO MUCH...BUT STILL KNOW SO LITTLE!!!
hmlittle59
So what is preventing you to run your process depending on that?
In other words – you have 8 possible states so you should have 8 possible processes / subroutines. It should be possible, but may be messy, to have each one of these processes continue to monitor the inputs. Sounds like a good candidate for implementation of “state machine”.
What did I miss?
I'm still testing for all different kind of situation that would cause it to fail but so far so good.
Remember I'm only monitoring down to the MINUTE. Not seconds or split seconds. That would makes it harder to trap certain time events.
I also monitor for exit BUTTON push...
Oh well...Back to testing...hope this helps someone.
PS: MY Miami Dolphins are not 0 and 2...NOT GOOD!!!
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
I'M STILL LEARNING SO MUCH...BUT STILL KNOW SO LITTLE!!!
hmlittle59