Fake an Interrupt on a BS2
Tony-
This approach may help.
When BS2(1) expects and is prepared to accept a command from the PC,
it prompts the PC by sending a code to ask: "Do you have something
for me?". The PC's response can be a command, or other code meaning
"No". The PC waits for this prompt before it sends anything. This
will keep the PC and BS2(1) in sync.
Similarly, BS2(1) sends a command to BS2(2) which may tell BS2(2) to
transmit data back to BS2(1), do the data collection function or
whatever.
On BS2(2), if the low state on the input pin lasts long enough, you
can check for the signal and for incoming serial data from BS2(1) if
you use a very short timeout on the SERIN statement on BS2(2).
Let's say your low condition would be on I/O 0 and your serial
stream on I/O 1 (this would be in lieu of the BUTTON command etc.):
loop:
BRANCH IN0,[noparse][[/noparse] collect_data ] ' go do data collection if IN0 low
SERIN 1,baud,1,loop, [noparse][[/noparse] command ] ' go back to loop if idle
{do whatever based on command received}
This should work if your low condition lasts longer than a couple of
milliseconds.
Regards,
Steve
This approach may help.
When BS2(1) expects and is prepared to accept a command from the PC,
it prompts the PC by sending a code to ask: "Do you have something
for me?". The PC's response can be a command, or other code meaning
"No". The PC waits for this prompt before it sends anything. This
will keep the PC and BS2(1) in sync.
Similarly, BS2(1) sends a command to BS2(2) which may tell BS2(2) to
transmit data back to BS2(1), do the data collection function or
whatever.
On BS2(2), if the low state on the input pin lasts long enough, you
can check for the signal and for incoming serial data from BS2(1) if
you use a very short timeout on the SERIN statement on BS2(2).
Let's say your low condition would be on I/O 0 and your serial
stream on I/O 1 (this would be in lieu of the BUTTON command etc.):
loop:
BRANCH IN0,[noparse][[/noparse] collect_data ] ' go do data collection if IN0 low
SERIN 1,baud,1,loop, [noparse][[/noparse] command ] ' go back to loop if idle
{do whatever based on command received}
This should work if your low condition lasts longer than a couple of
milliseconds.
Regards,
Steve
Comments
The Application:
Two BS2's communicating serially via RF
BS2(1) can receive data serially (not DEBUG) from the PC or from BS
(2) RF
Based on commands from the PC, BS2(1) transmits data to BS2(2)
BS2(2) accepts data from BS2(1) RF
BS2(2) transmits collected data back to BS2(1) RF
BS2(2) collects data triggered by a low state on an input pin
The Dilemma –
BS2(1): Can you monitor 2 serial ports simultaneously, or is there a
balanced timing scheme for the WAIT commands to effectively look back
and forth. I have the serial communication working cleanly as I test
various parts of the code but when I put it together the timing goes
awry.
BS2(2): To simulate the data collection routine, I am using a BUTTON
command to monitor the 0 state on the input. I cannot figure out how
to monitor the serial WAIT and the BUTTON at the same time.
The Reasoning:
I have selected the BS2's because of their low power consumption
requirements. There is a strong chance that each unit will have to
run on batteries in certain situations and the BS2 seemed to fit the
application.
Any help on this would be GREATLY appreciated.
Thanks in advance.
TonyZ
tonyz@a...
>Reply-To: basicstamps@yahoogroups.com
>To: basicstamps@yahoogroups.com
>Subject: [noparse][[/noparse]basicstamps] Fake an Interrupt on a BS2
>Date: Mon, 16 Sep 2002 18:42:37 -0000
>
>I have been struggling with this problem for three days now…
>
>The Application:
>Two BS2's communicating serially via RF
>
>BS2(1) can receive data serially (not DEBUG) from the PC or from BS
>(2) RF
>Based on commands from the PC, BS2(1) transmits data to BS2(2)
>
>BS2(2) accepts data from BS2(1) RF
>BS2(2) transmits collected data back to BS2(1) RF
>BS2(2) collects data triggered by a low state on an input pin
>
>
>The Dilemma –
>BS2(1): Can you monitor 2 serial ports simultaneously, or is there a
>balanced timing scheme for the WAIT commands to effectively look back
>and forth. I have the serial communication working cleanly as I test
>various parts of the code but when I put it together the timing goes
>awry.
>
>BS2(2): To simulate the data collection routine, I am using a BUTTON
>command to monitor the 0 state on the input. I cannot figure out how
>to monitor the serial WAIT and the BUTTON at the same time.
>
>The Reasoning:
>I have selected the BS2's because of their low power consumption
>requirements. There is a strong chance that each unit will have to
>run on batteries in certain situations and the BS2 seemed to fit the
>application.
>
>Any help on this would be GREATLY appreciated.
>
>Thanks in advance.
>
>TonyZ
>tonyz@a...
>
>
This is probably not going to help at all, but one kind of "interrupt" would
be a reset to the basic stamp.
Paul
_________________________________________________________________
MSN Photos is the easiest way to share and print your photos:
http://photos.msn.com/support/worldwide.aspx