28044 laser range finder
This assembly works very well but I am sweeping a servo to look for obstacles. The servo sweep code works smooth without the laser called but when the laser is called there is a jerk about 500ms after each angle call.
If I do not sweep but just call the laser routine everything is stable but the jerk still comes about 500ms after the laser flash. The laser code I am using:
void LaserScan()
{
char lrfData[LRFBUFSIZE];
char offset = 0;
lrfSerial.print('R');
delay(2000);
if(lrfSerial.available() > 0)
{while(1)
{
if (lrfSerial.available() > 0) // If there are any bytes available to read, then the LRF must have responded
{
lrfData[offset] = lrfSerial.read(); // Get the byte and store it in our buffer
if (lrfData[offset] == ':') // If a ":" character is received, all data has been sent and the LRF is ready to accept the next command
{
lrfData[offset] = 0; // Null terminate the string of bytes we just received
break; // Break out of the loop
}
offset++; // Increment offset into array
if (offset >= LRFBUFSIZE) offset = 0; // If the incoming data string is longer than our buffer, wrap around to avoid going out-of-bounds
}
}
}
Serial.println(lrfData);
lrfSerial.flush();
Serial.flush();
}
Pretty sure there is nothing in the code causing the servo to jerk?
If I do not sweep but just call the laser routine everything is stable but the jerk still comes about 500ms after the laser flash. The laser code I am using:
void LaserScan()
{
char lrfData[LRFBUFSIZE];
char offset = 0;
lrfSerial.print('R');
delay(2000);
if(lrfSerial.available() > 0)
{while(1)
{
if (lrfSerial.available() > 0) // If there are any bytes available to read, then the LRF must have responded
{
lrfData[offset] = lrfSerial.read(); // Get the byte and store it in our buffer
if (lrfData[offset] == ':') // If a ":" character is received, all data has been sent and the LRF is ready to accept the next command
{
lrfData[offset] = 0; // Null terminate the string of bytes we just received
break; // Break out of the loop
}
offset++; // Increment offset into array
if (offset >= LRFBUFSIZE) offset = 0; // If the incoming data string is longer than our buffer, wrap around to avoid going out-of-bounds
}
}
}
Serial.println(lrfData);
lrfSerial.flush();
Serial.flush();
}
Pretty sure there is nothing in the code causing the servo to jerk?
Comments
It doesn't look like you include your complete code, (servo control).
You do not say what platform you are working on.
If you are using a Propeller chip, I would run the servo sweep in a separate Cog.