Sunday, 13 September 2015

Hacking an electronic price display (work in progress)

Somehow I found one of this tags (dont ask) and decided to crack it open to see what is inside. This is how it looks like:

I cant tell much about the epoxy blob, the e-ink display though is a WF021-01, you can find its datasheet here. According to that document you can find all the interesting einkn pins in the printed circuit test pads, here is the list:

bs1  -> tp11
res  -> tp10
d/c  -> tp8 
busy -> tp7 
cs   -> tp6 
  d0   -> tp5   
d1   -> tp4 
vddi -> tp1 

I am using an arduino to talk to the eink display, the code I am using is here

So far I can make it flash when I disable the change pump but that's it. When I try to send an image the busy flag gets signaled and it remains that way. Any ideas are welcome!

Tuesday, 23 June 2015

Simple nodemcu module to drive a nokia LCD (PCD8544)

I desperately wanted to hook a Nokia5110 LCD to my nodemcu. I wrote a LUA module but it was slow and it was taking too much memory, mainly because the font data needs to stay in the precious RAM.

It looks like anything I do ends up taking too much memory, so the way to go is to write modules in c and then invoke them from LUA. I am very pleased with the results, so here it is for you to use: Download (just for fun the lua module and the image are also included)

You can use it this way:
  • pcd.init()
  • pcd.locate(0,0)
  • pcd.print("Hello world!")
And if you want to display images you can do it this way:
  • pcd.init() 
  •"image.bin", "r") 
  • pcd.printbin( 
  • file.close()
I already sent a pullrequest to the nodemcu guys, it may not get accepted as the pins needed are hardcoded :/ 

Saturday, 5 October 2013

Software defined FM radio transmitter (Arduino + AD9850)

This video shows it all, take it away!

The frequency is generated by the AD9850 and the modulation is done by the arduino

The full code is here:

The FM band channels are centered at certain frequency, in our case 90Mhz, any slight deviation of that freq (by a max of +/- 75Khz) will move the membrane of the speaker backward or forward, here is the bit of code that implements that. And this is the (unoptimized) modulation routine.
void playTone(unsigned int note, unsigned int duration ) 
  const double freq = 90 * 1e6; // transmitting at 90Mhz

  // play silence 
  if ( note == 0)
  unsigned long currentMillis = millis() + duration;
  while( millis()< currentMillis)
      ad.setfreq(freq + 75e3/2); // speaker's membrane backward
      ad.setfreq(freq - 75e3/2); // speaker's membrane forward

  ad.setfreq(freq );

Credits go to:
Brett Hagman for the RTTTL tune player
Poul-Henning Kamp for the AD9850 lib

Friday, 5 July 2013

Minimal ECG using an Arduino and Xoscillo

First off, the picture :)

To display the wave I am using XOSCILLO, a very cool and open source tool (which I wrote :P) that converts your Arduino into an oscilloscope.

Circuit diagram

Here is the scheme, I am using the typical instrumental amplifier(ins amp) and then another op amp to get some more gain. An ins-amp is like an op-amps but with a huge CMRR, I am using a AD8221 which comes in a tiny small package, it's lead pitch is only 0.65mm, if you want to know what I did to create a simple breakout board please follow this link.

I'm using a single supply for the amps that comes from the arduino 5V pin, and I am creating a buffered virtual ground, this is really important.

Here is, a bit dark, a pic of the setup in the breadboard.

Tricks of the trade:

This is what makes the difference between a working ECG and a non working one :)

The main problem is that the device is so sensitive that it get interference from almost everywhere, specially the mains hum at 50hz). As you can see I got a clean signal, and I am not using any kind of serious filtering, note that xoscillo has a low pass filter and I am not even using it, so what are the tricks?

  1. Run it from a laptop and unplug the charger!
  2. Don't use a second monitor, the HDMI port will cause all sorts of high frequency interferences
  3. Get about 1 meter away from the laptop
  4. Buy some serious ECG electrodes, mines are "H124SG * Ø 24 mm", they come in a box of 50 and should cost about 11 euros. 

That's all, if you like it or build it or need help feel free to write a comment, it will encourage me to write more articles :)

Saturday, 22 June 2013

Poor man's MSOP soldering

MSOP stands for Mini Small  Outline Package, that means that width of 4 leads is just 2mm, exactly the width of a row in a stripboard... Let see how can we solder that though.

On a piece of wood we tape carefully 4 thin wires. We start my taping one wire and then taping again a second one at a distance of 2mm, take as much time as you need, this step is crucial, place on top the MSOP to make sure they have the right separation. If you need to make any adjustments use the blade of a cutter to move the wire. Good now you have the top one and the lower one. For the 2 inner ones, just put them in between and fix them with tape, then use the cutter blade to make sure they are all spaced equally

We place the MSOP on top and we tape it, then make the necessary adjustments in the separations of the wires. Once we are happy we tape the IC this time more tightly.
 Time to solder, use flux and apply the iron firmly as with any other SMD
Once we have one side done we do the other side, this time it will be easier since the other half is firmly fixed, time to correct the separation of the wires too.
 Once we remove the tape we check the back of the IC to make sure all looks good and clean.
 We cut the thin wires by just applying some firm vertical pressure with a cutter.

 Time to  place it on the stripboard, we carefully separate the wires and we insert them through the holes,
 And voila, the breakout board :)

Tuesday, 26 February 2013

Measuring inductances using an arduino

I just read this excellent article about measuring inductances:

The technique consists in measuring the resonance frequency of a LC circuit. Since this frequency is:

f = 1.0/(2.0*M_PI*sqrt(L*C))

By measuring f with the arduino and knowing C you can easily get L.

I modified the code so its much more precise, the original code is using 'pulse' to read half an oscillation. My code instead measures one whole oscillation by using an AVR's hw feature called Input Compare, this feaure starts and stops a timer that runs at 16Mhz.


//measuring inductance using the higher precision input compare  
//based on  
//capture Flag  
volatile uint8_t Flag;
void InitTimer1(void)
    //Set Initial Timer value  
    TCCR1A = 0;
    TCCR1B = 0;
    // Input Capture Noise Canceller  
    TCCR1B |= (1 << ICNC1);
    //First capture on rising edge  
    TCCR1B |= (1 << ICES1);
    //Start timer without prescaller  
    TCCR1B &= ~ ((1 << CS12) | (1 << CS11) | (1 << CS10));
    TCCR1B |= (1 << CS10);
    //Enable input capture and overflow interrupts  
    TIMSK1 = 0;
    TIMSK1 |= (1 << ICIE1) | (1 << TOIE1);
    Flag = 0;
volatile uint16_t Capt;
volatile uint16_t T1Ovs2;
//capture ISR  
    if (Flag == 0)
        //reset overflows  
        TCNT1 = 0;
        T1Ovs2 = 0;
    else if (Flag == 1)
        Capt = ICR1;
        //disable capture and overflow interrupts
        TIMSK1 &= ~ ((1 << ICIE1) | (1 << TOIE1));
        //clear pending interrupts  
        TIFR1 = (1 << ICF1) | (1 << TOV1);
    //increment Flag  
//Overflow ISR  
    T1Ovs2++; //increment overflow counter  
//13 is the input to the circuit (connects to 150ohm resistor)
//8 is the comparator/op-amp output.   
// for guide  
double pulse, freq, inductance;
//insert capacitance here. Currently using 2uF  
double capacitance = 2E-6;
void setup()
    pinMode(8, INPUT);
    digitalWrite(8, LOW);
    pinMode(13, OUTPUT);
    Serial.println("Why hello!");
void loop()
    digitalWrite(13, HIGH);
    delay(10); //give some time to charge inductor.   
    digitalWrite(13, LOW);
    delayMicroseconds(15); //make sure resonance is measured  
    delay(100); // wait for ICR to read once cycle  
    pulse = (T1Ovs2 * 65536 + Capt) / 16.0;
    if (pulse > 0.1)
        freq = 1.E6 / pulse;
        inductance = 1. / (capacitance * freq * freq * 4. * 3.14159 * 3.14159);
        inductance *= 1E6;
        Serial.print("High for uS:");
        Serial.print("\tfrequency Hz:");
        Serial.print("\tinductance uH:");

Sunday, 3 February 2013

SMD if there is a will there is a way

I couldn't wait for my breakout boards to arrive! I hope this encourages others to do some smd soldering... I used some rosin soldering flux from radio shack and a regular solder.

SMD breakout board