Category Archives: measured

Heading difference

A problem that pops up always. When needing to calculate heading difference between two compass courses?


float calculateHeadError(float heading, float target)
{
#define PI2 PI*2.0
while (heading<0) heading += PI2; while (target<0) target += PI2; while (heading>PI2) heading -= PI2;
while (target>PI2) target -= PI2;

float res = heading-target;

if ((headingPI))
{
res =(heading+PI2)-target;
}

if ((heading>PI) && (target

External interrupts on Atmega 328

It’s this simple:


pinMode(5,INPUT);
PCMSK2 |= (1<
--
Catch the interrupts (default when signal goes up OR down)

ISR(PCINT2_vect)
{
// code here..
}

PCINT?_vect vectors are always used for Pin Change Interrupt Request Interrupts (see http://www.nongnu.org/avr-libc/user-manual/group__avr__interrupts.html)

--
Remember:

PCINT0..7 are asscociated with the 8 pins in PORTA and trigger the PCINT0_vect interrupt
PCINT8..15 are asscociated with the 8 pins in PORTB and trigger the PCINT1_vect interrupt
PCINT16..23 are asscociated with the 8 pins in PORTC and trigger the PCINT2_vect interrupt
PCINT24..31 are asscociated with the 8 pins in PORTD and trigger the PCINT3_vect interrupt

Use Logic loops in Ableton Live

Apple’s Logic comes with plenty of nice loops. These files are stored in “/Library/Audio/Apple Loops/Apple/Apple Loops for GarageBand”. However the files are in .CAF file format (Core Audio File). OS X comes with tool to convert these files, called “afconvert”.

To convert the files to for example AIFF (which is supported by Ableton Live) you can use command:

afconvert -f AIFF -d BEI16 infile outfile

You can find a script to batch convert all files from here: https://gist.github.com/1073217

MainStage 2 comes with plenty of nice samples (with the Jam Pack extensions which can be freely downloaded within the application). These files are stored in “/Library/Application Support/GarageBand/Instrument Library/Sampler/Sampler Files”.

Turnigy 9X with th9x firmware PPM out

The trainer out / transmitter out PPM pulse train on th9x has following features (measured facts):

  • Channel pulse is logical HIGH
  • Channel minimum pulse length = 700uS (microseconds, thats 0.7 milliseconds)
  • Channel minimum pulse length = 1700uS (microseconds, thats 1.7 milliseconds)
  • 8 channels per frame
  • Pause (logical low) between pulses is 300uS and has nothing to do with actual channel pulse width, pause has constant length (sum of pauses: 8*300uS = 2400uS = 2.4ms)
  • Conclusion: one channel tries to be max. 2000uS which would make total max. 16ms)
  • Total frame length = 20 milliseconds
  • So: last “channel” is 20ms minus sum of all pulses in frame, about 10..12ms (based on this information the last channel length is minimum 4ms)

Problems flashing Turnigy 9X with USBTiny?

I couldn’t flash my Turnigy 9X with Ladyada’s USBTinyISP (ver 2) until I found a solution

“I think you will find that your Device signature = 0x000000 problem is shared between the programmer and the Turnigy 9x. The Ladyada USB (known to avrdude as usbtiny) programmer schematic shows 1k5 short circuit protection resistors in the SCK and MOSI programming lines. I suspect that your programmer has the same circuit. The Turnigy 9X has 200R and .1uF capaitors on these lines to debounce the button inputs to the ATMega64. Unfortunately the debounce circuit slows down the programming pulses and prevents programming. Reducing the two 1k5 resistor values in the programmer to 100R fixes the problem, but so does choosing a different programmer!
I tried slowing down the programmer with -B option, but could not get the pulses slow enough.”

Source: http://diydrones.com/forum/topics/turnigy-9x-flashing-problem

Changed those resistors to 100 ohm and flashing worked. However first write failed the read verification set but retry gave 100% correct.

Good source: http://code.google.com/p/th9x/wiki/installation_de?wl=en-GB

BenQ M23 loosing network

If your BenQ M23 GSM module is losing network or doesn’t stay in the network you might have to register it to network with command:

AT+COPS=1,2,”24405″

Where 24405 is the “numeric format is the GSM Location Area Identification number which consists of a three BCD digit country code coded as in ITU-T E.212 Annex A[10], plus a two BCD digit network code, which is administration specific”.

You can get LAC number by commanding:

AT+COPS=?

(and wait for 10 seconds or so..)

Barometer units

1 atmosphere => 29.92 in Hg /760 mm Hg => 1.01325 bar => 1013.25 mb => 101.325 kPa => 1013.25 hPa

1 mb = 100 Pa = 0.1 kPa = 1 hPa = 0.0295 inches Hg = 0.75 mm Hg.

Source: http://www.islandnet.com/~see/weather/eyes/barometer2.htm