Tuesday, 6 August 2013

Design and Test, The Third

Filter Testing and Options

IN THEORY

In my previous posts, I'd debugged my power supply, and got my Arduino Leonardo clone up and running.

I'm getting closer to finishing but there's still one functional block that I'd not yet tested and it's my active filter.  Again, a big hat's off to Lior for the inspiration behind my build, but I have done some things my own way.

For example I used a Sallen-Key low pass active filter to get a 1.5kHz Low Pass Filter.

Thanks to the internet, rather than hand crank the numbers, I used this on-line calculator from OKAWA Electric Design. From that design I whipped up this LT-Spice File.


LT-Spice Circuit (Active Filter)


You'll note that I added an input buffer (Voltage Follower) to my filter to help both decouple it from the output pin of the micro, and to give me a crude method of adjusting the 'gain' of my filter.  The ratio of R3:R4 sets the attenuation of the signal from the micro (a 5V square wave) - if the 'kiss off' signal is too large I can simply reduce it by altering R3 / R4 as required.

From there the simulation offered these results:


Output

The above shows the output of the 1.4kHz kiss off tone, after passsing through the filter.  THis isn't a bad result for a second order filter, even thought it isn't a pure sinewave.


FFT Plot


FFT Result

After running an FFT on the simulation, you get some nice hard numbers.  Using the cursor comparison tools, you can see that the second harmonic is down some 20dB from the fundamental. Note that for voltages dB is 20*log(v2/v1), so 20dB down is a signal 10% of the original.  Sweet!

TEST RESULTS

 Borrowing my mates TDS 2014B we were able to capture some real world results.


Testing Active Filter

The above screenshot shows that the time domain response is indeed similar to the Spice results.



FFT Screenshot


FFT with Cursors

From the FFT results you can see that the second harmonic performance is much better than the predicted 20dB down (-35dB!).  This is excellent.  Some deviation from the model is expected - for example the square wave rise time I've modeled as having zero rise and fall time which will produce lots of harmonics (as a square wave will).  However I've no idea how quick the Atmega is driving the signal - the slower rise time will alone reduce some of the harmonics, ut still getting an extra 15dB of attenuation is a great result.

COMPARE AND CONTRAST

Just for the sake of something to do at lunch at work, I ran a quick simulation of the circuit used by Lior for  a quick comparison.



Simulation



Time Domain


FFT


Harmonics - 2nd


Harmonics - 3rd

The results here aren't great - but Lior's own admission was he'd not optimised this design, and heck, it worked for him so good enough.  In fact, I used this filter in my first prototype and that also worked with my alarm.  I'm curious to see if I fed a straight square wave into my alarm panel if the alarm would be happy with that .... I'll leave that test for Ron.


For a quick experiment I decided to patch in my passive filter prototype and run the scope across it.


Stuffing Up the Tests


Weird Clipping

I guessed that as the filter was built from passive parts, I could just patch it in and measure it.  However, looking at the 'scope picture above you can see that the tops of the sine wave is clipped.  This is an unfair measurement as some diode in in my test board must be switching and corrupting my measurement.  As this distraction was now taking me away from testing my own interface I decided to stop there.



As a teaser, here's a quick video of something else in the pipeline.....

Getting Down To It



Fully Loaded!

So I finally have fully loaded all my parts.  Time to test if the SIM900 can talk and connect to the GSM network.  So I powered up and.... my 4V rail dissapeared.  Under-load, it dropped to a lousy 2V.  What?

Still Got The Power Supply Blues

When I was initially testing my supply, although I measured a 'working' 4V rail, I did notice that it took around 4 seconds to charge the 1000uF cap.  

Perplexed, I started to check my circuit against the application circuit in the LM2576 datasheet, and it checked out electrically.  So what had I done wrong?  

On the front page of the datasheet it states that the LM2576 runs at 52kHz, and the application circuit shows a 100uH inductor is required to store the magnetic field.  And there's the rub - the inductor needs to be 100uH at 52kHz.

For my prototype I used the Bourns SDR2207-101KL based on the fact that it's good for over 2A of continuous DC current.  So far so good.

However, reading the datasheet, the test frequency for this part is 2MHz.  Ferrite cores tend to be optimised for use at different frequencies, and tested at 2MHz suggests that this isn't a 52kHz part. Got it wrong again....

Smith Chart Results

Just to verify the theory the next day at work I chucked the inductor on the Network Analyser at work and and recorded the Smith Chart above.  Without going into theory of Smith Charts, the 50kHz marker shows a crappy inductor, the 1 MHz marker a good one.  

eBay to the Rescue

For another project, I picked up some Switch Mode regulator boards from eBay.  These boards use the LM2596 which is pin for pin compatible with the LM2576, but runs at 150kHz, and (more importantly) uses an inductor that's suited for the frequency of operation (also as the switcher is working at a higher frequency, the inductor can be lower in value - in this case 33uH).



Surgery!

So my dud circuit was stripped out and the eBay board wired in.  This time the 4V rail held up under load.   With that, Nick whipped up some test code, and our first hard-coded message was sent.



SMS SUCCESS!

So, finally, all the hardware checks out.  When time permits I'll strip the eBay switcher of it's parts and load them on my board, but for now it's time for code.  We need to:
  • Decode the Contact ID Protocols from out alarm panel
  • Identify which messages require sending and SMS and which do not
  • How a user is to programme options such as number of messages to send, and to what numbers
  • And a truck load of other things.  
And oh yeah, I need to fix up my board :)  But until I do that, if anyone wants one of my leftover boards from Seeed, hit me up (contact me now added to the Blog, thanks for the tip Lior!).

Once we have our working prototype code that will be posted - but happy to take advice / input from others.

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!

No comments:

Post a comment