Show Posts
Pages: [1]
1  Development / Other Software Development / Re: Arduino 1.0 -> Serial.print NOT asynchronous? on: January 05, 2012, 02:03:01 pm
@Coding Badly:
thx for taking the time to do some tests. But you have a complete other sketch. Please try to use my sketch on a 8mhz board like I did. For most beginners, my sketch is more easy to understend. Your sketch does in fact the same but your code is more difficult for most beginners. So if you conclude that your timings are good with your code, then why are my timings bad with my code?

@fat16lib:
Also thx for taking your time to check out my problem. I'll check out your topic and test your code asap.



INFO: I use a atmega328 board running on 8mhz and downloaded the last arduino 1.0 version.
EXTRA: I took the time to compile some other sketches with arduino 1.0 and they are all slower compared to the same sketch compiled with arduino 0022. I do use micros() to compare timings en also use a simple loopcounter. I think I'll stay with arduino 0022 for a while.
2  Development / Other Software Development / Re: Arduino 1.0 -> Serial.print NOT asynchronous? on: January 02, 2012, 06:53:23 am
whow again I did find a strange behaviour with this new serial.print().

Take the sketch in prevouis post change baudrate to 19200 and you get this output in arduino 1.0
Code:
lkjljlkjlkjljlkjlkjlkjlkjlkjlkjlkj
1832
lkjljlkjlkjljlkjlkjlkjlkjlkjlkjlkj
1832
lkjljlkjlkjljlkjlkjlkjlkjlkjlkjlkj
1824
lkjljlkjlkjljlkjlkjlkjlkjlkjlkjlkj
1832
lkjljlkjlkjljlkjlkjlkjlkjlkjlkjlkj
1832
lkjljlkjlkjljlkjlkjlkjlkjlkjlkjlkj
1808
lkjljlkjlkjljlkjlkjlkjlkjlkjlkjlkj
1824
lkjljlkjlkjljlkjlkjlkjlkjlkjlkjlkj
1824
lkjljlkjlkjljlkjlkjlkjlkjlkjlkjlkj
1832


So the time spend for serial.print() for sending the same string is less when decreasing baudrate. Increase the baudrate and the time spend by serial.print() will be larger. :s  Can some explain this? smiley


Moderator edit: [code] [/code] tags added.
3  Development / Other Software Development / Re: Arduino 1.0 -> Serial.print NOT asynchronous? on: January 02, 2012, 05:17:55 am
Ok here it goes

its an atmega328 8mhz board.

changed code to

Code:
unsigned long timebegin;
unsigned long timeend;
void setup()
{
  Serial.begin(57600);
  
}
void loop()
{
  timebegin = micros();  
  Serial.print("lkjljlkjlkjljlkjlkjlkjlkjlkjlkjlkj");  
  timeend = micros();
  Serial.println();
  Serial.println(timeend-timebegin);
  delay(100);
}

output in arduino serial monitor for 0022
Code:
lkjljlkjlkjljlkjlkjlkjlkjlkjlkjlkj
5472
lkjljlkjlkjljlkjlkjlkjlkjlkjlkjlkj
5464
lkjljlkjlkjljlkjlkjlkjlkjlkjlkjlkj
5472
lkjljlkjlkjljlkjlkjlkjlkjlkjlkjlkj
5472
lkjljlkjlkjljlkjlkjlkjlkjlkjlkjlkj
5472
lkjljlkjlkjljlkjlkjlkjlkjlkjlkjlkj
5472
lkjljlkjlkjljlkjlkjlkjlkjlkjlkjlkj
5472
lkjljlkjlkjljlkjlkjlkjlkjlkjlkjlkj
...


output in arduino serial monitor for 1.0
Code:
lkjljlkjlkjljlkjlkjlkjlkjlkjlkjlkj
2208
lkjljlkjlkjljlkjlkjlkjlkjlkjlkjlkj
2208
lkjljlkjlkjljlkjlkjlkjlkjlkjlkjlkj
2208
lkjljlkjlkjljlkjlkjlkjlkjlkjlkjlkj
2208
lkjljlkjlkjljlkjlkjlkjlkjlkjlkjlkj
2208
lkjljlkjlkjljlkjlkjlkjlkjlkjlkjlkj
2208
lkjljlkjlkjljlkjlkjlkjlkjlkjlkjlkj
....

Ok, now I see some difference. But still 2ms is a long time for just filling a streambuffer  that will be send assync.

The fact is that I have another lager sketch with serial.print in it and a (fps) loopcounter. Logically I should, with the 1.0 version compared to the 0022 version now get more FPS/Counts in this sketch. But I don't :s


Moderator edit: [code] [/code] tags added.
4  Development / Other Software Development / Arduino 1.0 -> Serial.print NOT asynchronous? on: January 02, 2012, 03:52:33 am
Hi,

first of al, english is not my first nor my second language so I'll try to do my best.

In the past  few months I worked with the arduino 0022 software. Yesterday I finaly downloaded the new Arduino 1.0 software, where I found some interesting new feature in the serial.print function:

arduino reference page: "As of version 1.0, serial transmission is asynchronous; Serial.print() will return before any characters are transmitted."


So I made a little sketch to test this.


Code:
void loop() //Main Loop
{
  timebegin = millis();   //take the time before sending data
  Serial.print("lkjljlkjlkjljlkjlkjlkjlkjlkjlkjlkj");   // some random text, not important
  timeend = millis(); //take the time afte sending data
  Serial.println();
  Serial.print(timeend);
  Serial.print(",");
  Serial.println(timeend);
  delay(100); //wait some time before doing this loop again.
}


If I do timeend - timebegin. I get a value of 5ms. So the serial.print function took 5ms before returning. I compiled this sketch with arduino 0022 and arduino 1.0. There is no difference in time so where is the asynchronous ???

So if in arduino 1.0 the Serial.print() really would return before any characters are transmitted, why does It take 5ms to return and why is there no difference in time with the arduino 0022 version?


Moderator edit: [code] [/code] tags added.
Pages: [1]