Hello Fellow Yuneec Pilot!
Join our free Yuneec community and remove this annoying banner!
Sign up

Reverse engineering CGO3+ UART

Such kind of spikes only speak of a sloppy approach to writing the code.

I'm afraid, these pictures was taken not from original H480, so Yuneec is not a guilty party in this case.
 
The landing gear servo signal from Thunderbird FW looks similar to camera PWM from Typhoon H above:
50Hz Starts with a fix pulse 4.5ms + gap 500µs = 5ms Start sequence followed by a PWM pulse 3400µs for gear down. I guess it will be around 683 for gear up (not seen because to read this it must flying).
View attachment 31140
My first test of using PWM to retract the landing gear did not work. So, are you saying that the landing gear module needs to initialized before it can be controlled via PWM?
 
So, are you saying that the landing gear module needs to initialized before it can be controlled via PWM?
I do only share what I have seen on my test system. What the intention behind this is I can only speculate. And I speculate that there no initialization needed. It looks like the gear servo can read both, 250Hz pure PWM and (at Thunderbird FW) 50Hz PWM with this leading clock pulse.
 
So, 3 pwm pulses to move the landing gear in either direction? For the TH firmware with drone inverted it will retract the gear. It doesn't have to be in-flight to work. I probably need to figure out the correct functions to use for my purposes. In the Thunderbird firmware landing gear code I saw two settings, one was a 1000 and the other 2000 (microseconds). I had patterned my code based on that.
 
I'm not so good to explain in english. What i mean that there are two pulses in each cycle: a start pulse (or clock pulse), 4500µs fix length and a second pulse with variable length PWM puse itself. To distinguished both pulse from each other there is a 500µs gap between those. All this repeats forever every 20ms.
I think the picture makes it clear, better that I could...
 
  • Like
Reactions: 1midniterider
I was going for a more robust pwm function but, opted for a hard-coded method in a loop... I came up with two scenarios, one @50Hz and another @250Hz, based on your oscope readings...
 
I'm not so good to explain in english. What i mean that there are two pulses in each cycle: a start pulse (or clock pulse), 4500µs fix length and a second pulse with variable length PWM puse itself. To distinguished both pulse from each other there is a 500µs gap between those. All this repeats forever every 20ms.
I think the picture makes it clear, better that I could...
Here is a hard-coded Arduino file based on this. You will need to remove the txt extension to run in Arduino IDE.
 

Attachments

Uh oh... Just for fun I had ChatGPT create pwm code for the landing gear. We are in trouble.

Code:
#include <Servo.h>

// Pin Definitions
const int servoPin = 18;        // PWM output to the landing gear servo
const int pwmInputPin = 34;     // PWM signal input from the flight controller

Servo landingGearServo;         // Servo object for controlling landing gear

// PWM Input Configuration
int pwmInputValue = 0;          // Value read from the flight controller's PWM signal
int pwmThreshold = 1500;        // Threshold value for deploying/retracting gear

// Servo positions (adjust as per your landing gear's requirement)
int deployPosition = 180;       // Servo position for deployed gear (in degrees)
int retractPosition = 0;        // Servo position for retracted gear (in degrees)

void setup() {
  // Initialize Serial Monitor (optional, for debugging)
  Serial.begin(115200);

  // Attach the servo to the corresponding GPIO pin
  landingGearServo.attach(servoPin);

  // Initialize the servo to the retracted position
  landingGearServo.write(retractPosition);

  // Set the PWM input pin as an input
  pinMode(pwmInputPin, INPUT);
}

void loop() {
  // Read PWM input from the flight controller (analogRead or digitalRead)
  // For better accuracy, use pulseIn to measure the PWM pulse width
  pwmInputValue = pulseIn(pwmInputPin, HIGH, 25000);  // Measure pulse width (up to 25ms)

  // Debugging info (optional)
  Serial.print("PWM Input: ");
  Serial.println(pwmInputValue);

  // Check if PWM value is above the threshold to deploy landing gear
  if (pwmInputValue > pwmThreshold) {
    deployLandingGear();
  }
  else if (pwmInputValue < pwmThreshold) {
    retractLandingGear();
  }

  // Small delay for stabilization
  delay(20);
}

void deployLandingGear() {
  // Move the servo to the deploy position
  Serial.println("Deploying landing gear...");
  landingGearServo.write(deployPosition);
}

void retractLandingGear() {
  // Move the servo to the retract position
  Serial.println("Retracting landing gear...");
  landingGearServo.write(retractPosition);
}
 
I would do it with AnalogWrite(pin, value) as described here:
You can set the resolution and frequency of the PWM signal (to 250Hz) on a selected pin by using the analogWriteResolution and analogWriteFrequency functions.
 
Last edited:

New Posts

Members online

No members online now.

Forum statistics

Threads
21,141
Messages
243,757
Members
27,796
Latest member
bxt3r