Servo86.setRealTimeMixing()

[Servo86]

Description

Compensates the specified value to the current position control cycle of the servo.

For some robots with sensors (such as gyroscopes or accelerometers), this function can be used to feed back the physical quantities detected by the sensors to the robot’s motion.

Syntax

servo.setRealTimeMixing(value)

Parameters

  • servo: Variable of servo type.
  • value: Position compensation value in us, which is added to the target angle calculated by the current position control cycle of the servo in real time when the servo is running.

Returns

None.

Example

#include <Servo86.h>
 
Servo myservo;
 
void setup()
{
   myservo.attach(9);
   myservo.setPosition(1500); // set the target angle: 1500us
   myservo.run(); // turn the servo
   while(myservo.isMoving() == true); // wait for the servo to reach the target angle
 
   int i = 0;
   myservo.setPosition(2000, 5000); // set target angle: 2000us, time spent: 5 seconds
   myservo.run(); // turn the servo
   while(myservo.isMoving() == true)
   {
     i = (i + 10) % 400; // simulate the change of feedback angle
     myservo.setRealTimeMixing(i);
   }
}
 
void loop() {}

See also


Libraries Reference Home

The text of the 86Duino reference is a modification of the Arduino reference and is licensed under a Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain.

Leave a Comment

Scroll to Top