Shop OBEX P1 Docs P2 Docs Learn Events
SPSTR and Serout — Parallax Forums

SPSTR and Serout

dcoferdcofer Posts: 2
edited 2006-03-04 02:55 in BASIC Stamp
I am trying to implement fast data transfer between my PC and a BS2p40 chip. I am working with something that will need to send/recieve data with the computer constantly as fast as possible. I have done a number of speed tests and it turns out that I can recieve data much faster than I can send it. The reason for this is that I am using the SPSTR modifier with the serin command to directly write X number of bytes into scratchpad ram. But this modifier does not appear to work for serout. So the best I can do there is create a 20 byte array in my main memory, copy data from scratch pad into the array,·send that data·out, and repeat this for all the data. From the numbers I have run it looks like the thing that is slowing stuff down the most is the execution of the instructions in the loops that are needed to prep the temporary arrays for transmission. Serin with SPSTR appears to be optimized in some way so that it is much faster. So I·have a couple of questions regarding this problem.

1. Am I correct that there is no way to use SPSTR with serout? I tried it and it·would not compile. So·unless there is a trick I am missing·this·probably just does not work with serout.

2. Is there any way to set·an offset for where the SPSTR will begin looking for the data in scratchpad ram instead of at location 0?

3.·Does anyone know of a faster method of transfering data between the stamp and the PC. Right now the slowest part is literally the speed of code execution on the stamp itself rather than the transfer rate for serial communication.

Thanks,
David

Comments

  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2006-03-03 15:54
    David,

    ·· No you cannot use SPSTR in the SEROUT.· I wonder, you said you are copying the data into an array and sending it from there.· Is this faster than reading a byte of SPRAM and sending it right out to the serial port in a loop?· I haven't tested it but thought I would throw that out there.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
  • dcoferdcofer Posts: 2
    edited 2006-03-03 16:37
    I tried doing that as well. There was very little difference, but sending the temp array was slightly faster. In the test I am sending 20,40,60, or 80 bytes of data 100 times at 115.2Kbaud. Here are the number of milliseconds it takes to recieve all the data at the pc. I listed times for using the temp array, sending it one byte at a tine, and for recieving data using SPSTR. As you can see, there is a major difference in the amount of time required to recieve the data compared to sending it. Is there an easy way to find out how many execution cycles given commands require? That would let me calculate exactly how much time should be getting eaten by the loops and setting/getting memory values. When I started this I never imagined that it would be program execution speeds that would be holding me up. I thought for sure it would be problems with getting the data transfer speeds high enough. I was worried that 115.2k would not cut it. If I could find some way to get the time down for sending to what it is for recieving data I would be happy. Do you have any ideas on how to do that? Even if it requires different hardware or a different type of microntroller? Unfortuanetly, I believe the BS2p40 is your fastest chip.

    Bytes Temp Array One Byte at a Time Receiving Data
    20 1482 1582 530
    40 2804 2824 881
    60 4105 4055 1231
    80 5377 5377 1572

    David
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2006-03-04 02:55
    Unfortunately I was away from my desk the entire day and didn't really have time to full analyze your data, but as a matter of point, the BS2p40 is not our fastest BASIC Stamp, the BS2px is, but is available as a 24-pin module only.· Now the SX Microcontroller itself is way faster and could easily do what you're trying to do.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
Sign In or Register to comment.