+ Reply to Thread
Page 1 of 2 12 LastLast
Results 1 to 20 of 32

Thread: Yet anothe Arduino vs Propeller - what I am doing wrog?

  1. #1

    Default Yet anothe Arduino vs Propeller - what I am doing wrog?

    Hi all,
    I am trying to make an application which is supposed to transmit sensor data to PC via serial over USB.
    It is supposed to transmit a lot of data.
    So I am trying to compare different boards performance.
    Arduino Mega with 16 MHz clock speed transmists ~13000 reading in 10 sec.
    Propeller board with clock speed of 80MHz transmits 8700 reading in 10 sec.
    I somehow expected better speed from Propeller.
    Is this correct or am I doing something wrong?
    Here is Arduino code:
    Code:
    //random output speed test 
    
    int x;  
    
    void setup()
     {
      Serial.begin(115200);
      randomSeed(analogRead(0));
      }
    void loop()                  
    {
         x=random(300);
         Serial.print("DATA");
         Serial.println(x);     
     }
    and here is Propeller code:



    Code:
    CON
    _clkmode=xtal1+pll16x
    _xinfreq=5_000_000
    OBJ
      pst: "Parallax Serial Terminal"
    PUB main |rand
    rand:=300
    pst.Start(115200)
    repeat
      pst.str(string("DATA"))
      pst.dec(||(?rand)//300)
      pst.NewLine
        pst.LineFeed
    PS it has nothing to do with different implementation of random generation, I have the same results when transmitting just a hardcoded number.

  2. #2

    Default Re: Yet anothe Arduino vs Propeller - what I am doing wrog?

    Apples vs. Oranges,

    - The cogs actually run at 20 MIPS (as instructions (with a few exceptions) ) take four clock cycles on the prop
    - Spin compiles to an interpreted byte code, the Arduino compiles C to the native instruction set
    - using prop GCC would be a fairer comparison
    - the maximum speed for both is limited by the relatively low serial bit rate, try using 1Mbps
    www.mikronauts.com / E-mail: mikronauts _at_ gmail _dot_ com / Products and Projects:
    RoboPi: The most advanced Robot controller for the Raspberry Pi (Propeller based)
    SchoolBoard ][ Solderless Educational Development Board (Propeller, FPGA, more)
    Advanced prototyping & Parallax Propeller boards - Follow @Mikronauts on Twitter

  3. #3

    Default Re: Yet anothe Arduino vs Propeller - what I am doing wrog?

    Hi Konstantin;

    My guess is this is a bit of an unfair comparison.

    As I recall the Arduino has a dedicated serial output buffer.
    (If this is not true then "Never Mind".)
    So there is little overhead coming up with the next character to send.

    Your program uses the same cog to both send the character and find the next character.

    I would use 2 cogs, 1 for the main routine and a second to send the character.

    Duane J

  4. #4

    Default Re: Yet anothe Arduino vs Propeller - what I am doing wrog?

    I would second Bill Henning's comments, particularly that using GCC would be a fairer comparison. Spin is interpreted and the interpretive code is optimized for space, not speed. In addition, the Spin code for the serial I/O routines, particularly the conversion from decimal to characters and that for putting characters in the output buffer is not at all optimized. I'm more surprised that the Propeller did as well as it did given these limitations.

  5. #5

    Default Re: Yet anothe Arduino vs Propeller - what I am doing wrog?

    Quote Originally Posted by Konstantin View Post
    Arduino Mega with 16 MHz clock speed transmists ~13000 reading in 10 sec.
    Propeller board with clock speed of 80MHz transmits 8700 reading in 10 sec.
    You can reality check the Baud limit, along the lines of {assumes both value prints average 5 chars length}
    (115200/10)*10/(4+5) = 12800 in 10 sec
    (115200/10)*10/(4+5+2) = 10472 in 10 sec

    Notice the second case shows the impact of 2 additional chars.
    It seems the fist code is not sending the NewLine.LineFeed, as the time is close to a continual 9 bytes.
    - so it seems close to half of the skew, looks to be message variation ?

    If you want to minimise the SW overhead, use larger packets.
    It also looks like the 2nd case is being pulled down by SW speed, whilst the first one is at Baud Ceiling, and so could run even faster at higher baud rates.

    Also note the AVR has a Hardware uart, so whilst a Byte is being sent, the core can be doing other tasks, but a Prop has no Hardware uart, so a single cog design has to bit-bang THEN get the next byte.

    That means a Prop will benefit from the highest possible BAUD speed, as that saves bit-bang time.

    Your 8700 can be modeled as two delays, a Char-send, plus a SW overhead,
    1/((1/26303)+(1/13000)) = 8700.0737
    ie if you can shrink that comms time to zero, by fastest-possible-baud, (or using a second COG), then the SW overhead can approach 26303 readings sent.

    Look at FT232H devices, which can run up to 12MBaud, and it looks like 4MBaud is the highest legal 80MHz fraction.
    Last edited by jmg; 11-16-2012 at 10:58 AM.

  6. #6

    Default Re: Yet anothe Arduino vs Propeller - what I am doing wrog?

    You can do a lot better on the Propeller, not sure you can do better on the Arduino. It is all about how fast your serial i/o is going.
    Hwang Xian Sheng
    Kaohsiung/Gaoxiung
    Taiwan/Formosa
    R.O.C/Province of China, P.R.C.

    "My comments are independent... and at times just plain wrong. At other times, they just might be helpful. So consider the source."

  7. #7
    prof_braino's Avatar
    Location
    Between the pit of man's fears and the summit of his knowledge
    Posts
    4,036

    Default Re: Yet anothe Arduino vs Propeller - what I am doing wrog?

    As they said above. If you wanted to compare something to spin on the prop you would be closer using some type of basic on the arduino. Basic would most likely be interpreted and a more equal comparision to the spin.

  8. #8

    Default Re: Yet anothe Arduino vs Propeller - what I am doing wrog?

    If you used cog memory model with GCC I bet the Propeller would mop up the floor with the Arduino.

  9. #9
    prof_braino's Avatar
    Location
    Between the pit of man's fears and the summit of his knowledge
    Posts
    4,036

    Default Re: Yet anothe Arduino vs Propeller - what I am doing wrog?

    Quote Originally Posted by Martin_H View Post
    If you used cog memory model with GCC I bet the Propeller would mop up the floor with the Arduino.
    if all we are concerned with is being fast, try 5achyon forth. Peter reports 3 mbps over bluetooth. can't beat that with a stick.

  10. #10

    Default Re: Yet anothe Arduino vs Propeller - what I am doing wrog?

    Quote Originally Posted by Martin_H View Post
    If you used cog memory model with GCC I bet the Propeller would mop up the floor with the Arduino.
    As I suspected.... Is this comparison done?
    Hwang Xian Sheng
    Kaohsiung/Gaoxiung
    Taiwan/Formosa
    R.O.C/Province of China, P.R.C.

    "My comments are independent... and at times just plain wrong. At other times, they just might be helpful. So consider the source."

  11. #11

    Default Re: Yet anothe Arduino vs Propeller - what I am doing wrog?

    Quote Originally Posted by Loopy Byteloose View Post
    As I suspected.... Is this comparison done?
    yep, I tried the same with GCC and it performed almost as good as Arduino, 11500 readings vs 13000.
    But I will need to use I2C to get real data. As I understand it there are ready to use libraries in Spin language, but how do I handle it in GCC?
    Do I need to write all I2C protocol engine from scratch? (no way )
    I was totally unaware there is no hardware UART implementation on Propeller...well, if it has to implement RS232 protocol programmatically then it explains everything. Thank you for replies!

  12. #12

    Default Re: Yet anothe Arduino vs Propeller - what I am doing wrog?

    There is no hardware UART on the Propeller. On the other hand, the Propeller Serial Terminal I/O driver contains an assembly language program that's launched in another cog and operates completely in parallel with your program (and the Spin subroutines in the I/O driver) doing the "bit-banged" serial I/O. In terms of performance, it's equivalent to a hardware UART and has a 64 byte buffer.

    There is an I2C library driver included with GCC. I don't know what devices it supports other than memory (EEPROMs). You'll have to look at it. Most likely it has the necessary low-level functions to support nearly any I2C device, but you'll have to write the high level operations. For best performance, you may want to have the I2C I/O routines run in their own cog in parallel with your main program and communicate through a buffer of some sort. It all depends on what kind of I2C device and data you're talking about.

  13. #13

    Default Re: Yet anothe Arduino vs Propeller - what I am doing wrog?

    Konstantin,

    Welcome to the forum by the way.

    ...if it has to implement RS232 protocol programmaticaly then it explains everything.
    Not exactly. A cog based serial object, ie written in PASM, like PST or FullDuplexSerial can drive the serial line at 115200 baud just as well as a hardware UART. I have even written a software UART in C that runs in COG and can do 115200 using propgcc.

    In your case you are using pst.str, pst.dec etc methods in Spin and I suspect that is where all the slow down is.

    Moving to GCC has a substantial speed benefit over Spin as you see.

    It's a design choice that here is no hardware UART I2C and other blocks in silicon on the Propeller, all such things are to be "soft". This makes for maximum flexibility of the device even at the expense of a little speed here and there.

  14. #14

    Default Re: Yet anothe Arduino vs Propeller - what I am doing wrog?

    Quote Originally Posted by Loopy Byteloose View Post
    As I suspected.... Is this comparison done?
    Loopy, I'm no where near a Propeller chip, but the code below compiles, so it might do the trick.
    Code:
    /**
     * @file SpeedTest.c
     * This is the main SpeedTest program start point.
     */
    #include <stdio.h>
    #include <propeller.h>
    
    // snippet from C stdlib
    static unsigned int next = 1;
    
    int rand(void)
    {
        next = next * 1103515245 + 12345;
        // return (unsigned int)(next / 65536) % 32768;
        return (unsigned int)(next>>16) & 32768;
    }
    
    void srand(unsigned int seed)
    {
        // And you *should* get a warning if sizes dont match.
        next = seed;
    }
    
    /**
     * Main program function.
     */
    int main(void)
    {
        // Initialize seed with the time. Note: time isn't a good seed, reading an input is better.
        srand(CNT);
    
        while(1)
        {
            printf("DATA%d\n", rand());
        }
        return 0;
    }

  15. #15

    Default Re: Yet anothe Arduino vs Propeller - what I am doing wrog?

    Actually, I did it with the 'Step one' tutorial for GCC:
    Code:
    #include <stdio.h>
    #include <propeller.h>
    
    int main(void)
    {
        while(1) {
            printf("DATA%d\n", 100);
        }
        return 0;
    }
    at 115200 this code produced, as I said, 11500 reading in 10 secs
    Memory model COG, optimization O2
    Arduino code (see first message) produced 13000.
    Arduino code does include CRLF (this is what println is for).

  16. #16

    Default Re: Yet anothe Arduino vs Propeller - what I am doing wrog?

    A prop has 8 cogs, you are using one for a serial driver, one for the code... and you still have 6 cogs left

    Quote Originally Posted by Konstantin View Post
    Actually, I did it with the 'Step one' tutorial for GCC:
    Code:
    #include <stdio.h>
    #include <propeller.h>
    
    int main(void)
    {
        while(1) {
            printf("DATA%d\n", 100);
        }
        return 0;
    }
    at 115200 this code produced, as I said, 11500 reading in 10 secs
    Memory model COG, optimization O2
    Arduino code (see first message) produced 13000.
    Arduino code does include CRLF (this is what println is for).
    www.mikronauts.com / E-mail: mikronauts _at_ gmail _dot_ com / Products and Projects:
    RoboPi: The most advanced Robot controller for the Raspberry Pi (Propeller based)
    SchoolBoard ][ Solderless Educational Development Board (Propeller, FPGA, more)
    Advanced prototyping & Parallax Propeller boards - Follow @Mikronauts on Twitter

  17. #17

    Default Re: Yet anothe Arduino vs Propeller - what I am doing wrog?

    Quote Originally Posted by Bill Henning View Post
    A prop has 8 cogs, you are using one for a serial driver, one for the code... and you still have 6 cogs left
    More to this, my board has plenty of buttons, switches, LEDs, VGA &PS2 ports... and I have all of them wasted for nothing. I am really sorry for offering to such a mighty contraption so primitive task.

  18. #18

    Default Re: Yet anothe Arduino vs Propeller - what I am doing wrog?

    Quote Originally Posted by prof_braino View Post
    if all we are concerned with is being fast, try 5achyon forth. Peter reports 3 mbps over bluetooth. can't beat that with a stick.
    Maybe you guys can port that to Arduino so that those folks can have a fair comparison and fall in love with the easiness and greatness forth ... if anyone needs to be forth-proselytized it's those Arduino folks.

  19. #19

    Default Re: Yet anothe Arduino vs Propeller - what I am doing wrog?

    Quote Originally Posted by Bill Henning View Post
    A prop has 8 cogs, you are using one for a serial driver, one for the code... and you still have 6 cogs left
    Actually in the COG case quoted it is one and only one COG doing all the work.

  20. #20

    Default Re: Yet anothe Arduino vs Propeller - what I am doing wrog?

    He is using the "Parallax Serial Terminal" object, which cognew's the low-level serial code... so it appears to use two cogs.

    Mind you, he could change to the quad serial driver, and handle four serial ports... Arduino would not fare as well.

    Quote Originally Posted by jazzed View Post
    Actually in the COG case quoted it is one and only one COG doing all the work.
    www.mikronauts.com / E-mail: mikronauts _at_ gmail _dot_ com / Products and Projects:
    RoboPi: The most advanced Robot controller for the Raspberry Pi (Propeller based)
    SchoolBoard ][ Solderless Educational Development Board (Propeller, FPGA, more)
    Advanced prototyping & Parallax Propeller boards - Follow @Mikronauts on Twitter

+ Reply to Thread

Similar Threads

  1. Arduino vs Propeller
    By USMCinfinity in forum Propeller 1 Multicore Microcontroller
    Replies: 267
    Last Post: 09-09-2013, 06:00 AM
  2. Propeller or Arduino ?
    By KidE in forum General Discussion
    Replies: 40
    Last Post: 11-02-2012, 08:32 AM
  3. When the Propeller met the Arduino
    By blittled in forum Propeller 1 Multicore Microcontroller
    Replies: 41
    Last Post: 06-08-2012, 06:13 PM
  4. Arduino Vs. Propeller Round 100
    By Nick McClick in forum General Discussion
    Replies: 24
    Last Post: 05-30-2012, 09:15 AM
  5. occam-PI for Arduino (and Propeller?)
    By Leon in forum General Discussion
    Replies: 2
    Last Post: 08-25-2010, 01:16 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts