1. Multiple loops interrupt each other :(
- Posted by "Weichel" <steen.weichel at deepspace.dk> Jan 12, 2004
- 432 views
Hello list, I have a couple of loops that I want to run in parallel but, when I start number two the first stops and vise versa. When I stop number two number one will continue. Each loop are in a procedure for itself and I am using the IDE to develop the program. Thanks in advance for any input on this. Regards, Steen Weichel ---
2. Re: Multiple loops interrupt each other :(
- Posted by Isaac Raway <isaac-topica at blueapples.org> Jan 13, 2004
- 408 views
My advice is that you write this in C++. Euphoria as I understand it isn't meant to handle this sort of thing, and C++ excels at it. But, of course, that's probably not an option our you would have done that already... Weichel wrote: > > >I am trying to merge bit patterns for the parallel port data segment that is >the 8 data out registers. > >I have one stepper running one the four first bits, the other on the next >four bits. >Of course writing only to set a bit state for only one of the motors, will >also set the bits of the other motor. >So i have to merge the bit patterns into one bit pattern output for the port >which provides the required state for both motors. > >I think I will try to make three seperate programs: one for each motor and >then a third that will take data from the two motor programs and only do the >writing >to the port of the assembled bit pattern. A bit like Kat is suggesting. > >Any comments? and thanks for the advice. > >Steen Weichel > >-----Original Message----- >From: Matt Lewis [mailto:matthewwalkerlewis at yahoo.com] >Sent: 13. januar 2004 12:28 >To: EUforum at topica.com >Subject: RE: Multiple loops interrupt each other :( > > >>From: Kat >>On 12 Jan 2004, at 22:59, I Mullins wrote: >> >> >>>Weichel wrote: >>> >>> >>>>Hello list, >>>> >>>>I have a couple of loops that I want to run in parallel >>>>but, when I start number two the first stops and vise versa. >>>>When I stop number two number one will continue. >>>> >>>>Each loop are in a procedure for itself and I am using the IDE >>>>to develop the program. >>>> >>>> >>>Short answer: you can't. >>>Euphoria does not have threads. >>> >>>You might be able to write some tricky code which might appear to >>>operate in parallel, but it would be: 1. tricky, and 2. not >>>actual parallel processing. >>> >>> >>Two ways you can do this, and both means two separate programs: >> >>1) use dde, socks, or ipc to link two apps >>2) use the windows server in the archives, it's like win3.1 >>in written Eu! >> >> >Here's another: use timers instead of loops. You're using the IDE, so I >assume you're running under Windows. Set a couple of timers, and run >one iteration of the loop for each time the timer fires. The other >question I would ask is, what are you trying to do in the two loops? >Maybe there's a different (better?) way to do it. > >Matt Lewis > > >TOPICA - Start your own email discussion group. FREE! > > >--- >Incoming mail is certified Virus Free. >Checked by AVG anti-virus system (http://www.grisoft.com). >Version: 6.0.536 / Virus Database: 331 - Release Date: 03-11-2003 > >--- > > > >TOPICA - Start your own email discussion group. FREE! > >
3. Re: Multiple loops interrupt each other :(
- Posted by euphoric <euphoric at cklester.com> Jan 13, 2004
- 394 views
Weichel wrote: >I am trying to merge bit patterns for the parallel port data segment that is >the 8 data out registers. > >I have one stepper running one the four first bits, the other on the next >four bits. >Of course writing only to set a bit state for only one of the motors, will >also set the bits of the other motor. >So i have to merge the bit patterns into one bit pattern output for the port >which provides the required state for both motors. > >Any comments? and thanks for the advice. > > For each time interval, why not just read the whole port and have it process all the data? I don't get it (but that's not unusual). :) -- pseudo-code follows while i_say_go do x = read_port() y = left_4_bits(x) z = right_4_bits(x) y = process(y) z = process(z) x = combine(y,z) write_to_port( x ) end while
4. Re: Multiple loops interrupt each other :(
- Posted by euphoric <euphoric at cklester.com> Jan 13, 2004
- 401 views
Isaac Raway wrote: > > My advice is that you write this in C++. What are you, a sadist?!?! (or is that masochist?)
5. Re: Multiple loops interrupt each other :(
- Posted by euphoric <euphoric at cklester.com> Jan 13, 2004
- 402 views
Weichel wrote: >The problem is that the motors are for driving a telescope. > >One axis tracks the earth rotation and have a constant but tunable rate + >the option for slowing down or speeding up at a mouse click. >Other axis corrects error in misalignment to earth axis that is it may have >a slight constant drift in one direction + the option for slowing down or >speeding up at a mouse click. >So in the loops you have varying step speeds, currently controlled by a >time() fkt. and a time constant after which the loop continues to the next >step (4 steps for the four coils in the motor, then back again). >All speeds are controlled by varying the time between steps for each motor. >This is all working fine, but only one motor at a time. > >Therefore if I have to use only one loop it's very difficult not to have one >motor stepping rate influenced by the rate of the other. > > Check out the RDS game "LangWar" (comes standard with every EUPHORIA installation). It has an include file called sched.e... From what I can tell, your program is quite easily doable. -- sched.e -- Task Scheduler -- This is perhaps the most interesting source file since it shows a -- simple technique of task scheduling that could be used in any action -- game or simulation program. -- We have implemented a form of cooperative multitasking to manage over 10 -- independent tasks. There is a task that moves the Euphoria, another task -- that checks the keyboard for input, a task that makes enemy ships fire, -- another that counts down the damage report, etc. The sequence "tcb" records -- the time at which each task wants to be activated next. When the time comes -- to run a given task, next_task() will run it. -- For example, the task that moves the Euphoria will ask to be activated -- again in 20 seconds if the Euphoria is moving at warp 1, or much less at -- higher warps. The keyboard checking task is activated very frequently, but -- usually returns quickly (no key pressed). -- Some tasks require very precise activation times to make things look -- realistic, e.g. Euphoria moving at warp 5. Others do not, for example the -- BASIC TRUCE/HOSTILE/CLOAKING task which is activated after a lengthy and -- random amount of time. In recognition of this we have the "eat" (early -- activation tolerance) variable. After choosing the next task to run, and -- before entering into a delay loop to wait for the activation time to come, -- next_task() will check T_EARLY to see if it can activate the task a bit -- sooner. This will get this task out of the way and reduce the chance of a -- timing conflict with the next task. -- It's possible to have multiple logical tasks all running the same routine, -- but with different private data (parameters and private variables). For -- instance, there could be several torpedo tasks active at the same time. -- Each torpedo task has it's own set of private variables. It returns a -- sequence to next_task() containing the arguments that it wants to be -- called with the next time it is activated. This sequence is saved in the -- tcb for that task and allows it to preserve its own state variables -- between activations.
6. Re: Multiple loops interrupt each other :(
- Posted by "Euman" <euman at bellsouth.net> Jan 13, 2004
- 407 views
Hello Weichel, Do you have PLC programming experience? I assume these "motors" are "servo motors"..correct? The best method to achieve this in Euphoria is thru the use of timers and a seperate loop for each axis per servo. Euphoria "is" fast enough that servo input/output encoding can be acompilished for multiple servo's. You could run multiple instances of Euphoria and use Interprocess communcations (Filemapping mode) so each instance can share data.... Euman ----- Original Message ----- From: "Weichel" <steen.weichel at deepspace.dk> > > The problem is that the motors are for driving a telescope. > > One axis tracks the earth rotation and have a constant but tunable rate +
7. Re: Multiple loops interrupt each other :(
- Posted by Isaac Raway <isaac-topica at blueapples.org> Jan 14, 2004
- 411 views
Sadly, C++ is one of the best languages for threading and direct port access. Nothing is faster. C. K. Lester wrote: > > Isaac Raway wrote: > >> >> My advice is that you write this in C++. > > > What are you, a sadist?!?! (or is that masochist?) > > > > TOPICA - Start your own email discussion group. FREE! > >
8. Re: Multiple loops interrupt each other :(
- Posted by Isaac Raway <isaac-topica at blueapples.org> Jan 14, 2004
- 397 views
If you do use timers, *do not* use the standard Windows timers. You should use Multimedia Timers (which are accessed with a different set of Windows API functions. I don't know if this sub system is supported by any Euphoria wrappers.), which are guareteed to have a resolution of 1 millisecond. The problem with the standard timers (setTimer, etc) is that they have NO guaretees whastsoever. That means that if you ask for a timer event every 500 milleseconds, it could be a second or more between the actual events. Worse, there could be a whole pack of backed up events that you get really fast. This could burn out your motors. Euman wrote: > > >Hello Weichel, > >Do you have PLC programming experience? >I assume these "motors" are "servo motors"..correct? > >The best method to achieve this in Euphoria is thru the use >of timers and a seperate loop for each axis per servo. >Euphoria "is" fast enough that servo input/output encoding >can be acompilished for multiple servo's. > >You could run multiple instances of Euphoria and use >Interprocess communcations (Filemapping mode) so >each instance can share data.... > >Euman > >----- Original Message ----- >From: "Weichel" <steen.weichel at deepspace.dk> > > >>The problem is that the motors are for driving a telescope. >> >>One axis tracks the earth rotation and have a constant but tunable rate + >> >> > > >TOPICA - Start your own email discussion group. FREE! > >
9. Re: Multiple loops interrupt each other :(
- Posted by euphoric <euphoric at cklester.com> Jan 14, 2004
- 407 views
Isaac Raway wrote: > Sadly, C++ is one of the best languages for threading and direct port > access. Nothing is faster. That may be all well and true, but the true facts of the matter will come to light during the trial. Huh? What I mean is, is this instance, a "powerhouse on the PC, 4 stars, don't miss it!, this summer's number one hit" language like C++ would be overkill. Right? Why sacrifice ease-of-development for speed when you're not programming the next Unreal Tournament clone/killer? I rest my case. :) > > C. K. Lester wrote: > >> >> Isaac Raway wrote: >> >>> >>> My advice is that you write this in C++. >> >> >> What are you, a sadist?!?! (or is that masochist?) >> >> >> TOPICA - Start your own email discussion group. FREE! >> >> > > > TOPICA - Start your own email discussion group. FREE! > >
10. Re: Multiple loops interrupt each other :(
- Posted by Isaac Raway <isaac-topica at blueapples.org> Jan 14, 2004
- 406 views
> What I mean is, is this instance, a "powerhouse on the PC, 4 stars, > don't miss it!, this summer's number one hit" language like C++ would > be overkill. Right? Why sacrifice ease-of-development for speed when > you're not programming the next Unreal Tournament clone/killer? If you need threads... > > I rest my case. > Ditto. > :) > >> >> C. K. Lester wrote: >> >>> >>> Isaac Raway wrote: >>> >>>> >>>> My advice is that you write this in C++. >>> >>> >>> What are you, a sadist?!?! (or is that masochist?) >>> >>> >>> TOPICA - Start your own email discussion group. FREE! >>> >>> >> TOPICA - Start your own email discussion group. FREE! >> >> > > > TOPICA - Start your own email discussion group. FREE! > >
11. Re: Multiple loops interrupt each other :(
- Posted by euphoric <euphoric at cklester.com> Jan 14, 2004
- 411 views
Isaac Raway wrote: >> What I mean is, is this instance, a "powerhouse on the PC, 4 stars, >> don't miss it!, this summer's number one hit" language like C++ would >> be overkill. Right? Why sacrifice ease-of-development for speed when >> you're not programming the next Unreal Tournament clone/killer? > > If you need threads... > >> >> I rest my case. >> > Ditto. Well, counselor, threads aren't a requirement in this case. So now what ya gonna say?! LangWar has a multi-task control system. Have you taken a look at that? What's yer opinion uvvit.
12. Re: Multiple loops interrupt each other :(
- Posted by Isaac Raway <isaac-topica at blueapples.org> Jan 14, 2004
- 411 views
He wants to run multiple loops at the same time. Sounds like threads to me...using timers or other solutions came up because we can't do threads in Euphoria (by the way, are we sure about that?). But, the langwar system is defiantly interesting. Probably about the best you could do with a pure Euphoria solution. My only gripes with it might be that it's resolution is sort of unclear, and that it's management of tcb variable could be a bit better (such as growing by several spaces instead of one at a time). I think Multimedia Timers are still the way to go. But...now that I think about it again, I don't know if it's possible because you have to pass timeSetEvent a procedure address...we can't do that can we? Oh well. Feature for 2.5: Threads. Isaac C. K. Lester wrote: > > Isaac Raway wrote: > >>> What I mean is, is this instance, a "powerhouse on the PC, 4 stars, >>> don't miss it!, this summer's number one hit" language like C++ >>> would be overkill. Right? Why sacrifice ease-of-development for >>> speed when you're not programming the next Unreal Tournament >>> clone/killer? >> >> >> If you need threads... >> >>> >>> I rest my case. >>> >> Ditto. > > > Well, counselor, threads aren't a requirement in this case. So now > what ya gonna say?! > > LangWar has a multi-task control system. Have you taken a look at > that? What's yer opinion uvvit. > > > > TOPICA - Start your own email discussion group. FREE! > >
13. Re: Multiple loops interrupt each other :(
- Posted by euphoric <euphoric at cklester.com> Jan 14, 2004
- 410 views
Isaac Raway wrote: > He wants to run multiple loops at the same time. But I think his algorithm is flawed... I don't think he needs to run multiple loops, does he? I thought it was just checking a port and writing to the port.
14. Re: Multiple loops interrupt each other :(
- Posted by "Elliott S. de Andrade" <quantum_analyst at hotmail.com> Jan 14, 2004
- 409 views
>From: Isaac Raway <isaac-topica at blueapples.org> >Subject: Re: Multiple loops interrupt each other :( > >He wants to run multiple loops at the same time. Sounds like threads to >me...using timers or other solutions came up because we can't do threads in >Euphoria (by the way, are we sure about that?). > Quite definitely, I've tried with a few libraries. >I think Multimedia Timers are still the way to go. But...now that I think >about it again, I don't know if it's possible because you have to pass >timeSetEvent a procedure address...we can't do that can we? Oh well. > Yes, of course, just use a function, and return some junk value. It's just discarded anyway. >Feature for 2.5: Threads. > Yep, I'd agree with that. It would also be nice to be able to ignore a function's return value, with my suggestion of prepending the function with ~. It's noticeable, simple, and not confusing (for a reader, or the parser, even). >Isaac >