Servos start twitching/jittering as soon as said sketch is uploaded

I was thinking the same as only thing changing is using iBUS with FlySky transmitter to control servo as oppose to Arduino controlling servo directly via code with FlySky.

I wonder if it's because the values returned by VRA and VRB are fluctuating enough to cause movement in the servos. Try adding a dampener so you only update servos when the dial has moved x amount since the last move. Alternatively you could do this on the TX (I also use FS-i6x with custom FW for 16 channels of telem)

1 Like

Thank you for the suggestion mate. yes, I did the serial monitor debugging with FlySky transmitter relaying all values correctly from channels 1 - 6 (joysticks and VRA/VRB knobs). For someone new to Arduino world, DroneBot Workshop YouTube videos were most helpful, I did watch this one.

Thank you for suggestion. I tired "ibus.begin(Serial1, IBUSBM_NOTIMER);" but servo locked up became unresponsive, wouldn't receive input from Flysky.

You just gave me an idea, switch FlySky transmitter input from the VRA knob to joystick and see what happens...cheers mate!

hey mate, I tried using joystick channel 4 instead of VRA/VRAB it moves as per input from FlySky horizontal left to right joystick channel 4. But still servo jittered once sketch uploaded like it's receiving some type of pulse...

Thank you again for your feedback, appreciate you.

You do that, so woyncha print out the values you are using to move the servos to see if you are getting the data you think?

a7

1 Like

UPDATE: first of all, I would like to thank all for taking the time to help a newbie. I will most certainly pass along your kindness to the next bloke.

So "jremington+kmin+jim-p" mentioned the perhaps the lack of power from Arduino MEGA/Keyestudio board. This morning I decided not using ibus connection, instead wired servo and 6v battery directly into receiver - no board. As per fotos.

Turnt on FlySky transmitter and servo did not twitch. Moving smoothly via joystick channel 3 and also via channel 5 VRA.

Will purchase a Servo Motor Driver Board to power the servos separately. Hopefully then ibus connection will have enough power, will keep you posted. (I thought barrel 12v on board would supply the necessary power to servos but I think it's for micro servos and not 35kg. - my bad, cost me 2-months of brain storming as I wanted to figure it out on me own.)

Again, Thank you all, appreciate you!


1 Like

UPDATE & SOLUTION:

First of all, I would sincerely like to thank all of you for help! After reading all comments and suggestions, i ordered some parts and got to process of elimination. The parts included 2S Lipo 7.4v battery, 3300uf 16v capacitors and ferrite rings. I thought for sure one of these 3 options would solve issue, unfortunately it didn't. Though it did eliminate every possible issue on the hardware end of things, all roads leading to an issue with sketch. After reviewing every possible sketche online dealing with FlySky ibus, I noticed some code I hadn’t used. The one line of code I amended from "ibus.begin(Serial1)" to "ibus.begin(Serial1, IBUSBM_NOTIMER);" and the one line of code I added: "ibus.loop();" solved the issue. I uploaded sketch, the servo did NOT jittery/twitch/hiccups, perfectly still waiting for input from FlySky transmitter.

Always proper give credit to the peeps, STEVE9 who first mentioned code in earlier post but I didn't figure out, then last night after much researching I found 2 lines of code here

Again, thank you all for your most valued commodity, your time, appreciate you! And I would also like to thank the origin originator ARDUINO for their top quality products and of course for this most valuable forum.

/*
  Arduino FS-I6X Demo fsi6x-arduino-mega-ibus.ino
  Read iBus output port from FS-IA6B receiver module
  Display values for Channel 5 and Channel 6 (servos attached) on Serial Monitor

  Channel functions by Ricardo Paiva https://gist.github.com/werneckpaiva/

  DroneBot Workshop 2021 https://dronebotworkshop.com

  Amended Jan 28 2025 by SHAKE solves servo jitter/twitch/hiccups issue on Arduino MEGA
  include these two lines of code:
  ibus.begin(Serial1, IBUSBM_NOTIMER);
  ibus.loop();

*/

//Inlcude Libraries

#include <AFMotor.h>              // Adafruit Motor Library
#include <Servo.h>                // Include Servo Library
#include <IBusBM.h>               // Include iBusBM Library

IBusBM ibus;                      // Create iBus Object
Servo servo;                      // Horizontal Servo servoHor
   
int servoPin = 2;
int posServo = 0;
int CH5;

// Read the number of a given channel and convert to the range provided.
// If the channel is off, return the default value

int readChannel(byte channelInput, int minLimit, int maxLimit, int defaultValue) {
    uint16_t ch = ibus.readChannel(channelInput);
    if (ch < 100) return defaultValue;
    return map(ch, 1000, 2000, minLimit, maxLimit);
}

void setup() {

        Serial.begin(115200);                        // Start serial monitor for debugging
        ibus.begin(Serial1, IBUSBM_NOTIMER);         // Attach iBus object to serial port

        servo.attach(servoPin);                      // attach servoVer to servorVerPin 10 aka servo_1 (FlySky channel 6)
        servo.write(posServo);                       // start the servo at position 0 middle Horizontal
     
}

void loop() {
        
        ibus.loop();
        CH5 = readChannel(4, -100, 100, 0);					// Channel 5 on FlySky
        posServo = map(CH5, 0, 110, 0, 180);	      // scale it for use w the servo (value between 0 - 120) changed from map(ch5,0,1023,0,120)
        servo.write(posServo);                      // sets the servo position according to the scaled value
        delay(10);

}

1 Like

hey mate, just wanted to thank you! you were spot on with solution, I needed to add BOTH lines of code and I just added the one line: "ibus.begin(Serial1, IBUSBM_NOTIMER);" so the sketch still gave servos jitter/twitch/hiccups.