Hello,
I have found this useful video, at 1'34"
http://www.youtube.com/watch?v=tuzh9XCIins
Moderator: lukasz
/*
Francisco Bascón, december 2013
Using example from Tom Igoe.
http://www.arduino.cc/en/Tutorial/SerialEvent
This sketch takes some telemetry data avaible at serial port from
"communication_csv.c" r157 by Tom Pycke on Jan 18, 2013.
(svn/ trunk/ Firmware/ rtos_pilot/ communication_csv.c)
Tx pin on Gluonboard is at FTDI connection. The 5th from the FTDI GND pin.
Because I am newbie on Arduino, better code is grateful.
*/
boolean stringComplete = false; // whether the line is complete
boolean LetterTrue,EndLine= false;
int TAdata[3]; //three data in Attitude array
int TGdata[3]; //three data in GPS array
int TCdata[3]; //three data in Gluon control data array
void setup() {
// initialize serial:
Serial.begin(57600); //baud Gluon
}
void loop() {
// print the string when a newline arrives:
//////Below, show data on Arduino Serial Port to check////////////
if (stringComplete)
{
//Attitude, 2 data (roll, pitch at 1000 radians)
Serial.print("Att : ");
for (int i=0;i<=1;i++)
{
Serial.print(TAdata[i]);
Serial.print(",");
}
Serial.println();
//GPS, 3 data (speed at cm/s, yaw at 100 radians, satellites to chek)
Serial.print("GPS: ");
for (int i=0;i<=2;i++)
{
Serial.print(TGdata[i]);
Serial.print(",");
}
Serial.println();
//Gluon Control, 2 data (current_codeline ,to enable gimbal only on mission block, and height)
Serial.print("Ctr : ");
for (int i=1;i<=2;i++)
{
Serial.print(TCdata[i]);
Serial.print(",");
}
Serial.println();
stringComplete = false; //put the variables at initial values
LetterTrue,EndLine= false; //put the variables at initial values
}
}
/*
SerialEvent occurs whenever a new data comes in the
hardware serial RX. This routine is run between each
time loop() runs, so using delay inside loop can delay
response. Multiple bytes of data may be available.
*/
void serialEvent() {
while (Serial.available()) {
// get the new byte, from serial Output "communication_csv.c"
// author Tom Pycke,@date 24-dec-2009, since 0.1
char inChar = (char)Serial.read();
if ('A' == inChar ) //Attitude from $TA line
{
TAdata[0] =Serial.parseInt(); //roll (1000*rad)
TAdata[1] =Serial.parseInt(); //pitch (1000*rad)
TAdata[2] =Serial.parseInt(); // yaw from gyroscope (1000*rad), not good this yaw
// because zero value is for every module power on,
// doesn´t it? maybe needed better info to ensure.
LetterTrue = true; // if the incoming character is the right header letter
// set a flag, boolean variable
}
if ('G' == inChar ) //GPS from $TG line
{ //(Needed float variable to parse data right)
double TG_Float_data[6]; //six data in GPS array, need float to right parse
// due to three CHAR initial incoming data
TG_Float_data[0] =Serial.parseFloat();//gps.status CHAR.
TG_Float_data[1] =Serial.parseFloat();//gps.lat CHAR
TG_Float_data[2] =Serial.parseFloat();//gps.lon CHAR
TG_Float_data[3] =Serial.parseFloat();//speed_10 x m/s or cm/s
TG_Float_data[4] =Serial.parseFloat();// yaw or heading_rad*100, need moving to be good
TG_Float_data[5] =Serial.parseFloat();//satellites_in_view (only to check good parse of initial char)
LetterTrue = true; // if the incoming character is the right header letter
// set a flag, boolean variable
{// convert need data to integer values TGdata
TGdata[0] = TG_Float_data[3];
TGdata[1] = TG_Float_data[4];
TGdata[2] = TG_Float_data[5];
}
}
if ('C' == inChar ) //Control from $TC line
{
TCdata[0] =Serial.parseInt(); //flight_mode
TCdata[1] =Serial.parseInt(); //current_codeline, to enable servos
TCdata[2] =Serial.parseInt(); //altitude
LetterTrue = true; // if the incoming character is the right header letter
// set a flag, boolean variable
}
// if the incoming character is a newline, set a flag, boolean variable
if (inChar == '\n')
{
EndLine = true;
if ((EndLine) && (LetterTrue))
{
stringComplete = true; // if the header letter and the line has arrived, the loop part can now runs
}
}}}
Tom wrote:
4. Yes, you need to create a cable that connects to the USB port of you camera. Put the USB +5V to the signal wire of a servo cable. And of course also connect GND. Use the attached script and the CHDK servo trigger mode (as navigation command) to start and stop triggering.
Users browsing this forum: No registered users and 6 guests