export PATH="/your/new/path:$PATH"
Category Archives: snippet
Naze32 / BaseFlight commands
My commands are (enable one-servo-cable-CPPM and do not start motors when armed):
feature ppm
feature motor_stop
save
More at:
https://github.com/multiwii/baseflight/wiki/CLI-Variables
http://www.rcmodelforum.com/showthread.php/175-(Acro)-Naze-32-Afro-mini-How-to-setup-and-tune-a-quadcopter
Manual: http://www.abusemark.com/downloads/naze32_rev3.pdf
Calculate roll / pitch from accelerometer values
float roll = (atan2(-accValues[1], accValues[2])*180.0)/M_PI; float pitch = (atan2(accValues[0], sqrt((float)accValues[1]*(float)accValues[1] + (float)accValues[2]*(float)accValues[2]))*180.0)/M_PI;
Auto eject on Ultimaker 1
Pin interrupts on Atmega 168 + 328 (Arduino)
From http://arduino.cc/forum/index.php?topic=80928.0
From http://arduino.cc/forum/index.php?topic=80928.0
/* * Theory: all IO pins on Atmega168 are covered by Pin Change Interrupts. * The PCINT corresponding to the pin must be enabled and masked, and * an ISR routine provided. Since PCINTs are per port, not per pin, the ISR * must use some logic to actually implement a per-pin interrupt service. */ /* Pin to interrupt map: * D0-D7 = PCINT 16-23 = PCIR2 = PD = PCIE2 = pcmsk2 * D8-D13 = PCINT 0-5 = PCIR0 = PB = PCIE0 = pcmsk0 * A0-A5 (D14-D19) = PCINT 8-13 = PCIR1 = PC = PCIE1 = pcmsk1 */ Setup: PCMSK2 |= (1<<PCINT23); PCICR |= (1 << PCIE2); PCMSK0 |= (1<<PCINT0); PCICR |= (1 << PCIE0); ISR(PCINT2_vect) ISR(PCINT0_vect) { code here }
MultiWii + Mongoose + Tricopter
If you’re using MultiWii at Mongoose-board you might wonder how to connect motors to pins.
Pinouts for tricopter:
Yaw Servo: MultiWii pin=3 = PD3 => Mongoose-pin:3
Front Left: MW=11 = PB3 => Mongoose-pin: spi-header (MOSI)
Front Right: MW=10 = PB2 => Mongoose-pin: 10
Rear: MW=9 = PB1 => Mongoose-pin: 9
RX ppm sum: mw=2 = PD2 (soldered straight to atmega328p)
See: http://www.fuzzydrone.org/2012/01/connecting-motors-and-radio-receiver-to.html
SimonK ESC .hex-files (download+avrdude)
Hint: you can find pre-compiled .hex files for all SimonK versions from here : https://github.com/sim-/tgy/downloads
To upload on OS X (for example Hobby King 30A ESC 3A UBEC):
avrdude -c usbasp -pm8 -U flash:w:/Users/xxx/Downloads/tgy_2012-09-30_0d3e617/bs_nfet.hex
Bandwidth throttling on OS X
Simple way to enable bandwidth throttling on OS X
sudo ipfw pipe 1 config bw 150KByte/s
sudo ipfw add 1 pipe 1 src-port 80
sudo ipfw pipe 1 config bw 20KByte/s
sudo ipfw add 1 pipe 1 dst-port 80
OpenSCAD 2D object that can be exported to DXF
// basic example of OpenSCAD that makes a plate that has holes in it
// you can export this to DXF because it makes 2D projection
module test()
{
// difference = first “object” is cut out with the rest of the objects
difference()
{
// union = all shapes inside union becomes one
// in this case this is the first object
union()
{
cylinder(r=30, h=3, center=true);
cube(size = [100,30,1], center = true);
}
// ok, let’s then punctuate the cylinder+cube combo with holes
for ( i = [0:10] )
{
rotate([0,0,36*i]) // rotate the “world”
translate([25,0,0]) // move away from the center
{
cylinder(r=2, h=5, center=true); // punch a hole
}
}
}
}
projection(cut=true) test();
Arduino Due performance on sin()
Tested running 100.000 sin() calls and it took 2594 milliseconds. That means you make call sin() at 38.55kHz. If you want to make 44.1kHz sound in real-time there’s no way you can use the sin() method.
Here’s the code I used
void SpeedTest()
{
float f = 1.23;
Serial.println(millis());
for (uint32_t i=0; i<10000; i++) { f=sin(f); f=sin(f); f=sin(f); f=sin(f); f=sin(f); f=sin(f); f=sin(f); f=sin(f); f=sin(f); f=sin(f); } Serial.println(millis()); Serial.println(f); }