Friday, 26 July 2013

Design and Test

Testing, Day One.

It's been a while (a large part was waiting on parts - I'm looking at you Futurelec!) since I posted about my Alarm Monitoring system but as I've finally been able to get some build and test underway I thought I'd share the progress.  Which is a nice way of saying I'm not finished yet.

Step By Step

With this design I've incorporated a fair few new circuit blocks I haven't tried before, being:

  1. FET Current Limiter Circuit
  2. 4V, 3A (TWELVE WATTS BABY!) Switch Mode power supply
  3. AVR microcontroller (yes, never used 'em before)
So to start, I loaded only the power supply section before placing other parts.  This is a good practice when prototyping as if you stuffed something up, you don't blow up the rest of your board.  I've actually designed in zero ohm links on the power supply rails which could also prevent the same destruction but through experience I prefer to do it his way.

Zero ohm links are good for when you are setting up production boards.  You can adjust anything that needs adjusting in isolation before installing the links.

But for prototypes - Why load everything on your first prototype when a SNAFU in any area could make the whole exercise pointless?




Partially Loaded




Still Partially loaded.

First The Smoke Test

Initially, when powered up, no smoke.  YAY!

But my elation was short lived when as I measured the 4V and 5V rails on this board, I got bupkis.  My initial thoughts were that my current limiting circuit was doing it's job and that I might have a fault / short with the rails on the board somewhere.


Circuit Under Test

To check if the circuit was being current limited, you simply measure the voltage across R2, the shunt resistor.  I measured as near as practical to zero as to not make a difference, so I knew that it wasn't limiting. 

It just wasn't working.  Damn.

There's a big difference between fixing something, or making it from new.  When fixing something, you have the massive advantage that it used to work.  When building from new, you don't have that advantage.

Now, I was stumped.   I'd tested this idea before but not this exact configuration.  Time to start isolating bits to work out what the problem is.

The first thing I tackled was the FET (Q1).  Had I used this wrong?  To test it, I removed the BC807 and bingo, my rails sprang to life.  If I (via a short piece of wire) applied VIN to the node between R1 and R42, Q1 turned off.  So that part of the circuit worked, so what was the problem?

Avoid Reinventing the Wheel

When designing my projects, I often reuse parts that I've already used, even if they are less than optimal for the job.  This way I know the footprint is correct, I know I can source it in small quantities, and I know it *works*.

If you use Altium, you can develop your libraries as you go, and if I have any issues with a prototype I dive into the library and update the part so that the next time it's used, it's correct.

This time, I didn't do that.  

For the current limit circuit I needed to use a low power PNP transistor and I know and have used some BC807's in the past.  But this part wasn't in my current library.  So I searched my past projects, found where I used the BC807 and a quick copy - paste later it was in this design.  

So I'd broken my golden rule, and then I failed to check my own work.  I'd had this problem before, where I'd screwed up the pinmap.  Probably in the board I lifted the BC807 from in fact...



Q6 - Demon Child

Thankfully there was a simple fix - I just had to rotate the part and solder it down on it's now skewed pads.  


Q6 - Saved

I've used some screen shots from Altium to illustrate the issue - as in my board shot isn't that easy to see that transistor.



How I Broke It

If you look at this following extract from the BC807 datasheet, the pins are defined as 1 - 2 - 3 / B - E - C.


Extract from BC807 Datasheet


SOT-23 Footprint in Altium

Then compared with the footprint in Altium, there's agreement with how pads the pads are numbered.  I've come across footprints where the creator of that footprint has not arranged their pads in the same manner as the manufacturer.  So at this stage, it's looking okay.



Library Part Exploded

The issue however lies with the Schematic symbol.  Normally the pin designators and names are hidden.  I've turned the names and designators on in my above pic, and moved the pins out because the B C E labels overlap each other.

And there's your problem.  These pins 'map' to the footprint incorrectly.  

  • The collector pin goes to pad 1, not the base
  • The base pin goes to pad 2, not the emitter
  • The emitter pin goes to pad 3, not the collector

So I'd managed to place a forward biased diode junction across the shunt resistor and this turns the pass FET off. 

Pushing the Limits

As this isn't a work project, but a home project, I've not used as much rigour as I would professionally - I just wanted some hardware to play with quickly!

I'd designed my current limit to be 500mA, based on a 0.7V diode drop.  Strictly speaking, 0.7 V / 1.3 R = 0.538 A, but I knew it would be less than this as when the BC807 is saturated the diode drop is less than the  0.7 V specified in the datasheet.

The Datasheet Is a Lie

As I don't (yet) have a programmable constant current load I took to some more rudimentary testing.  With access to a LED strip that drew over 800mA at 12V, I had a load that could be used to force the current limit, but not be as brutal as a short circuit.



Bright Light!



Limiting.

With a 13.6V input (not an important value, just where the numbers stopped when I wound up the dial) the LEDs were limited to 420mA.  With the 1.3R shunt, that's 0.546 V across my shunt.  It works!

The PMV48XP FET used is rated to 3.5A.  But the caveat there is 'with adequate heatsinking'.


Derating Curve

The more a device heats up, the less current it can safely pass.  The only question is where does my target 500mA sit on this curve?

500mA is only 14% of the 3.5A maximum, but to be safe let's call it 20%.  Drawing a line across from the 20% point on the above curve, you get a junction temperature of well above 125 degrees Celsius.  It looks like this part will romp it in.  However, the junction is a tiny piece of silicon inside the SOT-23 package, and the case of the package can be much cooler than the junction.

So their is still a large question  as to how close to the limit my part is running.  I could have tried to measure the case temperature, and then using thermal resistance and heat sink calculations come up with an upper limit on the current.




.. or 15.1 Volts rather.

Turning the input voltage up to 15V resulted in a small dip in output current, followed by smoke from the PMV48XP


Smoke!


More Smoke!!

If you look around the solder joint on the top of the large inductor you can see some wisps of smoke. 400mA at 15V (or 6 watts) seems to be as much as I can get without resorting to heatsinking.  But to be fair that's a heck of a lot of power passing through a tiny SOT-23 package so I'm far from bummed.

How Much Power Do I Need?

A good question to ask now is just how much power do I need?  When I was designing this board I read that the SIM900 sinks current in 2A bursts, at 4V (8W), and took that figure and ran with it.  My switching circuit is over engineered with parts rated to deliver 3A, but I've throttled it with my current limiter that falls over above 6W. 

However, I didn't read the SIM900 data correctly.  The truth is that the SIM900 draws 2A bursts with a duration of 577us each 4615us (a duty cycle of 12.5%).  So rather than focus on the 2A Peak, I need a circuit that can deliver 240mA continuously (or close enough to 1W).  Yeah, my power supply can deliver that, I have a fat 1000uF cap to supply peak current to the SIM900 so I can lower the current limit and downsize my expensive inductor for something cheaper.  But I'll make a final decision on this once I finish this prototype.

From here I replaced the poor FET and moved on to other testing.

DTMF DECODE And Hook Detect





Green light = Good!

Although inspired by Lior's Alarmino I've done a few things a little differently.  Rather than sample the voltage across a shunt resistor to tell when a phone / alarm is off / on hook I use a comparator to send an active low signal to the micro when off hook is detected.

To test this, without a micro loaded, I simply placed a green led (and resistor) on the board controlled by the comparator's output.  After stetting the reference voltage, and plugging in a test telephone, the comparator was easily detecting on / off hook.  Yes!



Beep Bloop Bleep!

To check the DTMF Decode chip I plugged some LEDS into a breadboard, and connected acorss the two via some 6 core cable.  IT wasn't too hard to solder this cable to the MT8870 outputs and test.

And I'm glad that I did!  although the above shot shows DTMF decode taking place (some LEDS lit up) this wasn't the case initially.  My tones on the phone line were very low and DTMF decode was erratic.  This was weird as I had prototyped this before AND IT WORKED.


Prototype DTMF Decode

After some head scratching the penny dropped that there was a difference between this prototype and my design.  I'd use an active filter, rather than a lumped component filter, to keep costs down.

Spot the Mistake!

This filter is there to smooth out the harmonics of the square wave that we will get out of the micros' PWM output.  Although I was careful to AC couple the line and the DMTF chip, I'd not AC couple the output of the filter.  This meant that I was trying to drive the low impedance output of the opamp with the tones on the line, and this just attenuated the snot out of them.  The fix was as simple as adding a 100nF cap to the output of the filter to the line and all was good.

Believe it or not, but I try to take half way decent photos for my blog, but when your iPhone is your camera, they are never going to be great.  So I often take 3 or 4 shots and select the best for a post.  

I push the lot to my blog account and add them to posts as needed. What was cool though was some Google magic happened in the background and it realised that a bunch of my pics must the be photos of the same thing and automatically produced this animated GIF. 



Wiggle Wiggle

What was extra awesome is that i was decoding different DTMF tones while snapping these shots, and this animation shows this clearly. Woo Hoo!

At this stage I called it quits for the day - next time it's all about the trials involved in getting my AVR up and running.  Here's a hint.  I had to make this:



WTF?

You can follow the series here:

Cutting Out the Middle Man
Design and Test Part 1
Design and Test Part 2
Design and Test Part 3
Implemented.  Whoo Hoo!

5 comments:

  1. Nice work! I've been using the SIM900 a while now, and I've gotten quite fond of it! You couæd actually update the firmware on the module to detect DTMF tones and output them through the serial port. Just to save parts.

    Regards, Lerche

    ReplyDelete
    Replies
    1. That's interesting indeed. The beauty of a prototype is that I expect to build a final version later :) and to be able to reduce part count is a bonus.

      Delete
  2. I am guilty of that last hack as well:) I managed to mirror the pinout a few times with my boards.

    ReplyDelete
    Replies
    1. But wait.. there's more. Stay tuned for the next update.

      Delete
  3. Hello Simon,

    I'm Lior (dev of Alarmino). I really enjoy reading your posts, they're great!

    Couldn't find a "contact me" link on your blog, so I'm posting a comment here.

    My comment is that the 1000uF cap you're using to handle the SIM900's 2A spikes might be too small.
    These spikes' duration is 0.5mSec, and at 2A the voltage drop over a 1000uF cap would be 1V. This might drop the SIM900 voltage to about 3V which might be too low and cause it to reset. You may not detect this for a log time because the current drawn by the SIM900 depends on how close it is to the cellular tower, and it's probably lower than 2A most of the time.

    ReplyDelete