Slow Arduino Serial Port

Discussion in 'General Programming Discussion' started by Matthew Grivich, Apr 12, 2016.

  1. Matthew Grivich

    Matthew Grivich New Member

    Joined:
    Apr 12, 2016
    Messages:
    2
    Likes Received:
    0
    I am attempting to push data over the serial port as fast as possible. Currently, I am limited to about 10,000 bytes/second, which is plausible because the serial port is configured to 14,400 bytes (115,200 bits) per second. Does anyone know how I can increase the speed of the serial connection? Alternatively, if there is some other means besides Serial to pass data to the ARM processor, I could use that. My Arduino sketch is below. As it is, the "Unable to write quickly enough" is printed. If two characters are removed from Serial.println("012345678901"), then it passes. I am using the built in Serial port monitor (Tools -> Serial Monitor).

    Code:
    unsigned long sample_period = 1000; //micro seconds.
    unsigned long current_time = 0;
    
    void setup() {
      Serial.begin(115200); //115200 bits per sec, 14400 bytes per sec
      current_time = micros();
    }
    
    void loop() {
      int wait_count = 0;
     
      while(micros() - current_time < sample_period) {
        wait_count++;
      }
      if(wait_count == 0) {  
        Serial.println("Unable to write quickly enough");
      }
      current_time = micros();
      Serial.println("012345678901");
    
    }
    
     
    Last edited by a moderator: Apr 20, 2016
  2. waltervl

    waltervl UDOOer

    Joined:
    Dec 12, 2015
    Messages:
    2,162
    Likes Received:
    551
    Did you try to send more data in 1 line? Also the reading side effects the baudrate. You could also use minicom instead of Arduino IDE. Or write your own serial reading program.
     
  3. Matthew Grivich

    Matthew Grivich New Member

    Joined:
    Apr 12, 2016
    Messages:
    2
    Likes Received:
    0
  4. waltervl

    waltervl UDOOer

    Joined:
    Dec 12, 2015
    Messages:
    2,162
    Likes Received:
    551
    Do you see differences between minicom, Arduino serial monitor and your own program?
     

Share This Page