Question related Servo function
I am attempting to insert the `print6Axis();` function within the servo algorithms. However, I am uncertain about where I should place the command within the servo function, as I am not familiar with the servo function responsible for moving the head or legs.
For instance, let's consider the function called `servomove`. In pseudo-code, the function might resemble the following:
servomove loop{
targethead.setPWN(70); //Example command. I assume this is how it works, right?
if printgyro == 1: // When it received 'V' from a user.
print6Axis(); // Add the function to prevent it from halt when servo moves
}
I'm trying to insert the `print6Axis();` function in the servo function so that way, it wouldn't stop servo function from printing gyro.
Do you have any idea where I can find it?
43 Views
Hi,
Thank you so much for your continued help!
I tried the second method since I find myself using the 'i' command only.
I ended up inserting it inside the calibratedPWM function, like this:
int counter = 0; for (int s = 0; s <= steps; s++) { if (counter == 30) { counter = 0; if (printGyro) { read_IMU(); print6Axis(); } } // Serial.print(counter); counter++; pwm.writeAngle(i, duty + (steps == 0 ? 0 : (1 + cos(M_PI * s / steps)) / 2 * (duty0 - duty))); }
Now I can move the servo while getting data in real-time. It won't sacrifice the speed of servo which is great! I'm working with Bluetooth data and it's extremely responsive! Seriously, I can't wait to complete it and do the show and tell!