SMALL - espritmodel.com SMALL - Telemetry SMALL - Radio
Reply
Thread Tools
Old Nov 20, 2012, 07:57 PM
X-Ikarus
Reflex1's Avatar
United Kingdom, North York
Joined Feb 2003
1,710 Posts
I have been playing with model Vario's for a little time now ( Not an expert though)

My last was based on MultiWii code
it simply sounded an Alarm, via a FrSky analogue Telemetry link when in Lift
It worked quite well and many extended flights achieved

But. I missed the Full Vario audio capability of a Proper Vario
to enable "Centering" a Thermal and avoiding Sink.

Although due to poor conditions I haven't had many flights yet with KK's version
I'm already sure, I like it much better than my older system

And with it's low cost. Whats Not to like ?
Reflex1 is offline Find More Posts by Reflex1
Reply With Quote
Sign up now
to remove ads between posts
Old Nov 20, 2012, 08:08 PM
Who needs a pilot??
danstrider's Avatar
Alexandria, VA
Joined Jul 2002
1,166 Posts
Quote:
Originally Posted by thnilsen View Post
I have been thinking the same with using the FrSky telemetry units. However, I believe the LDC panel provided by FrSky only provides 3 tones all together, so you would be limited on indicating levels of lift/sink. Please correct me if I'm wrong as I'm having a hard time not pressing the BUY button on one of those DIY FrSky units...
Hi Thomas, yes and no. The D6FR I have only transmits a single analog line down, but the D8R-II looks to have a data line that should make this possible. This will mean just using the data downlink feature, not the FrSky panel. The protocol is documented here: http://www.rcgroups.com/forums/showp...25&postcount=1. From what I'm reading about others' FrSky vario experimentation, the 3-tone method simply used an analog transmission and set two thresholds on the ground unit. Not proportional. My D6FR would work for that. But I'm spoiled to the proportional SkyMelody, so I got a D8R-II to try.

Quote:
Originally Posted by kapteinkuk View Post
My vario only sends sound, so I doubt it will work through that FrSky down link, unless the link is hardware at lowest level (Mark/Space).
My plan is to replace the tone() calls with sendToGroundUnit() digitally via the data line and have a ground unit that parses and makes the tone. I don't have the room for another airborne transmitter. This will mean packetizing the data in the FrSky format, which is the only major hurdle I see left.

Quote:
Originally Posted by kapteinkuk View Post
The vario only uses fast relative changes in pressure as input. So an absolute accuracy is not necessary.
Good point.

Dan
danstrider is offline Find More Posts by danstrider
Reply With Quote
Old Nov 20, 2012, 08:17 PM
X-Ikarus
Reflex1's Avatar
United Kingdom, North York
Joined Feb 2003
1,710 Posts
Dan. if you can get it working via the
FrSky Data down link. I'd be interested in testing it
Reflex1 is offline Find More Posts by Reflex1
Reply With Quote
Old Nov 20, 2012, 09:10 PM
Registered User
New Zealand, Auckland, Waitakere
Joined Jan 2012
55 Posts
Well done guys this is exactly what i have been looking for! Super simple yet does its job. just a question regarding the size of this but can it be made smaller using a Arduino Pro Mini Microcontroller 3.3V/8MHz? Thanks ahead of time.
HughesBrothers is offline Find More Posts by HughesBrothers
Reply With Quote
Old Nov 21, 2012, 02:17 AM
Registered User
thnilsen's Avatar
Norway, Hordaland, Os
Joined Nov 2004
363 Posts
Quote:
Originally Posted by danstrider View Post
My plan is to replace the tone() calls with sendToGroundUnit() digitally via the data line and have a ground unit that parses and makes the tone. I don't have the room for another airborne transmitter. This will mean packetizing the data in the FrSky format, which is the only major hurdle I see left.

Dan
Again I might be wrong but I believe port A1 and A2 on the D8R-II plus RX is simple analog ADC ports and won't need much formatting, apart from sending a value between 1 and 1023, which can be done by taking the digital value from the vario and rescaled with the map function (I think?). So it should be fairly simple to connect one of the analog ports on the arduino vario to one of the A1/A2 ports and parse on the TX side with another arduino with a sound module.

Too bad that the FrLCD code doesn't seem to be available any longer, as that would be a very good starting point to make your own FrSky decoder and vario receiver.
thnilsen is online now Find More Posts by thnilsen
Reply With Quote
Old Nov 21, 2012, 08:56 AM
Who needs a pilot??
danstrider's Avatar
Alexandria, VA
Joined Jul 2002
1,166 Posts
Quote:
Originally Posted by thnilsen View Post
Again I might be wrong but I believe port A1 and A2 on the D8R-II plus RX is simple analog ADC ports and won't need much formatting, apart from sending a value between 1 and 1023, which can be done by taking the digital value from the vario and rescaled with the map function (I think?). So it should be fairly simple to connect one of the analog ports on the arduino vario to one of the A1/A2 ports and parse on the TX side with another arduino with a sound module.
Using A1 and A2 could work. Instead of a tone, a DAC could generate voltages representing the vario sound (since MS-5611 is only a digital sensor), push these onto A1 and/or A2, then be decoded on the ground. The D8R-II's two analog input ports are both internally scaled to 0x00 to 0xFF, a total of 255 discrete positions, or 512 if you used both A1 and A2. This is the first paragraph of: http://www.frsky-rc.com/uploadfile/2...1121837352.pdf This method appears to be what the FrLCD used, bottom of page 8: http://www.rcgroups.com/forums/showa...1&d=1336417330 using an analog output sensor like the Thermal Scout or How High.

Not to beat a dead horse, I'm personally leaning to using the 6 user bytes because I can get significantly more discrete tones (up to 256^6). Here's some code for stuffing a GPS onto the data line, for example: http://www.rcgroups.com/forums/showpost.php?p=18007374

I don't want to hijack this thread to turn it into an FrSky discussion. This may be possible with FrSky in multiple ways. Thanks kapteinkuk for the example application code and all you guys for contributing ideas.

Dan
danstrider is offline Find More Posts by danstrider
Reply With Quote
Old Nov 22, 2012, 12:24 PM
Youtube: TomRi25
Dr.Tom's Avatar
Croatia, City of Zagreb, Zagreb
Joined Aug 2010
734 Posts
great work KK

could the code be modified so it outputs sound right there, onboard?
it could be picked up by microphone on fpv planes,

step 2 would be RC selectable ON/OFF depending on PWM input on some channel...
and mixing it with mic line directly...

here's a product that does that, but costs a lot
http://www.dronesvision.com/lastoned...ge-fpv-flying/
and there are many older arduino based multirotor boards with baro sensors laying around
Dr.Tom is offline Find More Posts by Dr.Tom
RCG Plus Member
Last edited by Dr.Tom; Nov 22, 2012 at 12:29 PM.
Reply With Quote
Old Nov 22, 2012, 03:45 PM
Registered User
thnilsen's Avatar
Norway, Hordaland, Os
Joined Nov 2004
363 Posts
Quote:
Originally Posted by Dr.Tom View Post
great work KK

could the code be modified so it outputs sound right there, onboard?
it could be picked up by microphone on fpv planes,

step 2 would be RC selectable ON/OFF depending on PWM input on some channel...
and mixing it with mic line directly...
If you already have audio enabled on your FPV setup, I think it should be enough to just splice the output D2 with your existing audio line on the FPV vTx.

For the RC on/off take a look at http://www.sparkfun.com/tutorials/348. It is a simple tutorial on how to read the signals from a receiver. On the Nano, connect the RC channel of choice to pin D5 and add the following bits to Rolf's code:

int c1 = 0; // place at the very start before void setup.

pinMode(5, INPUT); // Place in void setup() function

ch1 = pulseIn(5, HIGH, 25000); // place early in void loop. The value of your rx channel will be stored in ch1.

Then replace the "if (toneFreq < 0 || ddsAcc > 0) " code with the following:
Code:
if ( ch1 >1500 ) {
 if (toneFreq < 0 || ddsAcc > 0) 
  {
    tone(2, toneFreq + 510);  
  }
  else
  {
    noTone(2);
  }
} 
else
{
 noTone(2)
}
If you have the D5 connected to a channel on a two way switch, it should then turn the tone off when the switch is on one side. Change the 1500 value at "if ch > 1500" to use different values. You can use the sketch from sparkfun to find the values you want to use if you use a 3 way switch. You should see values from the RX in the range of around 1000-18000. Some radio types might give more.

I have not tested the code as suggested, but it should get you there.

- Thomas
thnilsen is online now Find More Posts by thnilsen
Reply With Quote
Old Nov 25, 2012, 09:01 PM
Registered User
New Zealand, Auckland, Waitakere
Joined Jan 2012
55 Posts
Quote:
Originally Posted by HughesBrothers View Post
Well done guys this is exactly what i have been looking for! Super simple yet does its job. just a question regarding the size of this but can it be made smaller using a Arduino Pro Mini Microcontroller 3.3V/8MHz? Thanks ahead of time.
Hi again guys. Can any one just please confirm the above? That way i can buy the parts and get on with it. Cheers. Also for the rf transmitter and receiver can someone please post a direct link to the one that will work the best? Thanks heaps all.
HughesBrothers is offline Find More Posts by HughesBrothers
Reply With Quote
Old Nov 26, 2012, 04:17 AM
Registered User
thnilsen's Avatar
Norway, Hordaland, Os
Joined Nov 2004
363 Posts
Quote:
Originally Posted by HughesBrothers View Post
Hi again guys. Can any one just please confirm the above? That way i can buy the parts and get on with it. Cheers. Also for the rf transmitter and receiver can someone please post a direct link to the one that will work the best? Thanks heaps all.
I haven't checked, but if the MS5611 breakout board you pick and the radio module you pick both support 3.3v you should be fine using a Pro Mini. Check the specs on the components first. You would also have to make some arrangements to reduce the 5v coming from your RC RX if you decide to feed it from there. If you use a separate a battery that would not be an issue.
But to make it simpler, why not go for the 5v/16Mhz Pro Mini. That way it is fully compatible with the original design but still has the same small footprint as the 3.3v Mini Pro.

As for the 433 tx/rx, look at http://www.rfsolutions.co.uk/acatalo...AM_2dRX4_2d433 and http://www.rfsolutions.co.uk/acatalo...r__4_Pin_.html. Only drawback of using this shop is the expensive postage unless you live in the UK.

- Thomas
thnilsen is online now Find More Posts by thnilsen
Reply With Quote
Old Nov 28, 2012, 02:40 AM
Registered User
United States, WA, Seattle
Joined Apr 2009
8 Posts
OSS License

Hi Rolf,

What's the license you have set on the arduino code?

Thanks! I hope to build one this weekend.
harking is offline Find More Posts by harking
Reply With Quote
Old Nov 29, 2012, 07:08 PM
Who needs a pilot??
danstrider's Avatar
Alexandria, VA
Joined Jul 2002
1,166 Posts
Kapteinkuk, would you happen to have a datasheet on the GY-63 module? I can't find one online and it wasn't with the shipment... I'm struggling to get I2C working. Curious if you connected PS to VCC or GND (I read VCC to select I2C from the MS5611 datasheet) and if you connected CSB to VCC or GND (from your MS5611 address of 0x77, that is pointing to CSB being tied to GND)? I can't tell from your board build pictures if there are any connections beneath the board that aren't done on the backside. Your circuit schematic didn't show these connections.

In other news for all, I have the FrSky data transmission working fine. Input bytes to the airborne receiver's data port at 9600 baud (8n1, inverted), and they pop out of the ground transmitter module's txd port buttoned up in a little user frame. My tone generation on the ground sounds terrible and it appears tied to my transmitted 2-bytes dropping off precision compared to the float onboard. Definitely something solvable and I'm hoping this improves the sound greatly.

Dan
danstrider is offline Find More Posts by danstrider
Reply With Quote
Old Nov 29, 2012, 08:28 PM
Who needs a pilot??
danstrider's Avatar
Alexandria, VA
Joined Jul 2002
1,166 Posts
Hours, but I finally sorted out the I2C problem. Good news is that a ProMini runs the code just fine and connects to the MS5611 through the GY-63 just as in Rolf's video! Fun stuff.

Now for the FrSky cleanup and we're off to the races...
danstrider is offline Find More Posts by danstrider
Reply With Quote
Old Dec 02, 2012, 11:43 PM
Registered User
rrcdoug's Avatar
Canada, BC, Kelowna
Joined Aug 2010
215 Posts
Arduino Vario

I have been using an Xbee/Pro-mini/BMP-085/GPS based vario. Sensitivity and response are poor (about what we had hang gliding in the '70s) due to the noise from the Bosch pressure sensor and code running on a pocketPC (skyNavigator).

I am hoping to improve this unit with a MS5611 read by the arduino, then DAC it to frSky AD2. With 3 alarm levels available this, this should be usable and hopefully faster than the Xbee-Bluetooth-PocketPC chain I am now using.

My understanding of frSky serial telemetry is there is an overall limit of 1200 bps even though the link is 9600bps. I think DanStrider mentioned in a post that the serial data coming out the Tx module (from the airborne unit) is still in packets. I guess this makes sense but I seem to recall the statement that it was "pure user bytes".

I haven't ordered the frSky modules yet but they are very attractive at the price.
rrcdoug is offline Find More Posts by rrcdoug
Reply With Quote
Old Dec 08, 2012, 11:13 AM
Who needs a pilot??
danstrider's Avatar
Alexandria, VA
Joined Jul 2002
1,166 Posts
DIY Vario FrSky-style

Alrighty, I ported Rolf's vario to run over FrSky.

Airborne hardware:
  • FrSky D8R-II receiver
  • Arduino Pro Mini 3.3v 8MHz
  • GY-63 breakout board for MS5611 pressure sensor

Ground hardware:
  • DJT transmitter module
  • Arduino Pro Mini 3.3v 8MHz
  • RS232 inverting circuit (per FrSky manual, less R14, D8)
  • Piezo speaker

Functionality:
DIY DLG vario (0 min 33 sec)


Airborne code:
Code:
// All code by Rolf R Bakke, Oct 2012
// Modifications by Dan Edwards, Nov 2012
//   Added the 2nd order temperature calibration routine.
//   Added  #defines for the command names for clarity.
//   Tone is no longer generated airborne, instead data is
//    transmitted to the ground via an FrSky telemetry module.
//    A ground station parses the data and makes the tone.

//_____ MACROS
#define ADDR            0x77 // address of MS-5611
#define CMD_RESET       0x1E // ADC reset command
#define CMD_D1_ADC_256  0x40 // D1 ADC OSR=256
#define CMD_D1_ADC_512  0x42 // D1 ADC OSR=512
#define CMD_D1_ADC_1024 0x44 // D1 ADC OSR=1024
#define CMD_D1_ADC_2048 0x46 // D1 ADC OSR=2056
#define CMD_D1_ADC_4096 0x48 // D1 ADC OSR=4096
#define CMD_D2_ADC_256  0x50 // D2 ADC OSR=256
#define CMD_D2_ADC_512  0x52 // D2 ADC OSR=512
#define CMD_D2_ADC_1024 0x54 // D2 ADC OSR=1024
#define CMD_D2_ADC_2048 0x56 // D2 ADC OSR=2056
#define CMD_D2_ADC_4096 0x58 // D2 ADC OSR=4096
#define CMD_ADC_READ    0x00 // ADC read command
#define CMD_PROM_RD     0xA0 // Prom read command

#define TONE_PIN 9 // pin for piezo speaker
#define LED_PIN 13 // pin for LED

//_____ INCLUDES
#include <Wire.h>
#include <SoftwareSerial.h>

//_____ DEFINITIONS
unsigned int calibrationData[7];
unsigned long time = 0;
int checksum=0;

float toneFreq, toneFreqLowpass, pressure, lowpassFast, lowpassSlow;
int ddsAcc, encodedToneFreq;

// ProMini pin 6 to D8R pin Rx
SoftwareSerial SerialTelem(5,6,true); // rx,tx,inverse  RX (*airborne unit)

//********************************************************
//!  setup for main loop
//!
//!  returns nothing
//********************************************************
void setup() {
  // for user debugging
  Serial.begin(9600);
  Serial.println("FrSky vario airborne");
  delay(2000);

  // setup for FrSky telemetry data transfer
  SerialTelem.begin(9600);

  // setup altimeter sensor 
  Wire.begin();
  setupSensor();

  // initialize for mainline program filter
  pressure = getPressure();
  lowpassFast = lowpassSlow = pressure;
}

//********************************************************
//!  main program loop
//!
//!  returns nothing
//********************************************************
void loop() {
  byte buf[3];
  pressure = getPressure();
  //pressure = 4000 + 10*sin(-(float)millis()/2000);

  lowpassFast = lowpassFast + (pressure - lowpassFast) * 0.1;
  lowpassSlow = lowpassSlow + (pressure - lowpassSlow) * 0.05;

  toneFreq = (lowpassSlow - lowpassFast) * 50;

  toneFreqLowpass = toneFreqLowpass + (toneFreq - toneFreqLowpass) * 0.1;

  toneFreq = constrain(toneFreqLowpass, -500, 500);

  // direct digital synthesizer
  // the int wrapping around is the trick here
  ddsAcc += toneFreq * 100 + 2000;

  // create intermittent beeping tone for ascending
  if (toneFreq < 0 || ddsAcc > 0) {
    //tone(TONE_PIN, toneFreq+510);
    encodedToneFreq = (int)(toneFreq*100); // encode for max use of bytes
  }
  else {
    //noTone(TONE_PIN);
    encodedToneFreq = 0xFFFF; // represents a zero
  }

  // compute checksum (this is lame)
  checksum = highByte(encodedToneFreq) + lowByte(encodedToneFreq);
  checksum = (byte)checksum;

  // send everything at once
  buf[0] = highByte(encodedToneFreq); // MSB
  buf[1] = lowByte(encodedToneFreq); // LSB
  buf[2] = (byte)checksum; // checksum
  SerialTelem.write(buf,3);

  /* // show user bytes
   Serial.print("\nencodedToneFreq: ");
   Serial.println(encodedToneFreq);
   
   Serial.print("MSB: ");
   Serial.println(highByte(encodedToneFreq),HEX);
   
   Serial.print("LSB: ");
   Serial.println(lowByte(encodedToneFreq),HEX); // LSB
   
   Serial.print("chk: ");
   Serial.println(checksum,HEX); */

  ledOff();
  while (millis() < time);  //loop frequency timer
  time += 30;
  ledOn();
}

//********************************************************
//!  read pressure from MS-5611 sensor
//!
//!  returns pressure 10 to 1200mbar in 0.01mbar increments
//********************************************************
long getPressure() {
  long D1, D2, dT, P;
  float TEMP;
  int64_t OFF, SENS;

  D1 = getData(CMD_D1_ADC_4096); // resolution 0.012mbar
  D2 = getData(CMD_D2_ADC_256); // resolution 0.012C

  dT = D2 - ((long)calibrationData[5] << 8);
  TEMP = 2000 + (((int64_t)dT * (int64_t)calibrationData[6]) >> 23);  // -4000 to 8500 = -40C to 85C
  OFF = ((unsigned long)calibrationData[2] << 16) + (((int64_t)calibrationData[4] * dT) >> 7);
  SENS = ((unsigned long)calibrationData[1] << 15) + (((int64_t)calibrationData[3] * dT) >> 8);

  // 2nd order temp compensation, MS-5611 datasheet Fig 3
  float T2=0.0;
  int64_t OFF2=0, SENS2=0, tmp;
  if (TEMP < 2000) {  // lower than 20C
    T2 = (float)((dT*dT) >> 31);
    tmp = TEMP-2000;
    tmp = 5*tmp*tmp;
    OFF2 = tmp >> 1;
    SENS2 = tmp >> 2;
  }
  if (TEMP<-1500) {  // lower than -15C
    tmp = TEMP+1500;
    tmp = tmp*tmp;
    OFF2 = OFF2 + 7*tmp;
    SENS2 = SENS2 + (11*tmp) >> 1;
  }
  TEMP = TEMP - T2;
  OFF = OFF - OFF2;
  SENS = SENS - SENS2;

  // calculate pressure and temperature
  P = (((D1 * SENS) >> 21) - OFF) >> 15; // 10 to 1200mbar with 0.01mbar resolution
  TEMP = TEMP / (float)100;  // -40 to 85C

  //Serial.println(TEMP);
  //Serial.println(P);

  return P;
}

//********************************************************
//!  sends data requests to the sensor
//!
//!  returns raw data
//********************************************************
long getData(byte command) {
  long result = 0;
  twiSendCommand(ADDR, command);
  switch (command) {
  case CMD_D1_ADC_256:
  case CMD_D2_ADC_256: 
    delayMicroseconds(900); 
    break;
  case CMD_D1_ADC_512:
  case CMD_D2_ADC_512: 
    delay(3); 
    break;
  case CMD_D1_ADC_1024:
  case CMD_D2_ADC_1024: 
    delay(4); 
    break;
  case CMD_D1_ADC_2048:
  case CMD_D2_ADC_2048: 
    delay(6); 
    break;
  case CMD_D1_ADC_4096:
  case CMD_D2_ADC_4096: 
    delay(10); 
    break;
  }
  twiSendCommand(ADDR, CMD_ADC_READ); // command ADC to read
  Wire.requestFrom(ADDR, 3); // ADC read should return 3 bytes, MSB first
  if(Wire.available()!=3) Serial.println("Error: raw data not available");
  for (int i = 0; i <= 2; i++) {
    result = (result<<8) | Wire.read(); 
  }
  return result;
}

//********************************************************
//!  reads calibration parameters from sensor
//!
//!  returns nothing
//********************************************************
void setupSensor() {
  commandReset();

  for (byte i = 1; i <=6; i++) // get calibration coefficients 1-6
  {
    unsigned int low, high;

    twiSendCommand(ADDR, 0xa0 + i * 2);
    Wire.requestFrom(ADDR, 2);
    if(Wire.available()!=2) Serial.println("Error: calibration data not available");
    high = Wire.read();
    low = Wire.read();
    calibrationData[i] = high<<8 | low;
    Serial.print("calibration data #");
    Serial.print(i);
    Serial.print(" = ");
    Serial.println( calibrationData[i] ); 
  }
}

//********************************************************
//!  resets sensor and waits for it to restart
//!
//!  returns nothing
//********************************************************
void commandReset() {
  twiSendCommand(ADDR, CMD_RESET); // reset sensor
  delay(3);  // wait for the reset sequence timing
}

//********************************************************
//!  two-wire interface sends a command to an I2C address
//!
//!  returns nothing
//********************************************************
void twiSendCommand(byte address, byte command) {
  Wire.beginTransmission(address);
  if (!Wire.write(command)) Serial.println("Error: write()");
  if (Wire.endTransmission()) 
  {
    Serial.print("Error when sending command: ");
    Serial.println(command, HEX);
  }
}

//********************************************************
//!  turns LED on and off
//!
//!  returns nothing
//********************************************************
void ledOn()  {  
  digitalWrite(LED_PIN,1);  
}
void ledOff() {  
  digitalWrite(LED_PIN,0);  
}
Ground code:
Code:
/*
 All code by Dan Edwards, Nov/Dec 2012 except where noted
 Vario: Ground unit.
 uses hardware inverter for serial
 ProMini pin RX1 to DJT pin Txd
 */

// ****************************************************************** //
#define HEAD  0x7E  // sync is two of these in a row
#define PRIM  0xFD  // prim signifying a user data frame

#define STATE_BEGIN  0
#define STATE_HEAD  1
#define STATE_PRIM  2
#define STATE_SIZE  3
#define STATE_RESV  4
#define STATE_USER  5

#define TONE_PIN 9
#define LED_PIN 13

int vario=0;

// ****************************************************************** //
void setup() {
  // initialize serial port
  Serial.begin(9600); // FrSky ONLY speaks 9600 baud
  Serial.println("\nFrSky vario ground unit\n");
  delay(2000);
}

// ****************************************************************** //
void loop() {
  //Serial.println("");
  static float myTone = 0.0;

  getUserData();
  //Serial.print("Vario: ");
  //Serial.println(vario);

  // decode
  myTone = (float)vario/100 + 510;

  // make beepy noises
  if (vario == 0xFFFF) {
    noTone(TONE_PIN);
    //Serial.print("Tone: ");
    //Serial.println("0");
  }
  else if (myTone >= 0) {
    tone(TONE_PIN,myTone);
    //Serial.print("Tone: ");
    //Serial.println(myTone);
  }
}

// ****************************************************************** //
#define FRAMESIZE 11
#define SYNC 0x7E
#define USER 0xFD
int data[FRAMESIZE];
int counter;
boolean stuffFlag;
// derived from: http://arduino.cc/forum/index.php?topic=30440.15;wap2 

void getUserData() {
  while (Serial.available()) {

    byte b = Serial.read();

    if (b==SYNC && counter==FRAMESIZE-1 && data[0]==SYNC && data[1]==USER) {
      /* // looks like the end of a valid frame
       Serial.print("size: ");
       Serial.println(data[2], HEX);
       Serial.print("msb:");
       Serial.println(data[4], HEX);
       Serial.print("lsb:");
       Serial.println(data[5], HEX);
       Serial.print("checksum:");
       Serial.println(data[6], HEX);
       Serial.println(" "); */

      parseUserData(data);
      return;
    } 
    else if (b == 0x7D) { // Byte stuffing!
      stuffFlag = true;
      continue; // this byte only used as a flag, don't save
    } 
    else if (b == 0x7E) {
      counter = 0; // start of a new frame. hopefully.
    }

    if (stuffFlag) { // Byte stuffing!
      b ^= 0x20;
      stuffFlag = false;
    }
    data[counter++] = b;
  }
} // function


// ****************************************************************** //
boolean parseUserData(int *data) {
  byte msb, lsb, checksum;

  /* // show user data
   Serial.print("user data (hex): ");
   for (byte i=0; i<=FRAMESIZE-1; i++) {
   Serial.print(data[i],HEX);
   Serial.print(" ");
   }
   Serial.println(); */

  msb = data[4];
  lsb = data[5];
  checksum = data[6];

  // error check size and checksum
  if (data[2] == 3 && (byte)(msb+lsb)==checksum) {
    /* Serial.print("msb: ");
     Serial.println(msb,HEX);
     Serial.print("lsb: ");
     Serial.println(lsb,HEX);*/

    // reassemble vario
    vario = msb*256 + lsb;
    //Serial.print("raw vario: ");
    //Serial.println(vario);
    return true;
  } 
  else {
    //if ((byte)(msb+lsb)==checksum)
    //Serial.println("chksum err");
    if (data[2] == 3)
      Serial.println("size err");
    return false;
  }
}
It works okay. There is a little bit of choppiness in the sound which seems to come from running slower, occasional dropped frames, and perhaps things I haven't thought about. Was thinking of adding a smoother on the ground unit to get a prettier output tone.

No apparent issues with the Pro Mini! This should fit in my DLG once it's all cleaned up and shrunk to size. Looking forward to trying it out.

I'm happy to hear tips on the software.
Dan
danstrider is offline Find More Posts by danstrider
Reply With Quote
Reply


Thread Tools

Similar Threads
Category Thread Thread Starter Forum Replies Last Post
Discussion Arduino based IR tag module for combat sh4nce Electric Combat 37 Sep 25, 2014 10:44 AM
Mini-HowTo DIY arduino twin video receiver diversity controller. Updates allways in post #1 Richard_s FPV Equipment 144 Jul 13, 2014 12:27 PM
New Product DIY OpenPilot based FlightControl (F4) lilvinz Multirotor Electronics 267 Feb 16, 2014 04:43 AM
Idea DIY Video Diversity with Arduino - Please Review! MayMayDay FPV Talk 2 Sep 23, 2012 01:36 PM
Help! Engineering student and first arduino based build? cad2blender UAV - Unmanned Aerial Vehicles 3 May 17, 2012 08:59 AM