Categorie archief: Uncategorized

How to enable Motion Detection Interrupt on MPU6050.

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).

http://www.i2cdevlib.com/devices/mpu6050#registers is a in progress development to reverse engineer how to use the DMP. It also has a very useful register map (Thanks!), that fills the gaps in the “RM-MPU-6000A-00” document. With that register map, and a slightly older data sheet that actually has the section 8.3 that’s referred to elsewhere (found at https://dlnmh9ip6v2uc.cloudfront.net/datasheets/Components/General%20IC/PS-MPU-6000A.pdf , but that URL seems like it might not stay.), I could figure out how to enable the Motion Detection Interrupt.

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.)
  • Write the desired Motion threshold to register 0x1F (For example, write decimal 20).
  • To register 0x20 (hex), write the desired motion duration, for example 40ms.
  • 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. )
  • write register 0x38, bit 6 (0x40), to enable motion detection interrupt.

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.

Relevant excerpt from the linked older data sheet (PS-MPU-6000A-00 Revision: 3.1) above:

8.3 Motion Interrupt
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.

HH! Comment section below is open (no login required) for questions & remarks!

Advertenties

Some short notes on the Lecroy9450 repair project

Because there is no big news yet, some short updates.

– Claude Schwarz pointed me to the Yahoo user group “Lecroy Owners group”, they have design files for a HHZ406 replacement. (Made by Dieter Frieauff). So maybe the ext. trigger input can be repaired as well.

– A service manual for this ‘scope (And others) can be found there as well, or alternatively here: http://www.ko4bb.com/manuals/index.php?dir=LeCroy (Or on elektrotanya.com – but that site is full of ads)

– NoTMS was caused by a missing “Vct”, I accidentally scratched trough this trace while placing the bottom cover. Took quite some time to find, then just a little wire to fix.

9450_scratchedVCT 9450_scratchedVCTFixed

– Thanks to Claude Schwarz (Again), I now have a third ADC card. So I now have spareparts, and if I get one of the 2 broken cards working again, a working 2ch 350Mhz / 400Ms/s (10Gs/s)  DSO. (Or rather: the Leidse Makerspace then has a 2ch 350Mhz DSO). The 3 ADC cards will hereafter be named “9450_3A Claude”, “9450_3A LMS-Broken” and “9450_3A LMS-Working”. (order shown in the picture, ltr: broken, Claude, working )

9450_3A ADCs

– I measured the power supplies on “9450_3A LMS-broken”. All are present. (-5V, -12V, 5V and +12V). Next up: reference voltages and tracing the signal path.

– Some more pictures:

lecroy_patchedOn some of the ADC boards, a 5V regulator is placed where others have just a cap.

lecroy_patched_2

This is another original patch (-5V regulator), both on “9450_3A LMS broken”. This board has no LeCroy repair stickers (shown below), but those patches were there when I got the ‘scope so I assume they are original.

Bot these 2 regulators and the -12V and 12V ones have the correct output voltages.

lecroy_repair

Lecroy Repair stickers on the timebase board. (This board is working fine) There are more of those stickers in the scope on other boards.

9450_errorlog

And the last one for today: The calibration error log. Chan2 has “9450_3A Claude” in this picture, but “9450_3A LMS broken” gives similar results. If I exchange the cards between the channels, ch1 gets the errors and ch2 is error-free. (The error-free channel has “9450_3A LMS working” in both cases).

‘ll keep you posted!

EDIT 2-7-2014:
“Next up: reference voltages and tracing the signal path.”

Measured on HMS403, seems to be OK. Also none of the ADC’s have stuck bits (did not log what bit connected to what line of the LA, but with no input all are 0, as long as there is no selftest / calibration running.)

Please note if you connect a logic analyser to these circuits they are negative logic (“1” is – 5V, “0” = 0V). As the 0V is connected to chassis ground, and your LA’s ground might also be (through the powersuply’s both connected to earth ground), use caution!

The scope does not do a memory test on boot up. I carefully removed one of the RAM IC’s to test this, and the scope does still show “ADC/TMS state working”.

So there might be something wrong with the memory. Fortunately this is normal TTL logic again.

EDIT 8-Aug-2014:
On slower sample rates this scope only uses 1 of its 4 ADC’s (per channel). On slower sample rates, the problem stays, 1 out of 4 points on the display (Maybe 1 out of 4 samples?) is out of line. So it’s not 1 of the 4 adc’s that’s broken (because it only uses one at that sample rate), but something in the memory or further in the data pad. The memory is also divided in 4 parts/banks, so it could just be… But for now I’m going to work on other projects for a while.

Please comment if you have any questions or suggestions!

433Mhz spraak transmissie experiment met 1-bit ADC

Toen ik dit las vroeg ik me af of met zo’n 1-bit ADC verstaanbare spraak te verzenden zou zijn met zo’n goedkope 433Mhz module. En dan liefst met een heel simpele quick and dirty 1-bit ADC gemaakt uit standaard onderdelen.

En dat blijkt te kunnen!

M’n adc is geen echte adc, er is geen kloksignaal en de “charge injector” is een simpel RC netwerkje. Maar het werkt. Min of meer.

Geluidskwaliteit is zoals te verwachten viel beroerd, maar spraak is net aan verstaanbaar. (Als je geen idee hebt wat er gezegd wordt versta je het waarschijnlijk niet – als praktisch communicatiemiddel is het dus niet geschikt. Maar als experiment erg leuk.)

Goed, dat vraagt natuurlijk om schema’s, foto’s en filmpjes.

1bitadc schema
Het schema

Ik gebruik een LM358, 2x1k,2x47k,1x470k weerstanden, 1n en 100n condensatortjes, een microfoontje en een 433Mhz zendmodule. Aan de ontvangende kant: ontvangstmodule,1k,1n,piezospeaker.

1bitadc breadbord foto 1
Opstelling op breadboard

Vooraan de ontvanger, achteraan de zender.

Hier werkt de zender met een microfoontje. Maar dan hoort m’n camera me natuurlijk ook direct praten, zonder al die draadloze rommel ertussendoor. Dus heb ik een 2e test gedaan met een opname afgespeeld vanaf m’n pocketpc.

1bitadc breadbord foto 2
De zenderkant, nu met audiosignaal uit m’n pocketpc.

Filmpjes (Youtube)

Dit is een filmpje van de eerste test. Ik zeg “Dit is een spraakverstaanbaarheidstest”, en test later nog van een wat langere afstand. Tussen de spraak door hoor je alle andere rommel op de 433Mhz band. Deze test is met het microfoontje.

Dit is een filmpje van de 2e test. Ik zeg “if I did not want to repeat this test for Dutch and English I would have said: gratis T-shirts in the shop” Bij deze test speel ik de audio af vanaf m’n ipaq.

Het zou mogelijk beter werken met een echte 1 bits adc ipv dit quick and dirty ding. Misschien valt ook de functionaliteit van het quick and dirty ding nog uit te breiden.
Mocht iemand dat doen hoor ik er graag van 🙂

Fixing a broken SD card slot.

Repair companies are completely right they don’t repair on this level of detail, but swap an entire board instead. Much easy-er.  But I don’t have spare boards lying around and I like a challenge, so…

A friend of mine had a defective digital camera, someone forced the sd card in the wrong way, with bent contacts as a result. His camera now refused to read or write the card. Reseating the card didn’t help. Taking the camera apart and bending those contacts back to their original shape did help.

After removing ~20 tiny little screws the camera looks like this:

camera open

Might look terrifying because of all those little ribbon cable flex PCB’s, but I was able to put it all back together (I’ve done this sort of thing before).

O, and a warning for those that want to attempt this: Every camera with a flash contains a high voltage capacitor that probably is still charged. Discharge this capacitor before doing further work on the camera! (Or just don’t try this at home). In the picture above it is the big cap labelled “photo-flash”. It was charged to 140V.

sd kaart slot

This is the removed SD card slot. Instead of replacing the SD card slot, I opened it up. It contains 2 little springs (held on pins) and a tiny little metal bar, that together with the plastic sled forms the mechanism that allows you to push on the sd card to pop it out. Those tiny parts can be seen in the top half of the picture.

sdslot_detailIn this detailed picture the bent pins can be seen. The second one from the top I already bent back, the one on the bottom broke when bending it to its original shape. So I had to either replace the entire SD card slot (Might be hard to find one with the exact same footprint, not to mention the mess de-soldering it would give on the PCB, with all these tiny components nearby), or find a clever solution.

So, I replaced the bent pin with a pin from a female pinheader connector, cut and bent to shape and soldered to the remains of the broken pin.

sdslot_fix

After re-assembling everything, the camera still refused the SD card. However, this time reseating the card helped and it could access the card again.

Parts cost: Near zero.
Labour: ~ 5 hours. Yes, that’s why repair companies can’t do this.

If I had to do this again it would cost less time, because now I know where all those hidden screws are. Still, it would take too much time if I had to do this commercially. But I repair for fun, to prevent waste and for the challenge of getting something broken to work again. This certainly was a challenge. Not on the intellectual electronic level, but on the fine mechanical skill level. And it was rewarding to get this camera to read (and write) its card again.

Boem! een blog.

Omdat ik m’n website zowat nooit bijwerk heb ik nu ook een blog, om dat eventueel wat vaker bij te werken. Niet gezegd dat ik dat ook doe natuurlijk…

Ik ben van plan hier wat elektronicadingetjes te schrijven voor degenen die daarin geïnteresseerd zijn. Lopende projectjes, losse flarden, etc. in een wat losser verband dan m’n site. Daar kun je ook op reageren: vragen stellen, becommentariëren, discussiëren, wat op m’n site niet kon.

VFD test

Alvast een kleine preview van het VFD display van m ’n L/C ESR meter. Het is de welbekende IV-18 en op de foto krijgt deze voeding uit m’n labvoeding om alle segmenten te doen oplichten.

In de L/C/ ESR meter wordt dit VFD aangestuurd met losse transistoren (34 stuks maar liefst), en krijgt het voeding uit een simpel 3-transistor SMPSje (Aangepast van een ontwerp van Roman Black , de 3e transistor vervangt de zener). De aansturing komt uit een atmega328 via een stel 4094 schuifregisters.

Meer over dit project in een volgende post.