Shop OBEX P1 Docs P2 Docs Learn Events
Serial port comm speed? — Parallax Forums

Serial port comm speed?

RicardoPRicardoP Posts: 13
edited 2007-09-27 21:58 in Propeller 1
Another begginer question from me blush.gif

So I setup a little C# app on my PC that talks to the a properller. But if I don't put pauses in between the bytes being sent (about 20ms) I seem to "lose" some of them. Why is this? I'm using the FullDuplexObject which seems to run on its own cog so it should be going fast. Is there any way around this? I need to send this data very fast. If it makes any difference, this is a 1-way communication in that the PC sends data to the propeller but never the other way around. (altho doing some tests just for fun revealed the same problem, the PC was not getting all packets unless I put delays)

I'm having a ton of fun with the propeller btw!

Thanks.

Comments

  • CJCJ Posts: 470
    edited 2007-09-26 20:59
    my guess would be that the buffers are not being read fast enough

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Parallax Forums - If you're ready to learn, we're ready to help.
  • deSilvadeSilva Posts: 2,967
    edited 2007-09-26 21:40
    Ditto.
    But 20ms is a lot... When you use SPIN to process the bytes you seem to have more than 2.000 SPIN instructions for each byte
  • RicardoPRicardoP Posts: 13
    edited 2007-09-27 01:30
    The setup is so simple that it hardly would seem possible to be user error but I can't think of anything else to try. I'm using 115200 by the way, setting this to a higher value didn't seem to produce any difference.
  • Mike GreenMike Green Posts: 23,101
    edited 2007-09-27 01:48
    FullDuplexSerial can easily handle anything up to 230KBaud. It only has a 16 byte buffer though. That will fill up in less than 1ms. It's easy to increase the buffer size to any power of 2.
  • scottascotta Posts: 168
    edited 2007-09-27 02:11
    If you add a larger read/write buffer to FullDuplexSerial, it
    can handle over 1Mbps, in one direction.

    If you start reading and writing at that speed, the ping-pong
    multitasking starts dropping bits.
  • RicardoPRicardoP Posts: 13
    edited 2007-09-27 17:50
    This helped a lot, thanks guys. I increased the size of the buffer and things started to work much better, while getting familiar with the code I realized that I don't really care to process all information that I receive, I really only want the latest 5 bytes, so I changed the code so that it will write directly into the buffers a separate cog samples for input and now I'm getting near instant response which I what I need! I guess the downside to this is that, in my understanding read/write to main ram is very slow and if I put the whole program in the same cog (so I could use cog ram) things might run too slow and I will start to lose packets, just a guess I haven't tested. Both cogs are running pretty tight loops one reading the serial port the other uses that data to do some minor processing. I'm thinking of trying increasing the baud rate even further, running at 230k now.
  • Mike GreenMike Green Posts: 23,101
    edited 2007-09-27 18:04
    Reading and writing to main ram is certainly slower than reading and writing to cog ram, but not as much as you might think. There are no index registers in the Propeller, so array access has to be done through instruction modification. In addition, cog memory is organized into 32 bit words with no byte access. If you're storing bytes, you have to use additional instructions to pack and unpack the 32 bit words. You can do reads and writes about every 3 instructions (every 800ns with an 80MHz system clock). Typically, you can do bursts of a few bytes or words that way, then the bookkeeping for the loop will cause you to miss the next hub synchronization point. You should be able to transfer hub to cog or cog to hub at 4 Megabytes/second using long words or 1 Megabyte/second using bytes.
  • RicardoPRicardoP Posts: 13
    edited 2007-09-27 21:58
    I see, thank you. It doesn't sound like I can get any more speed out of what I'm already doing other than simply increase the baud rate further. I could also try to compress the 5 bytes down at the expense of accuracy.
Sign In or Register to comment.