The MPU6050 data sheet has a nice “marketing” section, claiming it has a DMP unit, and a couple of useful interrupts, among them a accelerometer event interrupt.

However, how to actually use these features is not documented there. And I want to use the Motion Detection Interrupt (so I can put the host MCU to sleep and wake it up when the MPU6050 senses motion – quite probably there’s a cheaper and better documented chip that can do this too, but I already bought a few MPU6050’s… “gy521” breakout board).

After power on (0x00 to register (decimal) 107), the Motion Detection Interrupt can be enabled as follows:

(optionally?) Reset all internal signal paths in the MPU-6050 by writing 0x07 to register 0x68;

write register 0x37 to select how to use the interrupt pin. For an active high, push-pull signal that stays until register (decimal) 58 is read, write 0x20.

Write register 28 (==0x1C) to set the Digital High Pass Filter, bits 3:0. For example set it to 0x01 for 5Hz. (These 3 bits are grey in the data sheet, but they are used! Leaving them 0 means the filter always outputs 0.)

to register 0x69, write the motion detection decrement and a few other settings (for example write 0x15 to set both free-fall and motion decrements to 1 and accelerometer start-up delay to 5ms total by adding 1ms. )

Translate the above into code for your favourite micro controller. (Or, maybe, the existing Arduino library for MPU6050 already supports this. I don’t know, I’m using STM32 this time. But it could be translated to AVR/PIC/MSP430 etc… as long as it has I2C/TWI)

Now, INT pin should go high when MPU6050 is moved/shaken/dropped. Play with threshold, duration and filter to set sensitivity.

The MPU-60X0 provides Motion detection capability with similar functionality to Free Fall detection. Accelerometer measurements are passed through a configurable digital high pass filter (DHPF) in order to eliminate bias due to gravity. A qualifying motion sample is one where the high passed sample from any axis has an absolute value exceeding a user-programmable threshold. A counter increments for each qualifying sample, and decrements for each non-qualifying sample. Once the counter reaches a user-programmable counter threshold, a motion interrupt is triggered. The axis and polarity which caused the interrupt to be triggered is flagged in the MOT_DETECT_STATUS register.

Like Free Fall detection, Motion detection has a configurable acceleration threshold MOT_THR specified in 1mg increments. The counter threshold MOT_DUR is specified in 1 ms increments. The decrement rate has the same options as Free Fall detection, and is specified in the MOT_DETECT_CTRL register.

The hollow core motors of a Cheerson CX-10 can actually be opened, and a new wire can be soldered to the brushes when the original one broke of.

This started as a challenge, me stating it was impossible to open these motors without damaging them beyond repair and my father insisting it is possible. So don’t ask me how to open them, I still think it is impossible. I only soldered the wire and closed it again. (Make a hole for the new wire by removing all residue of the old wire, remove part of the glue over the brushes, tin the new wire, then very quickly solder it, as to not overheat the plastic. Carefully press the back back on the motor again, making sure the brushes don’t bend in ways they are not supposed to)

And now my CX-10 is flying again. With a battery that’s slightly to large, a half-painted side to help orientation (Does not actually help), and rubber bands instead of screws holding it together. Also, half its props are pink because those where the last ones I had around. So its almost as ugly as possible, but it’s flying again. And that’s kind of crazy.

(And yes, I bought new motors just in case, and I still think this repair should be above my fine motor skills (pun intended) as everything is way to tiny and way to melt-able, but apparently its less impossible then I thought.)

This adds a echo to a wav file. The file also gets louder, because the result is not normalized. (sample + 0.8*Othersample v.s. sample+0.8*Othersample/1.8). This is my first real experiment with DSP. Maybe More Later(tm). Comments are welcome. (no registration necessary / pre-moderated by me)

Okay, what’s this about?Oona Räisänen challenged her readers to construct a whistle that could transmit data using FSK.

And if one reads her challenge carefully it says “whistle”. Not “pea whistle“. Now THAT simplifies things a lot!

A whistle design like this can be modified by inserting a magnet and wrapping a coil around it to act as an electromagnet. That way the length of the channel can be varied by moving the magnet, and with it the wavelength of the sound.

Then, by controlling the electromagnet with the bitstream – to – be – transmitted, one can transmit data by whistling.

It sounds like this. (that ticking/clicking noise when I’m not whistling is the magnet moving.)

I do not have the skill level that Oona has when it comes to decoding mystery signals, so I can’t decode the data out of that. I just hope the signal can still be decoded. But it is supposed to say “HELLO”, with leading 0xAA 0xA7. Bit time is 75ms, that is: for every “1” in the bitstream the electromagnet is powered for 75ms, and for every 0 it is left unpowered.

And because it is close to the new year, a bonus audio file for those among us that like to decode mystery signals: clicky. 🙂

Well, not really failed, since every result is a result. I just found a way how this does not work. Two in fact.

Okay, what’s this about?Oona Räisänen challenged her readers to construct a whistle that could transmit data using FSK.

So, I thought about replacing the pea in a pea whistle with a magnet, and then using an electromagnet outside the whistle to slow down (or stop) the pea’s movement during whistling. Since the pea modulates the whistles sound by blocking the “air exit” of the whistle when moving past it, slowing the pea down for a couple of revolutions should frequency modulate the whistle.

For another project I’m tinkering with an old computer power supply. While I’m at it, why not see if I can build some crude current limiting. It does not need to regulate the current neatly, as long as it is short circuit proof.

A LED on the 12V output of a computer PSU would normally be blown to bits. Such a power supply can furnish ridiculously large amounts of current, while a LED only needs 20mA and as a diode won’t self-limit this. The PSU in the picture is an old one, the 12V line is orange instead of yellow. (The 3V3 is brown.) The 12V can deliver about 7A, 350 times more than the LED needs.

Yet, in this picture, the LED does not break, because I added some current limiting circuit. How does this work?

WARNING: Do not try this at home. Or anywhere else. Or at least don’t blame me if you do anything stupid and/or electrocute yourself. There are dangerous (potentially lethal) voltages inside a computer power supply. I won’t tell you to disconnect it from mains and discharge primary capacitors before you work on it, you should know already or else leave the cover on. Put that screwdriver down!

Voltage regulation in a atx computer PSU is done via optocouplers. The controller IC, UC3842 (or similar) is after all connected to mains power.

On the secondary side of the supply a TL431 is used to send current trough the LED of an optocoupler when the output voltage of the PSU goes too high. The TL431 is used as a comparator (it is a programmable zener / shunt regulator / voltage reference). The other side of the optocoupler is connected to the uc3842 so it lowers its duty cycle and therefore the output voltage.

At danyk.cz schematics of computer power supply’s can be found. Go there to see the voltage regulator circuit (And all the protection circuits I removed from my PSU)

A crude form of current limiting is actually quite easy to make.

By connecting a second optocoupler with its transistor side parallel to the transistor of the first, the output voltage will go down if the led in the second optocoupler gets activated. For the UC3842 this is the same situation as when the output voltage goes to high. So now all I need is a circuit that activates the second optocouplers LED when the output current rises to high, and I have a crude form of current limiting.

This circuit is not that hard. Every resistor has a voltage drop if there is current going trough it. Ohms law. So the output current can easily be measured by putting a resistor in series with it. A sense resistor. Then a transistor that starts conducting when the voltage over the sense resistor surpasses 0,7V. Have the transistor drive the LED from the opto, and that’s the circuit.

For this test the sense resistor is 68Ohms. This would be a current of 0,7/68R=10mA. Because the voltagedrop over the sense resistor can be annoying it’s possible to connect the voltage regulation feedback after the sense resistor so it will compensate. I have not done that for this test.

In practice I won’t limit the current to 10mA, but more likely to 10A, and the sense resistor would be much smaller (0,068R).

But for this test it’s fun to light a LED with a computer power supply.

The current limit oscillates, causing the LED to flash, see video below:

If instead of the LED I connect my ammeter, the value fluctuates between 10 and 20 mA, but probably the peak values are further apart and the meter can’t keep up with the change.

But for short circuit protection this works fine. A big disadvantage however is that the fan in the PSU is on the same 12V line and also gets tuned down / turned off when current limit kicks in.

Because all the “modified computer PSU” project i’ve so far seen on the web only mess with the output voltage and not with the current limit, I decided to post this in both Dutch and English in the hope that it will be useful to anyone, however this idea comes with NO WARRANTIES whatsoever. Please note the rectified line voltage inside those supplies is potentially lethal and capacitors might remain charged to this voltage even when the supply is disconnected from mains. Do not attempt this unless you know how to safely deal with this. If you do attempt this, you do so at your own risk.

Please let me know if you see a similar project somewhere that also deals with current limit on a modified computer powersupply.