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

Coding a gimbal

Joined
Mar 4, 2019
Messages
320
Reaction score
153
Age
54
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

New Posts

Members online

No members online now.

Forum statistics

Threads
20,715
Messages
239,029
Members
26,407
Latest member
Jonasre99