New Products Flash Sale
Thread Tools
Old Jun 26, 2015, 09:53 AM
Rfriedman is offline
Find More Posts by Rfriedman
Registered User
United States, CO, Boulder
Joined Jul 2012
383 Posts
Quote:
Originally Posted by Pisces View Post
I build another KK vario last night. I tested the Alen Komic code on the bench with a servo tester connected to Pin D3. You are correct this code does not work correctly. The LED turns ON and OFF correctly but the vario audio does not turn OFF (mute ) as it gives out a constant 500Hz tone.

My earlier build used the Alen Komic PPM control on D3 but I had set the vario for rising tone only. I tested again the Alen Komic code with the vario set of rising tone only and it works.

Maybe you can try this. Find the line and // it out and add the second line. This is the KK code for rising tone only.

//if (toneFreq < 0 || ddsAcc > 0) // comment out original code rising and sinking tone
if (toneFreq > 0 && ddsAcc > 0) // KK code for rising tone only
So you are saying for rc controlled code, the vario ALSO needs to having the rising only code?
Rfriedman is offline Find More Posts by Rfriedman
Reply With Quote
Sign up now
to remove ads between posts
Old Jun 26, 2015, 04:04 PM
Pisces is offline
Find More Posts by Pisces
The Dreamer
Pisces's Avatar
Sydney, Australia
Joined Dec 2010
1,020 Posts
Correct. The Alen Komic code only seems to work when the vario is set for rising code only. As Stratocus has also found with the RC control for Vario OFF there is a constant audio tone.

I used a HK RC 3 way video switch to control the audio into the Vtx, OFF- MIC - VARIO.

You can also use a RC switch to power ON-OFF the vario.

Or simply turn off the volume on the ground station.

This video is the Volantex glider ASW28 2.6m from HK. The KK DIY vario audio is connected to a 3 way video switch. The video switch also works just fine with audio. The switch to vario is around the 1 minute mark in this video into a thermal.

ASW28 Mic audio and vario selection using a video switch (2 min 4 sec)
Pisces is offline Find More Posts by Pisces
Last edited by Pisces; Jun 26, 2015 at 04:09 PM.
Reply With Quote
Old Jul 04, 2015, 02:44 AM
Rfriedman is offline
Find More Posts by Rfriedman
Registered User
United States, CO, Boulder
Joined Jul 2012
383 Posts
This vario is fantastic!
Caught a thermal from 600 feet to 2000 feet, and finding others was not too difficult either.
Soaring is so fun!
Rfriedman is offline Find More Posts by Rfriedman
Reply With Quote
Old Jul 08, 2015, 12:55 PM
SAUDAX is offline
Find More Posts by SAUDAX
Registered User
Joined Mar 2014
2 Posts
Hello , from France.

I would like to achieve variometrede Rolf R Bakke but you would have to tell me the list of components that are required (resistors and capacitors ... with their particular features watts, volts ...) .I started in e ...

Thank you in advance.
SAUDAX is offline Find More Posts by SAUDAX
Reply With Quote
Old Jul 08, 2015, 12:58 PM
SAUDAX is offline
Find More Posts by SAUDAX
Registered User
Joined Mar 2014
2 Posts
Hello from France.

I would like to achieve variometrede Rolf R Bakke but you would have to tell me the list of components that are required (resistors and capacitors ... with their particular features watts, volts ...) .I started in electronic ...

Thank you in advance.
SAUDAX is offline Find More Posts by SAUDAX
Reply With Quote
Old Jul 09, 2015, 03:11 AM
VideoKing is offline
Find More Posts by VideoKing
Registered User
VideoKing's Avatar
United Kingdom, England, Kent
Joined Dec 2010
822 Posts
Quote:
Originally Posted by SAUDAX View Post
Hello from France.

I would like to achieve variometrede Rolf R Bakke but you would have to tell me the list of components that are required (resistors and capacitors ... with their particular features watts, volts ...) .I started in electronic ...

Thank you in advance.
All the components are shown on the circuit diagram....

Link to Circuit Diagram


All resistors can be 1/8W
All Capacitors should be 10V electrolytic or tantalum, minimum. (these are the lowest voltage you will probably find anyway.)
Also if you are new to electronics, make sure you put the capacitors in the right way around. They do have a polarity, + and -
VideoKing is offline Find More Posts by VideoKing
Last edited by VideoKing; Jul 09, 2015 at 03:20 AM.
Reply With Quote
Old Jul 10, 2015, 12:26 AM
Rfriedman is offline
Find More Posts by Rfriedman
Registered User
United States, CO, Boulder
Joined Jul 2012
383 Posts
Quote:
Originally Posted by stratocus View Post
Because more precision is being asked, here we go

on post #709 page 48, the following code doesn't work as said.
// Modified by Alen Komic, Mar, 2014
// - on/off switch on Arduino Nano pin D3

Evertime PWM is sent to D3, to mute audio, instead it freezes the audio signal to its actual frequency.
When luck is with you and you mute the tone in a "silent interval" then it stays silent, however 90% of the time it freezes on high pitch freq.
I read here or there this issue has been already reported.

Any fix available?
My coding skills aren't yet good enough. Been working at a programming company for the past month in hopes to learn arduino, but I am not there yet
But, I have a guess...


If switchstate is false, then it says :

Serial.println("On-hold");
ledOff();

Should it actually be just

notone(2)
ledOff();
Rfriedman is offline Find More Posts by Rfriedman
Reply With Quote
Old Jul 11, 2015, 06:06 PM
Pisces is offline
Find More Posts by Pisces
The Dreamer
Pisces's Avatar
Sydney, Australia
Joined Dec 2010
1,020 Posts
Hi Rfiedman, good that you are getting some coding knowledge.

I was wondering myself about the interrupt in the Alen Komic code.

void handleSwitchInterrupt()
{
if(int1) {
pwmcount1=micros(); // we got a positive edge of the pulse
} else {
// we got a negative edge of the pulse, time to measure
if( (micros()-pwmcount1)>0 ) { // did micros() counter reset? Do we have input signal at all?
if( (micros()-pwmcount1)> borderValue ) {
switchState = true;
} else {
switchState = false;


There are really 3 states.

1. pwmcount 0. This is no pwm on pin D3. The vario powers up and works.
2. pwmcount >0 but less than <border value. Should be mute but there is continuous steady tone.
3. pwmcount >border value The vario powers up and works.

The LED works correctly for all 3 states above. That is, the LED is OFF for state2.

In state2, the problem is there is continuous audio which should be mute. The vario has a continuous tone which I think is 500Hz. Then the 500Hz tone loop is still working. This tone generating loop needs to be stopped in state2. This is the problem in the code.
Pisces is offline Find More Posts by Pisces
Last edited by Pisces; Jul 12, 2015 at 03:28 PM. Reason: typo
Reply With Quote
Old Jul 12, 2015, 05:47 PM
Pisces is offline
Find More Posts by Pisces
The Dreamer
Pisces's Avatar
Sydney, Australia
Joined Dec 2010
1,020 Posts
Quote:
Originally Posted by Rfriedman View Post
My coding skills aren't yet good enough. Been working at a programming company for the past month in hopes to learn arduino, but I am not there yet
But, I have a guess...


If switchstate is false, then it says :

Serial.println("On-hold");
ledOff();

Should it actually be just

notone(2)
ledOff();
I think you meant

noTone(2);
ledOff();

I tried this and the code won't compile and upload. There is an error message that the noTone(2); is not defined for this loop.

Back to the drawing board
Pisces is offline Find More Posts by Pisces
Reply With Quote
Old Jul 12, 2015, 11:34 PM
Rfriedman is offline
Find More Posts by Rfriedman
Registered User
United States, CO, Boulder
Joined Jul 2012
383 Posts
This compiled. I added a line in the last part of the void loop(), basically the else statement of if (switchstate==true) .
I think that switchstate basically means that if the switchstate is true, the vario functions, and if switchstate is false, it should turn off, but he never actually turned off the tone generation I think. Just stopped the loop. It is hard for me to understand everything because I only know simplified Javascript, and don't understand arduino API just yet.
Code:
// Main code by Rolf R Bakke, Oct 2012
// Modified by Alen Komic, Mar, 2014
//    - on/off switch on Arduino Nano pin D3
//Modified Ryan Friedman for off-bug, V1

#include <Wire.h>

const byte led = 13;

unsigned int calibrationData[7];
unsigned long time = 0;

float toneFreq, toneFreqLowpass, pressure, lowpassFast, lowpassSlow ;

int ddsAcc;

volatile long pwmcount1; // temporary variable for PWM input counting
boolean switchState = true;
// #define int0 (PIND & 0b00000100) //For Nano & Uno. D2.
#define int1 (PIND & 0b00001000) //For Nano & Uno. D3.

#define borderValue 1500  // switch state border value

void handleSwitchInterrupt() 
{ 
   if(int1) {
     pwmcount1=micros(); // we got a positive edge of the pulse
   } else { 
     // we got a negative edge of the pulse, time to measure
     if( (micros()-pwmcount1)>0 ) { // did micros() counter reset? Do we have input signal at all?
       if( (micros()-pwmcount1)> borderValue ) {
         switchState = true;
       } else {
         switchState = false;
       }
     }
   }
} 

void setup()
{
  Wire.begin();
  Serial.begin(115200);

  pinMode(3,INPUT); 
  attachInterrupt(1,handleSwitchInterrupt,CHANGE); // Catch up and down 

  setupSensor();
  
  pressure = getPressure();
  lowpassFast = lowpassSlow = pressure;
}


void loop()
{
  if( switchState==true ) {
    pressure = getPressure();
  
    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);
  
    ddsAcc += toneFreq * 100 + 2000;
  
    if (toneFreq < 0 || ddsAcc > 0) 
    {
      tone(2, toneFreq + 510);  
    }
    else
    {
      noTone(2);
    }
  
    ledOff(); 
    while (millis() < time);        //loop frequency timer
    time += 20;
    ledOn();
  } else {
    Serial.println("On-hold");
    ledOff();
    noTone(2);
  }
}


long getPressure()
{
  long D1, D2, dT, P;
  float TEMP;
  int64_t OFF, SENS;
 
  D1 = getData(0x48, 10);
  D2 = getData(0x50, 1);

  dT = D2 - ((long)calibrationData[5] << 8);
  TEMP = (2000 + (((int64_t)dT * (int64_t)calibrationData[6]) >> 23)) / (float)100;
  OFF = ((unsigned long)calibrationData[2] << 16) + (((int64_t)calibrationData[4] * dT) >> 7);
  SENS = ((unsigned long)calibrationData[1] << 15) + (((int64_t)calibrationData[3] * dT) >> 8);
  P = (((D1 * SENS) >> 21) - OFF) >> 15;
  
  //Serial.println(TEMP);
  //Serial.println(P);
  
  return P;
}


long getData(byte command, byte del)
{
  long result = 0;
  twiSendCommand(0x77, command);
  delay(del);
  twiSendCommand(0x77, 0x00);
  Wire.requestFrom(0x77, 3);
  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;
}


void setupSensor()
{
  twiSendCommand(0x77, 0x1e);
  delay(100);
  
  for (byte i = 1; i <=6; i++)
  {
    unsigned int low, high;

    twiSendCommand(0x77, 0xa0 + i * 2);
    Wire.requestFrom(0x77, 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] ); 
  }
}


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);
  }
}


void ledOn()
{
  digitalWrite(led,1);
}


void ledOff()
{
  digitalWrite(led,0);
}
Rfriedman is offline Find More Posts by Rfriedman
Reply With Quote
Old Jul 13, 2015, 03:17 AM
Pisces is offline
Find More Posts by Pisces
The Dreamer
Pisces's Avatar
Sydney, Australia
Joined Dec 2010
1,020 Posts
BINGO your Rfriedman code mod works. The code mod for tone-OFF (mute) works.

I also tested the above code with the mod for for rising tone only and the RC PPM connected on PIN D3 works.

I used a servo tester on PIN D3 to control the audio mute. The final test is to use an RC rx channel connected to PIN D3. There is no reason why this should not work.

Well done Ryan.

EDIT: Forgot to mention that with nothing connected to PIN D3 the vario powers up and works normally.
Pisces is offline Find More Posts by Pisces
Last edited by Pisces; Jul 13, 2015 at 05:44 AM.
Reply With Quote
Old Jul 13, 2015, 09:01 AM
Rfriedman is offline
Find More Posts by Rfriedman
Registered User
United States, CO, Boulder
Joined Jul 2012
383 Posts
Woohoo!

I'll edit my older post with the correct code. Maybe we can get it put on the first page of the thread?


Did you test it on a switch?
Rfriedman is offline Find More Posts by Rfriedman
Last edited by Rfriedman; Jul 13, 2015 at 09:13 AM.
Reply With Quote
Old Jul 14, 2015, 08:29 AM
Rfriedman is offline
Find More Posts by Rfriedman
Registered User
United States, CO, Boulder
Joined Jul 2012
383 Posts
So I remember someone was working on 3 stage battery alarm code. Should we get that sorted out too?
Rfriedman is offline Find More Posts by Rfriedman
Reply With Quote


Thread Tools

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