Pages: [1]   Go Down
Author Topic: Serial.print() Cutting Off Phrases  (Read 408 times)
0 Members and 1 Guest are viewing this topic.
Scottsdale
Offline Offline
Newbie
*
Karma: 0
Posts: 27
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello,

I'm using Serial.print() to debug my program (see where it runs and where it does not). Currently the program is supposed to print out the following:

"Starting...."
then
"IMU Started"
then
"MLB"
then
"Roll Loop Done"

However, in the Serial Consol, I'm getting these phrases cut off at random sections like this:

"Starting....IMU StartedMLBRollLo"

Why is this?

Thanks,
Zachary

It's not the while loop timer issue. I tried while(1) and it did the same thing. One thing to note is that "MLB" is always complete. I'll upload the files I'm working with. It isn't the complete package, so it won't compile, but it should be all that is necessary.

Code:
void Plane::Move(int roll, int pitch, int yaw, String velocity, int time) /// time in miliseconds
{
  desiredRoll = roll;
  desiredPitch = pitch;
  desiredYaw = yaw;
  desiredVelocity = velocity;
  unsigned long startTimer = micros();
  unsigned long endTimer   = micros();
  while ((endTimer - startTimer) < (time*1000)) {
    Serial.println("MLB");
    delay(15);
    rollPlane(roll);
    Serial.println("Roll Loop Done");
    delay(15);
    pitchPlane(pitch);
    Serial.println("Pitch Loop Done");
    yawPlane(yaw);
    Serial.println("Yaw Loop Done");
    velocityPlane(velocity);
    Serial.println("Velocity Loop Done");
    /// May need a function to check if there is a lost connection/regained conection to the IMU via Serial
    endTimer = micros();
  }
}

* plane_v5.ino (0.65 KB - downloaded 4 times.)
* AutoCorrect.cpp (7.44 KB - downloaded 5 times.)
* MiniTasks.cpp (10.72 KB - downloaded 5 times.)
* Plane.h (3.02 KB - downloaded 4 times.)
Logged

RadarProject - Arduino Autopilot for RC http://radarproject.wordpress.com/

UK
Offline Offline
Shannon Member
****
Karma: 223
Posts: 12630
-
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

You are printing stuff out in a loop that looks as if it would run very quickly - you are probably producing output faster than the serial port can transfer it. Is it really useful to print stuff out that frequently?
Logged

I only provide help via the forum - please do not contact me for private consultancy.

0
Offline Offline
Shannon Member
****
Karma: 207
Posts: 12205
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Does the problem still show up if you reduce the baud rate from 115200 to 57600?
Logged

[ I won't respond to messages, use the forum please ]

Pages: [1]   Go Up
Jump to: