Sign in

username:

password:



Not a member?

Search basicx



Search tips

Subscribe to basicx



basicx by Keywords

Accelerometer | ADC | ADXL | Adxl20 | AVR | BasicStamp | BX-35 | BX28 | BX35 | COM3 | Compiler | Downloader | EEPROM | Electromagnet | GetADC | GP2D1 | GPS | I2C | IDE | Keypad | LCD | LCD+ | MIDI | Motors | Multitasking | Netmedia | Networking | PCB | PID | PlaySound | PWM | Relays | RTC | Servo | ShiftOut | SitePlayer | SPI | Stack | Timer | USB

Sponsor

controlSUITE™ software
Comprehensive.
Intuitive.
Optimized.

Real-world software for real-time control. Details Here!

Ads

Discussion Groups

See Also

DSPFPGAElectronics

Discussion Groups | BasicX | Continued problems with pseudo networking

Discussion forum for the BasicX family of microcontroller chips.

Re: Continued problems with pseudo networking - Neil Jepsen - Mar 31 15:34:00 2003

Ken I have successfully got 2- BX24's to talk to each other using
statusqueue, and I also found that timing is v important. I found that
a debug.print in the receive loop was too slow and resulted in missed
bytes. I can post you some working code if you wish.
neil Michael Puchol wrote:

> This timing issue is very true, and I've seen it happen - StatusQueue
> is
> very fast, and will miss two consecutive bytes arriving, they simply
> don't
> arrive fast enough.
>
> What you can do is this, if you want a routine that will grab a
> variable
> amount of data with a certain timeout:
>
> // BEGIN CODE
>
> Dim tmpString as String * 10 ' <= Change this to accomodate longer or
>
> shorter strings
> Dim InChar as Byte
> Dim TimeOut as Single
>
> TimeOut = Timer
>
> Wait_OK:
>
> ' Fill a string with incoming characters. Can be applied to a byte
> array by
> using an incremental counter
> If StatusQueue(InBuffer) Then
> Call GetQueue(InBuffer, InChar, 1)
> tmpString = tmpString & Chr(InChar)
> If Timer < (TimeOut + 5.0) Then ' <= Applies a 5 second
> timeout, i.e.
> the routine will wait for five seconds after the last byte is received
>
> before continuing
> Goto Wait_OK
> End If
> End If
>
> // END CODE
>
> Hope it helps,
>
> Mike > ----- Original Message -----
> From: "Doug" <>
> To: <>
> Sent: Tuesday, April 01, 2003 2:25 PM
> Subject: Re: [BasicX] Continued problems with pseudo networking > > Ken,
> >
> > Think about what you are doing here ... on the sending
> > processor you loop 10 times and send 10 bytes which is
> > the contents of the array ... on the receiving processor
> > you check StatusQueue only ONCE and then loop ten times
> > executing GetQueue. The issue is timing ... what happens
> > on the receiving end when the loop counter increments
> > and the bytes are not there yet? You need to make this
> > purely asynchronous.
> >
> > In other words forget receiving an array, receive
> > individual bytes and stuff them into an array. The
> > sending end can probably stay the same. But on the
> > receiving end you need to ditch the For loop. Rather
> > than using the For loop use a counter to count the
> > bytes. You want the StatusQueue to be triggered TEN
> > times, not ONCE. Try this ...
> >
> > Dim ByteCtr As Integer
> > Dim InData As Byte
> >
> > ByteCtr = 0
> > Do While (ByteCtr < 10)
> > If StatusQueue(InBx) Then
> > ByteCtr = ByteCtr + 1
> > Call GetQueue(InBx, InData , 1)
> > Array(ByteCtr) = InData
> > End If
> > Loop
> >
> > This way StatusQueue will be triggered for each byte
> > that arrives on the pin. I'm not surprised that your
> > code doesn't work ... your For loop chugs along
> > before the next byte arrives ... there is not a one
> > to one matching between StatusQueue and GetQueue ...
> >
> > -- Doug
> >
> >
> >
> >
> >
> >
> >
> >
> > Yahoo! Groups Sponsor
ADVERTISEMENT >
> Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service. [Non-text portions of this message have been removed]





(You need to be a member of basicx -- send a blank email to basicx-subscribe@yahoogroups.com )


Re: Continued problems with pseudo networking - Doug - Apr 1 5:28:00 2003

Ken,

Perhaps you should post your code ...

-- Doug

Ken wrote:
>After a week of playing with my pseudo networking idea between two BX-35's,
>I am totally frustrated. StatusQueue does not seem to work as the manual
>says it should (nor does GetQueueCount) and data between the two chips is
>frequently corrupt (if it even shows up at the "other" BX at all).
>
>There is nothing fancy about my code - I am simply trying to move 10 bytes
>from one BX to another BX. Perhaps I need to re-evaluate my use of the '35s
>for my application...




(You need to be a member of basicx -- send a blank email to basicx-subscribe@yahoogroups.com )

Re: Continued problems with pseudo networking - Doug - Apr 1 6:52:00 2003

Ken,

This may not make sense ... but I would try putting the
array value into a single byte and sending the single
byte ... and on the other end receiving into a single
byte then loading it into an array. I'm just grasping
at straws here, but better to eliminate the array from
the debugging. Also, do some debug statements on those
incoming bytes before they are put into the array. What
type of data is in the array?

Just FYI Protean logic has some serial buffer ICs in
8-in DIP format. They hold data in a buffer if the
microcontroller can't read the data fast enough or if
it's doing other things. For example let's say you
want to read from three different devices, definining
Com3 on different pins, you can use the buffer ICs to
hold the data. Then you can cycle between the three
devices and not lose data from any of the three inputs.
They are called RS509s ... I have some here but have
not tried them yet. Will be trying them soon. On some
of my projects I have multiple human input devices
where I want to read them all and never miss any bits.

http://www.protean-logic.com/Applications/an034/an034.htm
http://www.protean-logic.com/Applications/an012/rsb509.htm

You shouldn't need these to just connect two BX35s
together, but they may come in handy if you want the
Com3 port to cycle between different inputs ...

-- Doug


______________________________
controlSUITE™ software. Comprehensive. Intuitive. Optimized.
Real-world software for real-time control. Details Here!



(You need to be a member of basicx -- send a blank email to basicx-subscribe@yahoogroups.com )

Re: Continued problems with pseudo networking - Doug - Apr 1 7:25:00 2003

Ken,

Think about what you are doing here ... on the sending
processor you loop 10 times and send 10 bytes which is
the contents of the array ... on the receiving processor
you check StatusQueue only ONCE and then loop ten times
executing GetQueue. The issue is timing ... what happens
on the receiving end when the loop counter increments
and the bytes are not there yet? You need to make this
purely asynchronous.

In other words forget receiving an array, receive
individual bytes and stuff them into an array. The
sending end can probably stay the same. But on the
receiving end you need to ditch the For loop. Rather
than using the For loop use a counter to count the
bytes. You want the StatusQueue to be triggered TEN
times, not ONCE. Try this ...

Dim ByteCtr As Integer
Dim InData As Byte

ByteCtr = 0
Do While (ByteCtr < 10)
If StatusQueue(InBx) Then
ByteCtr = ByteCtr + 1
Call GetQueue(InBx, InData , 1)
Array(ByteCtr) = InData
End If
Loop

This way StatusQueue will be triggered for each byte
that arrives on the pin. I'm not surprised that your
code doesn't work ... your For loop chugs along
before the next byte arrives ... there is not a one
to one matching between StatusQueue and GetQueue ...

-- Doug





(You need to be a member of basicx -- send a blank email to basicx-subscribe@yahoogroups.com )

Re: Continued problems with pseudo networking - Doug - Apr 1 7:35:00 2003

Sending processor sends a byte ... Receiving processor reads
StatusQueue and triggers the For Loop ... loads the first
value in array (1) ... then increments the For loop ...

Sending processor sends another byte ... Receiving processor
reads StatusQueue and starts the For loop all over again!
The array index goes back to 1 and ... you will never stuff
the right array elements into the right position ...

-- Doug




(You need to be a member of basicx -- send a blank email to basicx-subscribe@yahoogroups.com )

Continued problems with pseudo networking - Ken Arck - Apr 1 12:25:00 2003

After a week of playing with my pseudo networking idea between two BX-35's,
I am totally frustrated. StatusQueue does not seem to work as the manual
says it should (nor does GetQueueCount) and data between the two chips is
frequently corrupt (if it even shows up at the "other" BX at all).

There is nothing fancy about my code - I am simply trying to move 10 bytes
from one BX to another BX. Perhaps I need to re-evaluate my use of the '35s
for my application...

Ken
(rant over.....)





(You need to be a member of basicx -- send a blank email to basicx-subscribe@yahoogroups.com )

Re: Continued problems with pseudo networking - Ken Arck - Apr 1 12:58:00 2003

At 12:28 PM 4/1/2003 +0200, you wrote:

Perhaps you should post your code ...

<---Here it is

1st BX-35 (this code is only called if a certain event occurs.)
----------------------------------------------------------------------------
----------

Dim OutBx(1 to 30) as Byte
Dim InBx(1 to 30) as Byte
Dim Array(1 to 10) as Byte
Dim A as Byte

Call OpenQueue(InBx, 30)
Call OpenQueue(OutBx, 30)
Call DefineCom3(21, 22, bx0000_1000)
Call OpenCom(3, 19200, InBx, OutBx)

For A = 1 to 10
Call PutQueue(OutBx, Array(A) , 1)
Next
---------------------------------------------------------------- 2nd BX-35 (this is a continuous Do loop)
----------------------------------------------------------

Dim OutBx(1 to 30) as Byte
Dim InBx(1 to 30) as Byte
Dim Array(1 to 10) as Byte
Dim A as Byte

Call OpenQueue(InBx, 30) 'Open Queues and Comport
Call OpenQueue(OutBx, 30)
Call DefineCom3(1, 3, bx0000_1000) '8 bit, no parity, non-inverted
Call OpenCom(3, 19200, InBx, OutBx) 'open com port at 19,200 baud rate

If StatusQueue(InBx) Then
For A = 1 to 10
Call GetQueue(InBx, Command_Array(A) , 1)
Debug.Print CStr(Command_Array(A))
Sleep(0.01)
Next
End If
Call ClearQueue(InBx)
---------------------------------------------------------------------------

(the debug.print statement is in for testing purposes only and I've tried
different values for the sleep call)

1st BX 2nd BX
--------- ----------

Pin 21 ---------------> Pin 3
Pin 22 ---------------> Pin 1




______________________________
controlSUITE™ software. Comprehensive. Intuitive. Optimized.
Real-world software for real-time control. Details Here!



(You need to be a member of basicx -- send a blank email to basicx-subscribe@yahoogroups.com )

Re: Continued problems with pseudo networking - Ken Arck - Apr 1 13:00:00 2003

Ooops... in the second BX code, the variable should be Array, not
Command_Array

Ken
------ http://www.ah6le.net
Version 3.0 of the RC-110 controller is now available.
http://www.ah6le.net/arcom/rc110.html
Coming soon! The RC-210 controller with tons more features!
AH6LE/R - IRLP Node 3000
http://www.irlp.net



______________________________
controlSUITE™ software. Comprehensive. Intuitive. Optimized.
Real-world software for real-time control. Details Here!



(You need to be a member of basicx -- send a blank email to basicx-subscribe@yahoogroups.com )

Re: Continued problems with pseudo networking - Dave Houston - Apr 1 13:08:00 2003

Change your Send routine to...

Call PutQueue(OutBx, Array(1), 10)

Change your receive routine to...

If StatusQueue(InBx) Then
Call Delay(0.025) 'You may need to play with this value
Call GetQueue(InBx, Command_Array(1), 10)
For A = 1 to 10
Debug.Print CStr(Command_Array(A))
Next
End If

On 1 Apr 2003, at 9:58, Ken Arck wrote:

> At 12:28 PM 4/1/2003 +0200, you wrote:
>
> Perhaps you should post your code ...
>
> <---Here it is
>
> 1st BX-35 (this code is only called if a certain event occurs.)
> ----------------------------------------------------------------------
> ------ ----------
>
> Dim OutBx(1 to 30) as Byte
> Dim InBx(1 to 30) as Byte
> Dim Array(1 to 10) as Byte
> Dim A as Byte
>
> Call OpenQueue(InBx, 30)
> Call OpenQueue(OutBx, 30)
> Call DefineCom3(21, 22, bx0000_1000)
> Call OpenCom(3, 19200, InBx, OutBx)
>
> For A = 1 to 10
> Call PutQueue(OutBx, Array(A) , 1)
> Next
> ---------------------------------------------------------------- > 2nd BX-35 (this is a continuous Do loop)
> ----------------------------------------------------------
>
> Dim OutBx(1 to 30) as Byte
> Dim InBx(1 to 30) as Byte
> Dim Array(1 to 10) as Byte
> Dim A as Byte
>
> Call OpenQueue(InBx, 30) 'Open Queues and Comport
> Call OpenQueue(OutBx, 30)
> Call DefineCom3(1, 3, bx0000_1000) '8 bit, no parity, non-inverted
> Call OpenCom(3, 19200, InBx, OutBx) 'open com port at 19,200 baud
> rate
>
> If StatusQueue(InBx) Then
> For A = 1 to 10
> Call GetQueue(InBx, Command_Array(A) , 1)
> Debug.Print CStr(Command_Array(A))
> Sleep(0.01)
> Next
> End If
> Call ClearQueue(InBx)
> ----------------------------------------------------------------------
> -----
>
> (the debug.print statement is in for testing purposes only and I've
> tried different values for the sleep call)
>
> 1st BX 2nd BX
> --------- ----------
>
> Pin 21 ---------------> Pin 3
> Pin 22 ---------------> Pin 1 >
>
> ------------------------ Yahoo! Groups Sponsor
> ---------------------~--> Get 128 Bit SSL Encryption!
> http://us.click.yahoo.com/W7NydA/hdqFAA/VygGAA/dN_tlB/TM
> ---------------------------------------------------------------------~
> - >
> ---
http://www.laser.com/dhouston/





(You need to be a member of basicx -- send a blank email to basicx-subscribe@yahoogroups.com )

Re: Continued problems with pseudo networking - Ken Arck - Apr 1 13:26:00 2003

At 01:08 PM 4/1/2003 -0500, you wrote:
>>>>
Change your Send routine to...

Call PutQueue(OutBx, Array(1), 10)

<---Wouldn't that place the same value - Array(1) - 10 times into the queue?

Ken
------ http://www.ah6le.net
Version 3.0 of the RC-110 controller is now available.
http://www.ah6le.net/arcom/rc110.html
Coming soon! The RC-210 controller with tons more features!
AH6LE/R - IRLP Node 3000
http://www.irlp.net






(You need to be a member of basicx -- send a blank email to basicx-subscribe@yahoogroups.com )

Re: Continued problems with pseudo networking - Michael Puchol - Apr 1 14:43:00 2003

This timing issue is very true, and I've seen it happen - StatusQueue is
very fast, and will miss two consecutive bytes arriving, they simply don't
arrive fast enough.

What you can do is this, if you want a routine that will grab a variable
amount of data with a certain timeout:

// BEGIN CODE

Dim tmpString as String * 10 ' <= Change this to accomodate longer or
shorter strings
Dim InChar as Byte
Dim TimeOut as Single

TimeOut = Timer

Wait_OK:

' Fill a string with incoming characters. Can be applied to a byte array by
using an incremental counter
If StatusQueue(InBuffer) Then
Call GetQueue(InBuffer, InChar, 1)
tmpString = tmpString & Chr(InChar)
If Timer < (TimeOut + 5.0) Then ' <= Applies a 5 second timeout, i.e.
the routine will wait for five seconds after the last byte is received
before continuing
Goto Wait_OK
End If
End If

// END CODE

Hope it helps,

Mike ----- Original Message -----
From: "Doug" <>
To: <>
Sent: Tuesday, April 01, 2003 2:25 PM
Subject: Re: [BasicX] Continued problems with pseudo networking > Ken,
>
> Think about what you are doing here ... on the sending
> processor you loop 10 times and send 10 bytes which is
> the contents of the array ... on the receiving processor
> you check StatusQueue only ONCE and then loop ten times
> executing GetQueue. The issue is timing ... what happens
> on the receiving end when the loop counter increments
> and the bytes are not there yet? You need to make this
> purely asynchronous.
>
> In other words forget receiving an array, receive
> individual bytes and stuff them into an array. The
> sending end can probably stay the same. But on the
> receiving end you need to ditch the For loop. Rather
> than using the For loop use a counter to count the
> bytes. You want the StatusQueue to be triggered TEN
> times, not ONCE. Try this ...
>
> Dim ByteCtr As Integer
> Dim InData As Byte
>
> ByteCtr = 0
> Do While (ByteCtr < 10)
> If StatusQueue(InBx) Then
> ByteCtr = ByteCtr + 1
> Call GetQueue(InBx, InData , 1)
> Array(ByteCtr) = InData
> End If
> Loop
>
> This way StatusQueue will be triggered for each byte
> that arrives on the pin. I'm not surprised that your
> code doesn't work ... your For loop chugs along
> before the next byte arrives ... there is not a one
> to one matching between StatusQueue and GetQueue ...
>
> -- Doug




(You need to be a member of basicx -- send a blank email to basicx-subscribe@yahoogroups.com )

Re: Continued problems with pseudo networking - Frank Manning - Apr 1 14:51:00 2003

From: "Michael Puchol" <>

> This timing issue is very true, and I've seen it
> happen - StatusQueue is very fast, and will miss
> two consecutive bytes arriving, they simply don't
> arrive fast enough.
>
> What you can do is this, if you want a routine
> that will grab a variable amount of data with a
> certain timeout: [...]

Excellent point. Incidentally, the beta 2 IDE overloads GetQueue
so you can specify an optional timeout. This was added in response
to a suggestion by Dave Houston.

-- Frank Manning
-- NetMedia, Inc.




(You need to be a member of basicx -- send a blank email to basicx-subscribe@yahoogroups.com )

Re: Continued problems with pseudo networking - Ken Arck - Apr 1 14:52:00 2003

At 01:52 PM 4/1/2003 +0200, you wrote:

>What type of data is in the array?

<----Bytes

>Think about what you are doing here ... on the sending
>processor you loop 10 times and send 10 bytes which is
>the contents of the array ... on the receiving processor
>you check StatusQueue only ONCE and then loop ten times
>executing GetQueue. The issue is timing ... what happens
>on the receiving end when the loop counter increments
>and the bytes are not there yet?

<----I had assumed a queue was FIFO and each byte remained in the queue
until either flushed or read. So if I stuffed 10 bytes into the sending
queue, they would remain there until "plucked" out - one at a time - by the
receiving queue and timing wouldn't be an issue. Apparently this is not the
case....

I'll try your code and see how it goes. Thanks to you, Dave and others who
have offered me assistance!

Ken ------ http://www.ah6le.net
Version 3.0 of the RC-110 controller is now available.
http://www.ah6le.net/arcom/rc110.html
Coming soon! The RC-210 controller with tons more features!
AH6LE/R - IRLP Node 3000
http://www.irlp.net






(You need to be a member of basicx -- send a blank email to basicx-subscribe@yahoogroups.com )

Re: Continued problems with pseudo networking - Frank Manning - Apr 1 15:04:00 2003

From: Ken Arck <>

> From: Doug <>
>>
>> Think about what you are doing here ... on the sending
>> processor you loop 10 times and send 10 bytes which is
>> the contents of the array ... on the receiving processor
>> you check StatusQueue only ONCE and then loop ten times
>> executing GetQueue. The issue is timing ... what happens
>> on the receiving end when the loop counter increments
>> and the bytes are not there yet?

This is a good point, but in this case GetQueue blocks the task
until data arrives.

> I had assumed a queue was FIFO and each byte remained
> in the queue until either flushed or read.

That's correct.

> So if I stuffed 10 bytes into the sending queue, they
> would remain there until "plucked" out - one at a
> time - by the receiving queue and timing wouldn't be
> an issue.

True. Timing is an issue, but not in this case. If you call
GetQueue on an empty queue, the task halts until a byte arrives.

-- Frank Manning
-- NetMedia, Inc.



______________________________
controlSUITE™ software. Comprehensive. Intuitive. Optimized.
Real-world software for real-time control. Details Here!



(You need to be a member of basicx -- send a blank email to basicx-subscribe@yahoogroups.com )

Re: Continued problems with pseudo networking - Ken Arck - Apr 1 15:17:00 2003

At 03:12 PM 4/1/2003 +0200, you wrote: Ooops ... I didn't realize that ... so the receiving
program halts completely? So then ... any idea why Ken's
simple program doesn't reproduce the array on the other
side?

<---that's my question too. If I read Frank's comments correctly, doing it
byte-by-byte should have worked.

Ken
------ http://www.ah6le.net
Version 3.0 of the RC-110 controller is now available.
http://www.ah6le.net/arcom/rc110.html
Coming soon! The RC-210 controller with tons more features!
AH6LE/R - IRLP Node 3000
http://www.irlp.net





(You need to be a member of basicx -- send a blank email to basicx-subscribe@yahoogroups.com )

Re: Continued problems with pseudo networking - Frank Manning - Apr 1 16:07:00 2003

From: Ken Arck <>

> Doug wrote:
>
>> Ooops ... I didn't realize that ... so the receiving
>> program halts completely? So then ... any idea why Ken's
>> simple program doesn't reproduce the array on the other
>> side?
>
> that's my question too. If I read Frank's comments
> correctly, doing it byte-by-byte should have worked.

One difficulty I see is in looking at code fragments instead of a
working program. But making an educated guess, it's possible that
a byte could arrive just after StatusQueue, but before ClearQueue.
If that happens, ClearQueue will erase the byte, and the data is
lost. This is just a guess -- the actual problem could be
something completely different.

I modified the receiving program to use Com1, which allows you to
type data in the monitor port. In the program, if you uncomment
the ClearQueue line, it's difficult to get the loop started.

This may or may not be representative of the code in question. I'm
kind of filling in the blank spots:

'---------------------------------------------------------------
Option Explicit

Dim OutBx(1 to 30) as Byte
Dim InBx(1 to 30) as Byte
Dim Command_Array(1 to 10) as Byte
'---------------------------------------------------------------
Public Sub Main()

Call OpenQueue(InBx, 30)
Call OpenQueue(OutBx, 30)
Call OpenCom(1, 19200, InBx, OutBx)

Dim A As Integer

Do
If StatusQueue(InBx) Then
Debug.Print
Debug.Print "--- Receiving array ---"
For A = 1 to 10
Call GetQueue(InBx, Command_Array(A), 1)
Debug.Print CStr(A); " "; CStr(Command_Array(A))
Sleep(0.01)
Next
End If

' Original code was uncommented.
'>> Call ClearQueue(InBx)
Loop

End Sub
'---------------------------------------------------------------

-- Frank Manning
-- NetMedia, Inc.




(You need to be a member of basicx -- send a blank email to basicx-subscribe@yahoogroups.com )