Wednesday, January 23, 2013

compiling and running coffeescript from within python

Running javascript from within python is already very easy using pyv8, the python wrapper for google's V8 javascript engine, like e.g. used within the Chrome browser.

On the other hand Coffeescript is a cool little language that compiles into javascript. I like it a lot more then javascript :)

I want to work with coffeescript from within python, without calling external tools.

The complication is that pyv8 provides a strict javascript environment. On the other hand coffeescript uses node.js and assumes all of it's libraries are available. (e.g. file I/O)

As the file I/O is not needed for my purpose, I just commented out the parts from the coffeescript code that use it.

The main missing part is the 'require' directive coffeescript uses from node.js, but which is not available when using plain V8 javascript. This can quite trivially be implemented in python.

However, this is still not enough, because of the way the functional wrapping is implemented in the javascript coffeescript generated for itself (coffeescript is written in coffeescript!) I had to change that generated code to explicitly return the "exports" object towards the caller of "require" because it would just return null by default. (+ a couple of other minor hacks here and there)

Here is all the python code:

 1 #!/usr/bin/env python
 2 #
 3 # (c) 2012 Joost Yervante Damad <joost@damad.be>
 4 #
 5 # License: CC0 http://creativecommons.org/publicdomain/zero/1.0/
 6 
 7 import PyV8
 8 import os.path
 9 
10 class Global(PyV8.JSClass):
11 
12     def __init__(self):
13       self.path = ""
14 
15     def require(self, arg):
16       content = ""
17       with open(self.path+arg+".js") as file:
18         file_content = file.read()
19       result = None
20       try:
21         store_path = self.path
22         self.path = self.path + os.path.dirname(arg) + "/"
23         result = PyV8.JSContext.current.eval(file_content)
24       finally:
25         self.path = store_path
26       return result
27 
28 def make_js(coffee_script_code):
29   with PyV8.JSContext(Global()) as ctxt:
30     js_make_js_from_coffee = ctxt.eval("""
31 (function (coffee_code) {
32   CoffeeScript = require('coffee-script/coffee-script');
33   js_code = CoffeeScript.compile(coffee_code, null);
34   return js_code;
35 })
36 """)
37     return js_make_js_from_coffee(coffee_script_code)
38 
39 coffee_script_code = """
40 yearsOld = max: 10, ida: 9, tim: 11
41 
42 ages = for child, age of yearsOld
43   "#{child} is #{age}"
44 return ages
45 """
46 
47 js_code = make_js(coffee_script_code)
48 
49 print js_code
50 
51 with PyV8.JSContext() as ctxt:
52   print PyV8.convert(ctxt.eval(js_code))


This is the output javascript from running the script:



 1 (function() {
 2   var age, ages, child, yearsOld;
 3 
 4   yearsOld = {
 5     max: 10,
 6     ida: 9,
 7     tim: 11
 8   };
 9 
10   ages = (function() {
11     var _results;
12     _results = [];
13     for (child in yearsOld) {
14       age = yearsOld[child];
15       _results.push("" + child + " is " + age);
16     }
17     return _results;
18   })();
19 
20   return ages;
21 
22 }).call(this);
23 

And this is the result of the execution of the coffeescript:
['max is 10', 'ida is 9', 'tim is 11']

fun!

Monday, October 15, 2012

on demand and configurable Arduino HardwareSerial

At some point you want to tune a hardware serial interface. Typically to increase the receive buffer size because the sender sends fast and you need some time to do other stuff then just receive data.

Sometimes you don't use the serial interfaces at all, or only use it for sending short debug messages.

In all those cases you're potentially wasting quite a bit of RAM as Arduino always instantiates all available serial interfaces with the fixed buffer size of typically 64 bytes.

I thought it a fun little coding challenge to adapt the Arduino HardwareSerial code to use C++ template parameters. Those parameters can then be used to instantiate the HardwareSerial only when you need it and only with buffer sizes you want.

It turned out quite simple, and the following basic example Arduino sketch illustrates the principle:


 1 /* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil -*- */
 2 
 3 /* (c) 2012 Joost Yervante Damad <joost@damad.be> */
 4 /* License: GPL3+ */
 5 
 6 static HardwareSerial<HARDWARE_SERIAL, 0, 16> MySerial;
 7 
 8 void setup()
 9 {
10   MySerial.begin(31250);
11 }
12 
13 static uint8_t c = 0;
14 void loop()
15 {
16   delay(50);
17   ++c;
18   MySerial.write((char)c);
19 }

In line 6 I instantiate the HardwareSerial instance. It has 3 template parameters:

  1. HARDWARE_SERIAL: this indicates we want the first hardware serial of the microcontroller. This is used to differentiate the underlying ports, etc at compile time. On an Arduino Mega you could also use HARDWARE_SERIAL1, HARDWARE_SERIAL2 or HARDWARE_SERIAL3.
  2. 0: This is the receive buffer size. In this case it is 0 meaning we don't want to receive anything and won't waste any bytes on a buffer. As an added bonus the interrupts for receiving will not be enabled.
  3. 16: This is the transmit buffer size. The test program is only sending single bytes, so we could even use 1 here!
I like how it turned but I fear it is a bit too complex to be part of the official Arduino tree.

The code can be found in github at:



Friday, October 12, 2012

software serial, a possible alternative implementation

(All code on this page is (c) 2012 Joost Yervante Damad and licenced under the GPL version 3)

Everybody at some point at least temporary needs more serial interfaces  on their Arduino/ATMega/... micro-controller.
The usual solution is to use the software serial library. The existing implementations have some serious limitations so I'm working on an alternative solution.

First let's have a look at the existing ones and their features and limitations.

Before Arduino 1.0 there was a version which I will call "Old Software Serial".
Starting with Arduino 1.0 a library called "New Software Serial" was integrated.

Old Software Serial


This was written in 2006 by David A. Mellis.

Sending is done via setting the transmit pin HIGH and LOW and  the timing of the bits is done by means of the "delayMicroseconds" call which does busy looping.

Receiving is done by calling the "read" function which will busy wait for the start of the byte and then read the bits where the timing between the bits is again done via delayMicroseconds.


It does not use any interrupts.


This works but has severe limitations:

  • sending data keeps the CPU busy
  • receiving data also keeps the CPU busy
  • if your program is not actively reading at the right time you will loose bytes
  • only one instance can be active at once as reading is done in the main program

New Software Serial


This started it's life as AFSerial done by Lady Ada from Adafruit industries. It was then picked up by Mikal Hart from Arduiniana and there were bugfixes and improvements by various other people (Paul Stoffregen from the Teensy, ...) In Arduino 1.0 it was integrated as the "SoftwareSerial" library.

Sending works basically the same as in the Old Software Serial.

Receiving is interrupt based.
The receive pin is registered for pin change interrupts. This means every time the pin changes from LOW to HIGH or the other direction an interrupt is called.
In practice when a pin change happens and it is a HIGH->LOW transition this indicates a start bit and then the byte is read by means of short delays implemented via a busy loop. The byte is then inserted into a circular buffer. Reading from the main program just reads from that buffer.

The big improvement here is that reading does not require blocking the main program. 

This works better then the Old Software Serial but also has limitations:
  • sending data still keeps the CPU busy
  • it only supports one active receiver; you have to change the active receiver with the listen() call if you have multiple instances of SoftwareSerial (this is actually a limitation caused by how reading a byte works)
  • reading a byte BLOCKS busy looping within the interrupt handler
That last in particular is quite nasty. It means that while the library is reading a byte, no other interrupts can be handled. This Includes interrupts for a receive of another software serial instance or even another hardware serial interface! Normally the goal should be to have interrupt handlers do as little as possible.

JD Software Serial


Giving comments on other people's code is easy so let's put my money where my mouth is and try to come up with a better solution.

For now I'm focusing on the receive part, for the sending part I have some ideas about as well, but that is not that important as sending doesn't block interrupts and people expect it to be synchronous.

The basic idea is to also use the pin change interrupt, but instead of blocking to read an entire byte, look at the HIGH->LOW and LOW-HIGH transitions and the timing of when they happen and find out the bytes like that.

This approach also has some shortcomings and caveats, I'll get to that later.

A first try


First I'm going to write a simple interrupt handler that just puts the transitions in a 32bit circular buffer annotating each bit with it's timestamp. All this code is not optimized it is just to do some playing with the concept.

The type for the buffer and data fields for the interrupt:

 1 typedef uint32_t stamp_t;
 2 typedef struct {
 3   bool rise;
 4   stamp_t timestamp;
 5 } bitchange;
 6 static bitchange bitchanges[32] = { { 0,0 } };
 7 static int datapos = 31;
 8 static int freepos = 0;
 9 static volatile uint8_t * receivePortRegister = 0;
10 static uint8_t receiveBitMask = 0;

The interrupt handler:

 1 inline void handle_interrupt()
 2 {
 3   // if our bit change buffer is full, just drop this bit
 4   if (datapos == freepos) { return; }
 5   const uint8_t pin_data = *receivePortRegister & receiveBitMask;
 6   bitchanges[freepos].rise = pin_data > 0;
 7   bitchanges[freepos].timestamp = mytimer();
 8   freepos = (freepos + 1) & 31;
 9 }
10 
11 ISR(PCINT0_vect)
12 {
13   handle_interrupt();
14 }

The mytimer() function uses the timer0 facility which is already in use by the Arduino core. It uses the lower 24 bit of the timer0 overflow counter together with the fast changing content  of the TCNT0 register.

1 extern unsigned long timer0_overflow_count;
2 static inline stamp_t mytimer() {
3   const stamp_t ov = (timer0_overflow_count & 16777215l) << 8;
4   const uint8_t t = TCNT0;
5   return ov+t;
6 }

My setup uses two Arduino boards. Arduino one is sending a 'U' every second on it's TX pin, meaning it is using the hardware serial. It is clocked at 31250 baud.
That TX pin is connected to pin 2 on the second Arduino. The second arduino is connected with it's normal serial interface to a PC via USB at 115200 baud.

The setup. On the left the sender, on the right the receiver. Data is going via the green wire.


To get started I just look at the bit transitions in a busy loop.

 1 void loop()
 2 {
 3   if ((datapos + 1)%32 != freepos) {
 4     const bool rise = bitchanges[datapos].rise;
 5     const stamp_t timestamp = bitchanges[datapos].timestamp;
 6     ATOMIC_BLOCK(ATOMIC_RESTORESTATE) {
 7       datapos = (datapos + 1) & 31;
 8     }
 9     Serial.print(timestamp); Serial.print(' ');   Serial.println(rise?'1':'0'); 
10 }

That works fine. Evert time it sees a byte it prints:

11835708 1
12085644 0
12085652 1
12085660 0
12085668 1
12085676 0
12085684 1
12085692 0
12085700 1
12085708 0

First line is the stop bit of the previous byte.
Second line is the start bit of this byte.
The remaining lines are the data bits.
The data bits give 10101010 which is LSB (Least significant bit) to MSB (most significant bit) meaning it represents 01010101 which is 0x55 which is 85 decimal which is the character 'U'. Now the reason I'm using that particular byte is that it has an edge on every bit, which makes it an easy case.

In general there are a couple of special cases:

  1. two or more times the same bit in one byte
  2. initially starting out in the middle of a byte
  3. ending with one or more HIGH bits meaning there is no stop bit interrupt
1 is easy to fix: just look at the time-stamps and insert extra bits with the previous bit value. The amount of bits can be determined from the difference of the current time-stamp and the previous time-stamp.
2 just implies that we need to be clever in trying to find the start bit in an existing stream.

3 is the tough one. The solution I'm implementing is that when a start bit is received and I was actually still expecting a data bit the remainder of the bits are filled with HIGH because that is what they might be.
However that does mean that the byte is only known when the next byte starts, which could be quite late. In practice though for the typical ASCII values this is not an issue as the MSB is 0, and the stop bit is always seen.

Get those bytes


Let's give decoding the bytes a stab. After quite some testing/tweaking I came with the following test code that nicely dumps the received byte and works for the whole 0 till 255 (0xFF) range:

 1 void loop()
 2 {
 3   if ((datapos + 1)%32 != freepos) {
 4     // first get data out of array
 5     const bool rise = bitchanges[datapos].rise;
 6     const stamp_t timestamp = bitchanges[datapos].timestamp;
 7     // only then update datapos to avoid getting overwritten data
 8     ATOMIC_BLOCK(ATOMIC_RESTORESTATE) {
 9       datapos = (datapos + 1) & 31;
10     }
11     // Serial.print(timestamp); Serial.print(' '); Serial.println(rise?'1':'0');
12     if (want_start) {
13       if (!rise) {
14         if (start_delay > 0) {
15           const stamp_t d = stampdiff(timestamp, prev_ts);
16           if (d < start_delay) {
17             // to soon, skip
18           } else {
19             want_start = false;
20             bit_count = 0;
21             recv_byte = 0;
22             start_delay = 0;
23             //Serial.print('T');
24           }
25         } else {
26           // \/ we actually receive what could be a start bit
27           want_start = false;
28           bit_count = 0;
29           recv_byte = 0;
30           //Serial.print('S');
31         }
32       } else {
33         //Serial.print('Q');
34         // /\ probably a stop bit; just discard and wait for next start
35       }
36     } else {
37       // we are receiving a byte
38       const stamp_t d = stampdiff(timestamp, prev_ts);
39       // Serial.println(d);
40       if (d > 80) {
41         // if it takes to long to get a bit, the byte has ended
42         if (!rise) {
43           // \/ we find what is possibly a new start bit
44           // this means we need to fill the remaining bits with
45           // /\ meaning a 1
46           const int num_bits_remaining = 8 - bit_count;
47           // Serial.print("+"); Serial.print(num_bits_remaining); Serial.print('-');
48           for (int i = 0; i  < num_bits_remaining; ++i) {
49             recv_byte >>= 1;
50             recv_byte += 128;
51           }
52           Serial.print('$');
53           Serial.println((int)recv_byte, HEX);
54           want_start = false;
55           bit_count = 0;
56           recv_byte = 0;
57         } else {
58           // /\ we're out of sync, restart
59           //Serial.println('*');
60           bit_count = 0;
61           want_start = true;
62           start_delay = 80;
63         }
64       } else {
65         // new edge within the same byte
66         // if the edge comes after double the expected time or more
67         // we've skipped a bunch of bit of the previous value
68         const int8_t prev_num_bits = ((d+1) / 8) - 1;
69         // Serial.print("+"); Serial.print(prev_num_bits); Serial.print('-');
70         // push previous bits
71         for (int8_t i = 0; i < prev_num_bits; ++i) {
72           recv_byte >>= 1;
73           recv_byte += rise ? 0 : 128; // inverse of what we're going to now
74           // Serial.print(rise ? 'O' : '|');
75           ++bit_count;
76         }
77         // push current bit
78         if (bit_count < 8) {
79           // Serial.print(rise ? '1' : '0');
80           recv_byte >>= 1;
81           recv_byte += rise ? 128 : 0;
82           ++bit_count;
83         }
84         if (bit_count >= 8) {
85           // we reached the end of the byte
86           Serial.print('#');
87           Serial.println((int)recv_byte, HEX);
88           want_start = true;
89         }
90       }
91     }
92     prev_ts = timestamp;
93   }
94 }


This actually somewhat works :)

Now comes the tough part to rework it to do the byte decoding in the interrupt handling and work with a circular buffer like New Software Serial. After that it needs to be optimized.

Also tables need to be made to accommodate different baud rates then the fixed 31250 baud used here.
An interesting thing is that because I'm already looking at time-stamps anyway, implementing auto-baud should not be hard!

Another future addition could be to actually sample the pin a second time shortly after the first time and if it's not the same discard the bit. This would work as a simple noise filtering.

To be continued in the near future!

Saturday, September 29, 2012

Dimming a 12V LED strip with a mosfet and PWM, part 3

This is part 3 and for now the final part of this series of posts on my experiment with using a mosfet for dimming a 12V LED strip as the strip is going to be used for lighting up my soldering desk (undimmed).

In part two I found that using a 100nF snubber capacitor filters out the Drain-Source ringing. However I noticed a large drop in Drain voltage from the expected 12V when the mosfet is disabled. As last time, K made an interesting comment,  this time that the circuit seems seriously overdamped.

Let's try and actually use the formulas K mentions in the comments and which can be found in the article Calculating Optimal Snubbers.

The datasheet for the IRF540 mosfet shows a Drain-Source capacitance of 375pF (C) at 12V.
Assuming a ringing time (T) of 200ns and using the formula T=2*pi*sqrt(L*C) gives a parasitic inductance of 2.2uH.

This gives a snubber resistance R=sqrt(L/C) ~= 100Ω. With C=T/R this gives a snubber capacitance of 2.2nF.
100Ω 2.2nF snubber
The snubber does give a damping effect, but still a nasty initial peak of 30V.

Remeasuring the period shows actually more in the direction of 400ns. Recalculating like above gives 10uH parasitic inductance. The snubber gives 190Ω and 1nF.

190Ω 1nF snubber
Note that I changed the vertical scale of the blue line to 10V. This means we have a nasty spike of 36V, which is definitely worse.

As this still doesn't look very well I started playing with values.

47Ω 1nF

0Ω 4.7nF snubber (blue 10V scale)

0Ω 4.7nF snubber (blue 5V scale)


0Ω 3.3nF snubber
0Ω 10nF snubber
As you can see increasing the capacitance reduces the peak, but also reduces the end voltage below the expected 12V.

I finally settled for the 0Ω 3.3nF snubber. It gives some minimal ringing but stays near 12V. As it requires no resistor there is no resistive loss.

Measuring the power usage shows no significant difference between the snubbed and plain circuit. I still think that some parts of the story have not been revealed here. Maybe in a future blog post...



Thursday, September 27, 2012

Dimming a 12V LED strip with a mosfet and PWM, part 2

In a previous post I looked at PWM dimming a 12V LED strip. Time to revisit this with some new insights. So I saw bad ringing at turn-off of the mosfet. According to K the noise is caused by the capacitance of the Drain-Source of the power mosfet in combination with the inductance of the load. This makes sense as I already figured out that changing the load influenced the ringing.

Let's do a proper "snubber". (Not "shunt" as I called it last time).

I'm re-measuring with the gate voltage on the yellow channel and the drain voltage on the blue channel of the scope. Notice that the blue channel has a 5V per division scale and the yellow one 1V per division.

no snubber
 Without snubber that looks absolutely horrible.

Second lets add a 100nF capacitor from drain to VCC like I did in the previous post.

"snubber" cap to VCC

That is with a "snubber" cap to VCC, which arguably is not really a snubber at all.

Finally, lets really add the snubber over the Drain and Source of the mosfet, which means Drain to ground as the Source is directly connected to ground.

snubber cap across drain-source
That looks nice!
There is still some high frequency noise (~20Mhz) but it has a very low amplitude.

Let's go back to the initial situation, is it really a problem? I guess with the mosfet I'm using (IRF540), not really. It has a Drain Source breakdown voltage of 100V, and the largest peak I notice is 40V. On the other hand that might just go past the breakdown voltage of the LEDs on the LED strip and that is not a good thing either.

A curious thing is that in the non-snubbed circuit the drain voltage goes all the way up to almost 12V and in the snubbed circuit it only goes up to 5V. It looks like the LED strip in combination with the snubber acts as some kind of impedance divider.
If  I change the snubber from 100nF to 1uF (10x larger) the peak voltage on the Drain drops to 4V. Changing it to 50nF raises the peak voltage to 6V.

Something to ponder about...

fixing things with sugru

Sugru is air-curable silicone rubber. It is easily shape-able by hand and cures in about a day. It stays good for about 6 months in the original packages, but I store it in the fridge where it will stay good a bit longer.

Etching tank

When I'm not etching I want to store the etchant away in a safe place. I use glass jars stored in a hazardous materials container for that. The tricky thing is to pour the etchant from the tank into the glass jars without spoiling any as it is both toxic and corrosive. The tank being rectangular in shape makes this nearly impossible.

The solution: a sugru-made (I mixed two colors here) round shaped high side-walled  pouring guide.


A test run with water show it works great. Not a single drop of spill.

Screw protector

This is actually something fixed by Isabelle. One of the screw protectors in the horse trailer got missing and she was worried her horse might injure herself on the exposed screw. Some sugru to the rescue!

On the right the normal screw protector, on the left the sugru fix.

Fridge

One of the knobs to keep a panel in place in the fridge had broken off. We probably overloaded that particular part in the panel, although it is also arguably a week construction. It is fixed with sugru and seems to hold until now, although we also re-organized the fridge to get a better weight distribution. Sorry for the unclear picture but I didn't feel like taking the fridge apart again.



Conclusion


Sugru is handy stuff! Highly recommended to have some off it in your house, especially as it allows you to easily fix things you might normally just throw away and buy anew. Less waste is good!

Sunday, September 23, 2012

Dimming a 12V LED strip with a mosfet and PWM

Dimming a 12V LED strip with an N-channel power mosfet is pretty straightforward. In this experiment I'm using 5 meter of cool white LED strip running at about 800 mA giving 10 Watt.

the basic setup
 An Arduino Duemilanove (my trusty lucky white one) is used to provide pulse with modulation ( PWM ). Digital pin 9 and 10 (also known as OC1A and OC1B) are used. They both use the Timer2 facility of the atmega328p microcontroller which means I can have them output exactly the same PWM signal. Digital 9 is used to drive the mosfet and digital 10 is only used for displaying the unloaded PWM signal on the scope.

Basic PWM setup schematic


PWM on the scope
On the scope you can see the yellow PWM signal driving the mosfet and the blue one that is not connected to any load.

The following Arduino sketch does a simple PWM sweep in 10 steps per second:

 1 void setup()
 2 {
 3   pinMode( 9, OUTPUT);
 4   pinMode(10, OUTPUT);
 5 }
 6 
 7 byte b = 0;
 8 
 9 void loop()
10 {
11   analogWrite(9, b);
12   analogWrite(10, b);
13   delay(100);
14   ++b;
15 }

This gives a PWM signal as shown in the (crude) video below.


Not shown in the video is that this also nicely dims the LED strip.

This is actually good enough for simple dimming, but lets look at it more in detail. More specific lets look at the rise and fall of the PWM signal at the gate of the mosfet.

a detailed look at the voltage at the rising edge at the gate of the mosfet

Whats interesting to see is that it takes about 600ns in total to go from 0V to 5V at the mosfet gate.
The first sharp rise is from 0V across the threshold voltage of the mosfet to the Miller plateau voltage and takes about 100ns. At this point the current through the mosfet is already at the peak but the voltage across the mosfet from drain to source still has to drop from the 12V it starts at. This drop happens across the relatively flat part of the peak in the middle called the Miller plateau region. After this drop the Drain-Source voltage for this particular mosfet will be a bit above 150mV and the remaining 11.85V will be across the LED strip. Finally the voltage at the gate rises to 5V which will slightly lower the on-resistance of the mosfet and the final Drain-Source voltage should be about 100mV.
As mentioned all this takes about 600ns which is not very fast. Looking at the specification of the IRF540 mosfet a rise time of about 35ns should be possible.

I got quite some interesting info concerning mosfet gate drivers from this Texas Instruments paper.

The basic idea to get a faster transition is driving more current in the mosfet gate then the measly 50mA that the digital pin of the Arduino/atmega is capable of providing.

One solution suggested by the paper is to use a Bipolar totem-pole driver. The idea behind that is that by using the very fast operation and large gain of bipolar transistors the gate can be charged and discharged quickly.

adding the bipolar totem-pole mosfet driver 
When the PWM signal is high the NPN transistor is on and the PNP transistor is off. This allows a large current to flow from the 5V power supply and the tank capacitor C into the mosfet gate.

PWM high and NPN on
When the PWM signal is low the PNP transistor is on and the NPN transistor is off allowing for a quick sink of the charge on the mosfet gate into ground.

PWM low and PNP on

For the transistors a BC639 NPN and a BC640 PNP do the job. R is 3.3Ω. RB is 22Ω. RGATE is 4.7Ω. C is a big 1000μF electrolytic.

final setup
improved rise time
A rise time of 44ns using the bipolar totem-pole driver is not bad at all.

Lets take a look at the other side of the wave form.

fall ringing
There is some nasty ringing on the fall side of the pulse. This won't affect the dimming but it's interesting anyway to take a look what is happening.

First thing I checked is RGATE. Increasing the resistance off RGATE does lower the ringing but it also kills the just gained speed improvement.

Then I noticed something weird: if I unrolled part of the LED strip the peaks of the ringing got larger. I then replaced the LED strip by a single LED and surely the ringing is all but gone.

I assume the capacitance/inductance of the 5 meter LED strip and/or all its LEDs cause the ringing.

Adding a shunt resistor across the LED strip lowers the amplitude of the ringing but it requires quite a low ohm resistor which in turn gets very hot when there is 12V across it, and it wastes a bit of energy.

Measurement with the scope shows that the ringing is at about 3.5Mhz. A simple shunt capacitor of 100nF should nicely act as a low-pass filter. If we presume a parasitic resistance of 1Ω, using f = 1/(2*pi*R*C) gives about 1.5Mhz cut-off frequency for the filter.

schematic with CSHUNT added


with 100nF filter
That certainly looks nice. I still don't think it is more then aesthetics though..

 I'd love to hear comments on this! Either here or on G+.