Multi-tasking problem?: need to turn on the lights for 10 seconds while ...
Archiver
Posts: 46,084
hi,
I have 5 human detectors and
I need to turn on 5 110volts lights for differents
amounts of time (i.e. 10 seconds)
But if I place a 10 seconds of pause
(i.e. pause 10000) for the first relay
to close the circuit for 10 seconds,
it will be impossible to detect human
using the other 4 sensors.
Is it a multi-tasking problem ?.
Any help is welcome thanks: Joe
__________________________________
Do you Yahoo!?
New Yahoo! Photos - easier uploading and sharing.
http://photos.yahoo.com/
I have 5 human detectors and
I need to turn on 5 110volts lights for differents
amounts of time (i.e. 10 seconds)
But if I place a 10 seconds of pause
(i.e. pause 10000) for the first relay
to close the circuit for 10 seconds,
it will be impossible to detect human
using the other 4 sensors.
Is it a multi-tasking problem ?.
Any help is welcome thanks: Joe
__________________________________
Do you Yahoo!?
New Yahoo! Photos - easier uploading and sharing.
http://photos.yahoo.com/
Comments
>hi,
>
>I have 5 human detectors and
>I need to turn on 5 110volts lights for differents
>amounts of time (i.e. 10 seconds)
>
> But if I place a 10 seconds of pause
>(i.e. pause 10000) for the first relay
>to close the circuit for 10 seconds,
>it will be impossible to detect human
>using the other 4 sensors.
>
>Is it a multi-tasking problem ?.
Not really, just don't pause. Poll the other detectors in lieu of pausing.
Use a counter to determine when to exit. The "count" will probably have to be
determined by trial and error. If you're using the BS-2p series there may be
other avenues as well.
>Any help is welcome thanks: Joe
Regards,
Bruce Bates
and turn it off. Just one big loop, or better, write a program that looks
at sensors and jumps to subroutines to turn on and off the relays. Circuits
to switch relays can be found at this web site.
jim
http://www.geocities.com/jimforkin2003/
Original Message
From: Joe Terk [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=ri2u0fFRVy5_R-GyVetosWbvl04pvIElQhDpiWm6t6FgwJ-LZvznDmvAfXxGOr8GPH-irrf9L1p_meo]joeterk@y...[/url
Sent: Friday, December 12, 2003 11:06 AM
To: basicstamps@yahoogroups.com
Subject: [noparse][[/noparse]basicstamps] Multi-tasking problem?: need to turn on the
lights for 10 seconds while ...
hi,
I have 5 human detectors and
I need to turn on 5 110volts lights for differents
amounts of time (i.e. 10 seconds)
But if I place a 10 seconds of pause
(i.e. pause 10000) for the first relay
to close the circuit for 10 seconds,
it will be impossible to detect human
using the other 4 sensors.
Is it a multi-tasking problem ?.
Any help is welcome thanks: Joe
__________________________________
Do you Yahoo!?
New Yahoo! Photos - easier uploading and sharing.
http://photos.yahoo.com/
To UNSUBSCRIBE, just send mail to:
basicstamps-unsubscribe@yahoogroups.com
from the same email address that you subscribed. Text in the Subject and
Body of the message will be ignored.
Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
You could use a shorter PAUSE together with a subroutine for checking your
detectors within a FOR loop like this:
FOR n = 0 TO 99
PAUSE 100
GOSUB CheckDetectors
NEXT
I hope this helps.
Best regards,
Russell Warburton
email: russell@w...
website: http://www.warburtech.com
telephone: +44 (0)7814 044 754
Original Message
From: "Joe Terk" <joeterk@y...>
To: <basicstamps@yahoogroups.com>
Sent: Friday, December 12, 2003 4:05 PM
Subject: [noparse][[/noparse]basicstamps] Multi-tasking problem?: need to turn on the lights
for 10 seconds while ...
> hi,
>
> I have 5 human detectors and
> I need to turn on 5 110volts lights for differents
> amounts of time (i.e. 10 seconds)
>
> But if I place a 10 seconds of pause
> (i.e. pause 10000) for the first relay
> to close the circuit for 10 seconds,
> it will be impossible to detect human
> using the other 4 sensors.
>
> Is it a multi-tasking problem ?.
>
> Any help is welcome thanks: Joe
>
>
>
> __________________________________
> Do you Yahoo!?
> New Yahoo! Photos - easier uploading and sharing.
> http://photos.yahoo.com/
>
> To UNSUBSCRIBE, just send mail to:
> basicstamps-unsubscribe@yahoogroups.com
> from the same email address that you subscribed. Text in the Subject and
Body of the message will be ignored.
>
>
> Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
>
>
>
Main:
DO
FOR idx = 0 TO 4
IF (timer(idx) = 0) THEN
IF (sensor(idx) = IsOn) THEN
timer(idx) = TimeDelay
light(idx) = IsOn
ELSE
light(idx) = IsOff
ENDIF
ELSE
timer(idx) = 0
ENDIF
NEXT
PAUSE LoopDelay
LOOP
END
The ideas is to use a small loop delay value (say 100 ms) and run it
multiple times (the value of TimeDelay) to create your long pauses.
-- Jon Williams
-- Applications Engineer, Parallax
-- Dallas Office
Original Message
From: Joe Terk [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=ObG7e656uHQF4ztAdbRd3di96O6V21rBZIhI3oSqGKtKLZZXUHRYPYe6XXlD0oDjLZOnyg1C4gFqdQ]joeterk@y...[/url
Sent: Friday, December 12, 2003 10:06 AM
To: basicstamps@yahoogroups.com
Subject: [noparse][[/noparse]basicstamps] Multi-tasking problem?: need to turn on the
lights for 10 seconds while ...
hi,
I have 5 human detectors and
I need to turn on 5 110volts lights for differents
amounts of time (i.e. 10 seconds)
But if I place a 10 seconds of pause
(i.e. pause 10000) for the first relay
to close the circuit for 10 seconds,
it will be impossible to detect human
using the other 4 sensors.
Is it a multi-tasking problem ?.
Any help is welcome thanks: Joe
__________________________________
Do you Yahoo!?
New Yahoo! Photos - easier uploading and sharing.
http://photos.yahoo.com/
To UNSUBSCRIBE, just send mail to:
basicstamps-unsubscribe@yahoogroups.com
from the same email address that you subscribed. Text in the Subject
and Body of the message will be ignored.
Your use of Yahoo! Groups is subject to
http://docs.yahoo.com/info/terms/
This message has been scanned by WebShield. Please report SPAM to
abuse@p....
Main:
DO
FOR idx = 0 TO 4 ' loop through channels
IF (timer(idx) = 0) THEN ' if timer expired, check sensor
IF (sensor(idx) = IsOn) THEN ' sensor active?
timer(idx) = TimeDelay ' -- yes, load timer
light(idx) = IsOn ' -- yes, turn on light
ELSE
light(idx) = IsOff ' timer expired, kill
light output
ENDIF
ELSE
timer(idx) - timer(idx) - 1 ' update this timer
ENDIF
NEXT
PAUSE LoopDelay
LOOP
END
Original Message
From: Jon Williams
Sent: Friday, December 12, 2003 10:24 AM
To: basicstamps@yahoogroups.com
Subject: RE: [noparse][[/noparse]basicstamps] Multi-tasking problem?: need to turn on the
lights for 10 seconds while ...
This is off the top of my head...
Main:
DO
FOR idx = 0 TO 4
IF (timer(idx) = 0) THEN
IF (sensor(idx) = IsOn) THEN
timer(idx) = TimeDelay
light(idx) = IsOn
ELSE
light(idx) = IsOff
ENDIF
ELSE
timer(idx) = 0
ENDIF
NEXT
PAUSE LoopDelay
LOOP
END
The ideas is to use a small loop delay value (say 100 ms) and run it
multiple times (the value of TimeDelay) to create your long pauses.
-- Jon Williams
-- Applications Engineer, Parallax
-- Dallas Office
Original Message
From: Joe Terk [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=Aeug9OdTD3hl0ZRn6uUv5q0d3amtca0qSTCnS7YtTTobWf2XH3DaA06-UJ38FvfvCqTyyUFqzrAimjk]joeterk@y...[/url
Sent: Friday, December 12, 2003 10:06 AM
To: basicstamps@yahoogroups.com
Subject: [noparse][[/noparse]basicstamps] Multi-tasking problem?: need to turn on the
lights for 10 seconds while ...
hi,
I have 5 human detectors and
I need to turn on 5 110volts lights for differents
amounts of time (i.e. 10 seconds)
But if I place a 10 seconds of pause
(i.e. pause 10000) for the first relay
to close the circuit for 10 seconds,
it will be impossible to detect human
using the other 4 sensors.
Is it a multi-tasking problem ?.
Any help is welcome thanks: Joe
__________________________________
Do you Yahoo!?
New Yahoo! Photos - easier uploading and sharing.
http://photos.yahoo.com/
To UNSUBSCRIBE, just send mail to:
basicstamps-unsubscribe@yahoogroups.com
from the same email address that you subscribed. Text in the Subject
and Body of the message will be ignored.
Your use of Yahoo! Groups is subject to
http://docs.yahoo.com/info/terms/
This message has been scanned by WebShield. Please report SPAM to
abuse@p....
To UNSUBSCRIBE, just send mail to:
basicstamps-unsubscribe@yahoogroups.com
from the same email address that you subscribed. Text in the Subject
and Body of the message will be ignored.
Your use of Yahoo! Groups is subject to
http://docs.yahoo.com/info/terms/
This message has been scanned by WebShield. Please report SPAM to
abuse@p....
people than answer. Joe
--- Jon Williams <jwilliams@p...> wrote:
> Oops... made a mistake. This is better, and I added
> comments.
>
> Main:
> DO
> FOR idx = 0 TO 4 ' loop through channels
> IF (timer(idx) = 0) THEN ' if timer expired,
> check sensor
>
> IF (sensor(idx) = IsOn) THEN ' sensor
> active?
> timer(idx) = TimeDelay ' -- yes, load
> timer
> light(idx) = IsOn ' -- yes, turn on
> light
> ELSE
> light(idx) = IsOff ' timer expired, kill
> light output
> ENDIF
> ELSE
> timer(idx) - timer(idx) - 1 ' update this
> timer
> ENDIF
> NEXT
> PAUSE LoopDelay
> LOOP
> END
>
>
>
Original Message
> From: Jon Williams
> Sent: Friday, December 12, 2003 10:24 AM
> To: basicstamps@yahoogroups.com
> Subject: RE: [noparse][[/noparse]basicstamps] Multi-tasking problem?:
> need to turn on the
> lights for 10 seconds while ...
>
>
> This is off the top of my head...
>
> Main:
> DO
> FOR idx = 0 TO 4
> IF (timer(idx) = 0) THEN
> IF (sensor(idx) = IsOn) THEN
> timer(idx) = TimeDelay
> light(idx) = IsOn
> ELSE
> light(idx) = IsOff
> ENDIF
> ELSE
> timer(idx) = 0
> ENDIF
> NEXT
> PAUSE LoopDelay
> LOOP
> END
>
> The ideas is to use a small loop delay value (say
> 100 ms) and run it
> multiple times (the value of TimeDelay) to create
> your long pauses.
>
> -- Jon Williams
> -- Applications Engineer, Parallax
> -- Dallas Office
>
>
>
>
Original Message
> From: Joe Terk [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=h3e6SUGVL29a04sYcGSczOIjPgeeyM2kbImHPuNWowDJrbJWlmJeB39Q6hodp1rqmf1uEFmPAzcXlg]joeterk@y...[/url
> Sent: Friday, December 12, 2003 10:06 AM
> To: basicstamps@yahoogroups.com
> Subject: [noparse][[/noparse]basicstamps] Multi-tasking problem?: need
> to turn on the
> lights for 10 seconds while ...
>
>
> hi,
>
> I have 5 human detectors and
> I need to turn on 5 110volts lights for differents
> amounts of time (i.e. 10 seconds)
>
> But if I place a 10 seconds of pause
> (i.e. pause 10000) for the first relay
> to close the circuit for 10 seconds,
> it will be impossible to detect human
> using the other 4 sensors.
>
> Is it a multi-tasking problem ?.
>
> Any help is welcome thanks: Joe
>
>
>
> __________________________________
> Do you Yahoo!?
> New Yahoo! Photos - easier uploading and sharing.
> http://photos.yahoo.com/
>
> To UNSUBSCRIBE, just send mail to:
> basicstamps-unsubscribe@yahoogroups.com
> from the same email address that you subscribed.
> Text in the Subject
> and Body of the message will be ignored.
>
>
> Your use of Yahoo! Groups is subject to
> http://docs.yahoo.com/info/terms/
>
>
>
>
> This message has been scanned by WebShield. Please
> report SPAM to
> abuse@p....
>
>
> To UNSUBSCRIBE, just send mail to:
> basicstamps-unsubscribe@yahoogroups.com
> from the same email address that you subscribed.
> Text in the Subject
> and Body of the message will be ignored.
>
>
> Your use of Yahoo! Groups is subject to
> http://docs.yahoo.com/info/terms/
>
>
>
>
> This message has been scanned by WebShield. Please
> report SPAM to
> abuse@p....
>
>
> To UNSUBSCRIBE, just send mail to:
> basicstamps-unsubscribe@yahoogroups.com
> from the same email address that you subscribed.
> Text in the Subject and Body of the message will be
> ignored.
>
>
> Your use of Yahoo! Groups is subject to
> http://docs.yahoo.com/info/terms/
>
>
__________________________________
Do you Yahoo!?
New Yahoo! Photos - easier uploading and sharing.
http://photos.yahoo.com/
1. The actual PAUSE doesn't take too long since it blocks looking at
the sensors during the PAUSEs.
2. The variable timing of the code part of the loop causes an
acceptable error in the time required for the lights being on.
For lighting lights after a person is detected, the above conditions
are probably met.
If the conditions are not met for your application, you can use
external timers in a Co-Processor (or other circuit) to get more
accurate timing.
I have a lot of information about timers and how to use them on my
website www.bluebelldesign.com. You can just learn about timers there
or you can buy our products which feature our Co-Processor which
includes timers (and ramping servo controllers, A/D, ...).
By the way, yes, it is multi-tasking but don't let that scare you. [noparse];)[/noparse]
As you can see from Jon's example, it isn't always as complicated as
it sounds.
Harry
Stamp Robotics to the next level
www.bluebelldesign.com
--- In basicstamps@yahoogroups.com, "Jon Williams" <jwilliams@p...>
wrote:
> Oops... made a mistake. This is better, and I added comments.
>
> Main:
> DO
> FOR idx = 0 TO 4 ' loop through
channels
> IF (timer(idx) = 0) THEN ' if timer expired,
check sensor
>
> IF (sensor(idx) = IsOn) THEN ' sensor active?
> timer(idx) = TimeDelay ' -- yes, load timer
> light(idx) = IsOn ' -- yes, turn on
light
> ELSE
> light(idx) = IsOff ' timer expired, kill
> light output
> ENDIF
> ELSE
> timer(idx) - timer(idx) - 1 ' update this timer
> ENDIF
> NEXT
> PAUSE LoopDelay
> LOOP
> END
>
>
<snip>
>
Original Message
> From: Joe Terk [noparse][[/noparse]mailto:joeterk@y...]
> Sent: Friday, December 12, 2003 10:06 AM
> To: basicstamps@yahoogroups.com
> Subject: [noparse][[/noparse]basicstamps] Multi-tasking problem?: need to turn on the
> lights for 10 seconds while ...
>
>
> hi,
>
> I have 5 human detectors and
> I need to turn on 5 110volts lights for differents
> amounts of time (i.e. 10 seconds)
>
> But if I place a 10 seconds of pause
> (i.e. pause 10000) for the first relay
> to close the circuit for 10 seconds,
> it will be impossible to detect human
> using the other 4 sensors.
>
> Is it a multi-tasking problem ?.
>
> Any help is welcome thanks: Joe
>
On thoses codes you wrote " ELSE", what is it for? I do not have that command
word in any of my books
Thank you!
Jon Williams a
Note MOST 'old' examples (and the 1.33 version of
the compiler) are the 'original' PBasic, which only
has an 'IF.. THEN <Goto Destination>' form.
--- In basicstamps@yahoogroups.com, rene genest <rene.genest@q...>
wrote:
> Hi Jon!
>
> On thoses codes you wrote " ELSE", what is it for? I do not have
that command
> word in any of my books
>
> Thank you!
>
> Jon Williams a
It is now available in PBASIC 2.5. PBASIC 1.0 (BS1) and PBASIC 2.0 use only the
IF-THEN {GOTO Address} structure which is very close the the machine language it
calls.
With IF-THEN-ELSE think of it this way: IF some condition is true, THEN do this
block of code, ELSE do this block of code:
IF (condition) THEN
'
' code for condition is True
'
ELSE
'
' code for condition if not True
'
ENDIF
-- Jon Williams
-- Applications Engineer, Parallax
-- Dallas Office
Original Message
From: rene genest [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=m2FAaPu800ry_efPt7dsVZ8gmX2jaV7uL55AEANn8-5uEonev3SXo1VqkLwUh3i02WRbX2ax48iMEVAKwA]rene.genest@q...[/url
Sent: Friday, December 12, 2003 8:07 PM
To: basicstamps@yahoogroups.com
Subject: Re: [noparse][[/noparse]basicstamps] Multi-tasking problem?: need to turn on the lights
for 10 seconds while ...
Hi Jon!
On thoses codes you wrote " ELSE", what is it for? I do not have that command
word in any of my books
Thank you!
Jon Williams a