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

Coding a gimbal

Joined
Mar 4, 2019
Messages
400
Reaction score
210
Age
55
I am working on something that might help us all with our broken cgo3 and even the cgo2. I am trying to get around Yuneec's need for calibration of the boards. Here is some code I am working on for a controller. I do this in my spare time, so updates will follow as I have time for them.




/ *

* Program for controlling and superimposing a signal line
* for a CGO2 camera.
* © Dieter Bruse 2015
* /
#include <avr / io.h>
#include <avr / interrupt.h>
#define F_CPU 1000000UL // 1.0 MHz (for delay.h)

bool signal_online = false;
byte PIN_PWM = 1;
byte PIN_SWSE = 3; // Switch signal receiver
byte PIN_SWSP = 4; // Processor switch signal
long start_at = millis ();
void setup () {
// put your setup code here, to run once:
pinMode (PIN_PWM, OUTPUT);
pinMode (PIN_SWSE, OUTPUT);
pinMode (PIN_SWSP, OUTPUT);

analogWrite (PIN_PWM, 0);
digitalWrite (PIN_SWSE, LOW);
digitalWrite (PIN_SWSP, LOW);

}

void loop () {
long now = millis ();
/ *
* If the signal is already online from the recipient
* the channel is kept open.
* /
if (signal_online) {
analogWrite (PIN_PWM, 0);
digitalWrite (PIN_SWSP, LOW);
digitalWrite (PIN_SWSE, HIGH);
return;
}

/ *
* After switching on, after about 5 seconds
* a signal of approx. 500us applied for one second.
* /
if (now - start_at> 5000 && now - start_at <6000) {
digitalWrite (PIN_SWSP, HIGH);
analogWrite (PIN_PWM, 7);
digitalWrite (PIN_SWSE, LOW);
}

/ *
* After about 6 seconds, the signal from the processor will be the one above
* was set to 0 and the coupler closed.
* The signal line of the receiver is now released for this.
* /
if (now - start_at> = 6000) {
analogWrite (PIN_PWM, 0);
digitalWrite (PIN_SWSP, LOW);
digitalWrite (PIN_SWSE, HIGH);
signal_online = true;
 
  • Like
Reactions: Steve Carr
The program above is made to generate a start pulse for CGO2 camera (it seems also work for CGO3). It is a µ-processor between PWM out of the drone and PWM in at camera. After power on it waits 5s then it generates 500µs pulses for 1s. This initializes the camera to take the PWM signals into account. After the 1s pulses the processor led PWM signal through from drone to camera. That's it, no access to gimbal or so.
It was made to tilt the camera with a standard PWM signal (one without start pulse).
Links:
Anmelden
Yneec CGO3 + in own constructions.
Using CGO2 with standard PWM receiver - Page 3 - RC Groups
br HE
 
  • Like
Reactions: cabinfourus
The program above is made to generate a start pulse for CGO2 camera (it seems also work for CGO3). It is a µ-processor between PWM out of the drone and PWM in at camera. After power on it waits 5s then it generates 500µs pulses for 1s. This initializes the camera to take the PWM signals into account. After the 1s pulses the processor led PWM signal through from drone to camera. That's it, no access to gimbal or so.
It was made to tilt the camera with a standard PWM signal (one without start pulse).
Links:
Anmelden
Yneec CGO3 + in own constructions.
Using CGO2 with standard PWM receiver - Page 3 - RC Groups
br HE
I am using chatGPT to help me rewrite this code to do more. Pretty handy tool sometimes. The guy who wrote the original emailed me about it but it doesn't seem to do much. Hopefully, I can rewrite it to do more. I am looking at the gimbal set v39 software as a reference.
 
That is the problem with using the PWM interface with the CGO3+, you can only control the tilt, not the yaw. To control the yaw, as far as I know, you have to use the serial interface to the gimbal.

Yes, that's true. The flight controller tries to connect to the camera via UART. If failed the fall back to PWM (backwards compatiliby?).
failed_conn-PWM.png

If connection was established then the whole communication (tilt, pan, yaw and possibly more) will be done via UART.
Conn_established.png

Zoom in:

Conn_established_zoom.png

Channel 0 on the bottom is analog, showing that all UART signals are 3.3V, so be aware not using circuits that have 5V signal voltage.

br HE
 
  • Like
Reactions: Steve Carr

New Posts

Members online

No members online now.

Forum statistics

Threads
20,955
Messages
241,598
Members
27,286
Latest member
lahorelaptop