Quadcopter summer 2016

Before Aug I had no chance to fly the DJI F450, the first two weeks of august were not ok for flying, so I started in the middle of August.

18-aug-2016: Checked the batteries, compass and IMU calibrated, and it runs again.

On 24-aug and 25-aug I had two more flights, one on the beach and one on the moor. The “Maasvlakte video” dates from 24-aug.

The flight on 25-aug-2016 “Loon op Zand” had two hard landings because of battery capacity problems, either the low voltage level is too high, either I should charge the batteries differently, namely not at 1C but at a 1/2 or less at done prior to 25-aug-2016.

31-aug-2016: “Sunset at Oostvoorne” all went fine on this evening, except for taking off in the last run where I accidentally put it in manual mode, drone drifts in ATT mode at take-off while it is too close, you want to flip to GPS mode, but you execute MANUAL mode and then it is too late. This quadcopter is really sensitive in MANUAL mode.

11-sep-2016 “A few hours on the beach”: Fixed the gimbal (the Feiyu is easy to repair), one cable was disconnected during the last crash, replace a propellor, wait for a wind free day and off we go (10-sep had too much wind, so I took the kite up).

14-Sep-2016: “Beach Oostvoorne” went further south in the hope the beach was empty on a Wednesday afternoon, it pretty much was. Flew over the dunes and returned over the shorelines. Wind up to 4 m/s from the south, temperature 32C.

Trust me, I’m an engineer was the previous title of this blog

 

Advertisements

Rotary encoder on an Arduino

Attach a rotary encoder to an Arduino and make it count when you turn the knob. How does it work?

IMG_3119

The encoder has two lines, an A line on the left, a ground line in the middle, and a B line on the right. A and B output so-called Gray codes when you turn the knob, the Gray codes reveal the sense of rotation, the knob has 24 position in one turn, and with each click line A or B will change like a switch does.

I started to play around with existing Arduino code inspired by an article on circuits at home [link] and I added a few bells and whistles. There are some comments in the code, you will soon learn that there is a state transition table. My  explanation of this table goes in four handwritten sheets after the code.

#define ENC_A 14        // this is analog pin A0
#define ENC_B 15        // analog pin A1 on the arduino Uno
#define ENC_PORT PINC   // ENC_PORT gets all analog pins in one byte
#define TIMEOUT 2       // feel free to experiment around, 2 msec was ok for me
#define DEBUG 0         // 1 gives a bit more output
#define ROTATE 0        // counter from 0 to 255 rotates across boundary or not
#define CLOCKWISE       // undefine if you want a counterclockwise counter

unsigned long int timer = 0;
uint8_t encoder,prevencoder;

void setup() {
  pinMode(ENC_A, INPUT); digitalWrite(ENC_A, HIGH);  // it is A0
  pinMode(ENC_B, INPUT); digitalWrite(ENC_B, HIGH);  // it is A1
  Serial.begin (115200);
  Serial.println("Start");  
}

void loop() {
 static uint8_t counter = 0;      // output of the encoder
 int8_t tmpdata;
 if ((millis() - timer) > TIMEOUT) {
    tmpdata = read_encoder();
    if (DEBUG) {
      if (prevencoder != encoder) BinPrint( encoder );
      prevencoder = encoder;
    }
    if (tmpdata) {
      Serial.println(counter, DEC);
      if (ROTATE) {
        counter += tmpdata;
      } else {
        if ((counter < 255) && (tmpdata == +1)) counter += tmpdata;
        if (  (counter > 0) && (tmpdata == -1)) counter += tmpdata;
      }
    }
    timer = millis();
  }  
}

// returns change in encoder state (-1,0,1) 
int8_t read_encoder()
{
  // put the gray codes in four quadrants and start to count, I checked 
  // this in the following way
  //
  //   01 | 00
  //   -------
  //   11 | 10
  //
  // and the start counting the transitions across the boundaries
  //
  #ifdef CLOCKWISE
    // this is for clockwise turning
    static int8_t enc_states[] = {0,-1,+1,0,+1,0,0,-1,-1,0,0,+1,0,+1,-1,0};   
  #else
     // this is for counterclockwise turning
    static int8_t enc_states[] = {0,+1,-1,0,-1,0,0,+1,+1,0,0,-1,0,-1,+1,0};   
  #endif
  static uint8_t old_AB = 0;                // only does this once actually
  encoder = ENC_PORT;                       // I want to be able to debug
  old_AB <<= 2;                             // remember previous state
  old_AB |= ( encoder & 0x03 );             // form the state byte 
  return ( enc_states[( old_AB & 0x0f )]);  // &0x0f zeros out other bits
}

// shows the state of the encoder ports when we are debugging
void BinPrint( uint8_t copy ) {
  for (int i=0; i<8; i++) {
    if (copy & 0x01) {
      Serial.print("1");
    } else {
      Serial.print("0");
    }
    copy = copy >> 1;
  }
  Serial.println(" ");  
}

Here is the theory:

IMG_3115IMG_3116IMG_3117IMG_3118

Last update: 17-aug-2016

 

PI2NOS

De vraag was waar het getik op de repeater af en toe vandaan komt. Mijn SDR liet vandaag zien dat er af en toe spikes zijn waarbij de zender buiten de 12,5 kHz bandbreedte komt.

pi2nos_spike

Last update: 4-8-2016 13:31