Go Down

Topic: Serial.print() Cutting Off Phrases (Read 511 times) previous topic - next topic

ZacharyBruno

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: [Select]

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();
  }
}
RadarProject - Arduino Autopilot for RC http://radarproject.wordpress.com/

PeterH

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?
I only provide help via the forum - please do not contact me for private consultancy.

MarkT

Does the problem still show up if you reduce the baud rate from 115200 to 57600?
[ I won't respond to messages, use the forum please ]

Go Up