Categorie archief: experiments

[fixed] TM1637 LED display “not working”.

Last week I got 2 of these displays from a friend who couldn’t get them to display anything. (He knows I like those challenges.) Above picture proves it now works.

What was the case:

The data sheet says (e.g. in the schematic at page 8) a 100pF capacitor should be placed on CLK and DIO lines to GND.

verbatim quote from the data sheet: “100pF capacitor connected to the DIO, CLK communication port pull-up and pull-down can reduce interference to radio communications port.”

The capacitor is probably meant to reduce the signals rise time and thus reduce high frequency harmonics.

On the PCB, a 10nF capacitor was present, and that’s the cause of the display not functioning, just like overly long connections would cause this (when the wire length itself adds to much capacitance)

So, for those of you who bought one of these displays on Aliexpress, DX, or ebay, try removing those 2 capacitors (Or replacing them with 100 pF) if the display doesn’t work.

lowres_tm1637_desolderCsOnDioAndClk_circled
remove those 2 capacitors or replace them with 100 pF

 

Advertenties

[gefikst] TM1637 LED display “doet niks”.

Afgelopen week kreeg ik 2 van deze displays van een vriend die ze niet aan de praat kreeg en weet dat ik van dergelijke uitdagingen houd. Op bovenstaande foto het bewijs dat het inmiddels gelukt is het displaytje wél aan de praat te krijgen.

Wat was het geval:

In de datasheet staat (o.a. in het schema op blz. 8) een condensator van 100pF op de clock en datalijn naar gnd.

Letterlijke quote uit datasheet: “100pF capacitor connected to the DIO, CLK communication port pull-up and pull-down can reduce interference to radio communications port.” Het zal waarschijnlijk de bedoeling zijn met deze condensator de flanken van het signaal minder stijl te maken en zo minder hoogfrequente harmonischen te hebben.

Op de PCB zat echter een condensator van 10 nF, en dan werkt het niet meer, net zoals het niet meer werkt als de verbindingen te lang zijn (De draden zelf voegen dan dusdanig veel capaciteit toe).

Dus, mocht u/je een van deze displays gekocht hebben bij een van de vele aanbieders op ebay / Aliexpress, en het werkt niet, probeer dan eens deze 2 condensatortjes (van CLK en DIO) te verwijderen.

lowres_tm1637_desolderCsOnDioAndClk_circled
Verwijder deze 2 condensators of vervang ze door 100 pF

 

 

Fixed: RC522 RFID reader not reading (some) cards (Part 1)

Some of the RC-522 RFID card reader modules that can be bought on ebay / aliexpress have a problem: they do not read all (types of) cards they should be able to read. In this blog post I want to explain how to recognize these faulty readers and how to fix them. (There is a more detailed post in Dutch)

rfidadvertentiefoto
RC522 module (picture source: generic advertisement)

Choosy Cardreaders

Lets start at the beginning:
At MakerSpace Leiden those RFID-RC522 card readers are used in the access-system and AC-node system. Participants of the MakerSpace can scan their cards to get access to the MakerSpace (access system) or to enable power to heavy machinery that requires training (After completing the training ; AC-node system).

Most use their OV-chipkaart. (Public transport card, Oyster card for UK readers).

The problem that surfaced is that some of the RC522 card readers won’t read some cards (Including the OV-chipkaart).

That’s obviously a problem when the door won’t open or the machine won’t start, or your project using those card readers doesn’t work with all the cards it should be working with. Lees verder Fixed: RC522 RFID reader not reading (some) cards (Part 1)

Opgelost: RC522 RFID lezer leest (sommige) kaarten niet. (Deel 1)

Ik heb een probleem (mede-)ontdekt met de RC522 rfid kaartlezer modules die op ebay / aliexpress en dergelijk aangeboden worden: ze lezen sommige kaarten niet. In deze blogpost wil ik uitleggen wat het probleem is, en hoe het opgelost kan worden, in de hoop dat mensen die hetzelfde probleem tegenkomen daar wat aan hebben.

rfidadvertentiefoto
RC522 module (foto uit advertentie van verkoper)

En omdat het anders een erg droog stuk tekst wordt, schrijf ik halverwege een stuk onzin over een zomerjurk. (Want dit is mijn blog, en niet mijn scriptie :P)

Kieskeurige kaartlezers

Laat ik bij het begin beginnen:
Bij MakerSpace Leiden worden deze RFID-RC522 kaartlezers gebruikt om toegangskaarten te lezen in het deursysteem en bij de zwaardere machines waarvoor training nodig is. Deelnemers van de MakerSpace kunnen daarbij hun OV-chipkaart (Of een andere 13,56Mhz RFID kaart die ze al hebben) gebruiken. Ze kunnen dan deze kaart gebruiken om toegang te krijgen tot de MakerSpace, of om b.v.  (na relevante training en goedkeuring) de cirkelzaagtafel in te kunnen schakelen.

Het probleem dat daarbij boven water kwam, is dat sommige RC522 kaartlezers sommige kaarten niet lezen. (Wat voor de (on)nodige frustratie zorgt als het toevallig je eigen kaart is bij de lezer van de deur waar je door wilt… Of het is de kaartlezer van het project waar je mee bezig bent…)

Lees verder Opgelost: RC522 RFID lezer leest (sommige) kaarten niet. (Deel 1)

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!

Fine motor skills?

I did not know this was possible.

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.

IMG_7643_holowcoremotor

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)

IMG_7642_holowcoremotor

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.

cx10

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

Python echo

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)

"""
Echo. Usage: python_Echo InpuFile.wav OutputFile.wav Delay_in_Seconds
0.15 seconds gives a believable echo. Pass a file multiple times trough it or modify source for multiple echo's

Only works with 1ch WAV files. To be improved Later(tm).
"""
import sys
import numpy as np
import wave
import struct

if len(sys.argv) != 4:
        print "Usage: python_Echo InpuFile.wav OutputFile.wav Delay_in_Seconds"
        exit()
        
delay = float(sys.argv[3])

if delay > 2:
        print "weirdly long delay. Try < 2"
        exit()
        
w= wave.open(sys.argv[1])
framerate = w.getframerate()
frames = w.getnframes()
channels = w.getnchannels()
width = w.getsampwidth()
print("sampling rate:", framerate, "Hz, length:", frames, "samples,",
"channels:", channels, "sample width:", width, "bytes")
    
data = w.readframes(frames)
sig = np.frombuffer(data, dtype='<i2').reshape(-1, channels)

echo_output = wave.open(sys.argv[2], 'w')
echo_output.setparams((channels, width, framerate, 0, 'NONE', 'not compressed')) #output file matches input file params

values = []

for i in range(0, frames):
        if i > delay*framerate:
                value = sig[i] + 0.8*sig[i-delay*framerate] #add echo
        else:
                value = sig[i]
        packed_value = struct.pack('h', value) #this failes for 2 channel files.
        values.append(packed_value)

value_str = ''.join(values)
echo_output.writeframes(value_str)

outsig = np.frombuffer(value_str, dtype='<i2').reshape(-1, channels)

echo_output.close()
print "done"

Used sources:
https://docs.python.org/2/library/wave.html
http://stackoverflow.com/questions/2060628/reading-wav-files-in-pythonhttp://soledadpenades.com/2009/10/29/fastest-way-to-generate-wav-files-in-python-using-the-wave-module/

And something about DSP from a dead-tree book.

Continued “data transmission whistle” experiment, more successful this time

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.

So, I built such a whistle (Dutch). With a simple arduino sketch and a mosfet it is indeed possible to transmit data by whistling.

Datatransmission by whistle

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

(Failed) Pea whistle experiment

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.

pea whistles Lees verder (Failed) Pea whistle experiment

ATX computer power supply current limit.

(This post is also available in Dutch)

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.

ledopatxpsu

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.

IMG_6466_psuproject_curlim_schematic

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.