mitat.tuu.fi
500Hz Speed Controllers
Speed controllers that can handle 500Hz update or frame rate (instead of traditional 50Hz, that is 20ms frame):
TowerPro 9g w12A Brushless Speed Controller
TURNIGY Plush 10amp 9gram Speed Controller
@ electronics | measured
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
@ electronics | measured | snippet
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)
@ measured
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 = 0×000000 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
@ electronics | measured
Great way to keep your server in correct time with PHP
This really works. From here: http://www.xenocafe.com/tutorials/php/ntp_time_synchronization/index.php
#!/usr/bin/php -q
// ntp time servers to contact
// we try them one at a time if the previous failed (failover)
// if all fail then wait till tomorrow
$time_servers = array("time.nist.gov",
"nist1.datum.com",
"time-a.timefreq.bldrdoc.gov",
"utcnist.colorado.edu");
// date and clock programs (change for your system)
$date_app = "/bin/date";
$clock_app = "/sbin/clock";
// a flag and number of servers
$valid_response = false;
$ts_count = sizeof($time_servers);
// time adjustment
// I'm in California and the clock will be set to -0800 UTC [8 hours] for PST
// you will need to change this value for your region (seconds)
$time_adjustment = 0;
for ($i=0; $i<$ts_count; $i++) {
$time_server = $time_servers[$i];
$fp = fsockopen($time_server, 37, $errno, $errstr, 30);
if (!$fp) {
echo "$time_server: $errstr ($errno)\n";
echo "Trying next available server...\n\n";
} else {
$data = NULL;
while (!feof($fp)) {
$data .= fgets($fp, 128);
}
fclose($fp);
// we have a response...is it valid? (4 char string -> 32 bits)
if (strlen($data) != 4) {
echo "NTP Server {$time_server} returned an invalid response.\n";
if ($i != ($ts_count - 1)) {
echo "Trying next available server...\n\n";
} else {
echo "Time server list exhausted\n";
}
} else {
$valid_response = true;
break;
}
}
}
if ($valid_response) {
// time server response is a string - convert to numeric
$NTPtime = ord($data{0})*pow(256, 3) + ord($data{1})*pow(256, 2) + ord($data{2})*256 + ord($data{3});
// convert the seconds to the present date & time
// 2840140800 = Thu, 1 Jan 2060 00:00:00 UTC
// 631152000 = Mon, 1 Jan 1990 00:00:00 UTC
$TimeFrom1990 = $NTPtime - 2840140800;
$TimeNow = $TimeFrom1990 + 631152000;
// set the system time
$TheDate = date("m/d/Y H:i:s", $TimeNow + $time_adjustment);
$success = exec("$date_app -s \"$TheDate\"");
// set the hardware clock (optional) - you may want to comment this out
exec("$clock_app --systohc");
echo "The server's date and time was set to $success\n";
} else {
echo "The system time could not be updated. No time servers available.\n";
}
?>
@ code
Arduino & millis() – overflow
We know that the value of millis() rolls over after 49 days. You can write a hack to overcome with this but how to make sure it works, without testing your code for 49 days?
Here’s the trick. Modify the arduino core code so that millis() will actually roll over after 10 seconds from start. If your Arduino program overcomes that, it will probably do it again after 49 days.
Edit file /Applications/Arduino.app/Contents/Resources/Java/hardware/arduino/cores/arduino/wiring.c
.. And modify / replace:
#include
volatile unsigned long timer0_millis = ULONG_MAX - (1000*10);
@ electronics | snippet
sed
To replace content of file in unix / linux, use sed.
Basic use, first try outputting to terminal:
sed s/blue/black/ file.txt
you can then do either
sed s/blue/black/ file.txt > replaced.txt
or
sed -i s/blue/black/ file.txt
Last command makes changes directly to file.
If you need to use non-alphabetic-characters, use \ – char in front of them. For example:
sed s/file\.txt/nonfile\.txt/ filetoreplace
More, much more : http://www.grymoire.com/Unix/Sed.html#uh-8
Goodbye Spotify
After almost two years of paying premium account I’ve decided to detach from Spotify and start buying music in CD-format.
Why?
Spotify updates itself without asking user permission. There is no way to even turn it off from the application. Why it bothers me? It’s a serious security risk. Spotify can plant any code on my machine. Probably they won’t plant any harmless functionality but think about if someone breaks into Spotify’s update system? Too easy to distribute any kind of malicious code.
Spotify adds cluttering features and redesigns UI too often. In latest update Spotify was one click away from sending my local mp3’s to Spotify. Actually based on my first rant it could have done it automatically based on their attitude and respect on users.
Spotify doesn’t pay artist enough. Yeah, I know what you’re saying: artist can decide if they want to publish music on spotify or not. I wish it was that simple.
Spotify redirects all paying customers to ask in getsatisfaction.com but fails to answer to questions. I’m paying 9,99€ per month and I wish they would have bothered to answer to my concern there but no. I’m paying customer and I think I can demand customer service. But nada. And I’m not the only one, go ahead and look.
So thanks but no thanks. I try to stick to owning the music I want to listen and not walk in a leash of Spotify and follow their rules. It’s my money.
BPM to milliseconds
To get the milliseconds between bars when you know beats per minute, calculate the pause:
pauseTime = 60000/bpm;