A milestone

Too bad I work alone and mostly at nighttime. Otherwise, I would have some people around to share the sheer joy that I am experiencing right now. For a lack of that, I’ll turn to the web. Just an hour ago, I completed a major milestone in my main project line. I am ecstatic as with work of this magnitude, the light at the end of the tunnel is always months away( and right after, you get into another tunnel…) Here is the writeup on the situation.

I have had a fascination with oscilloscopes for a very long time. While being incredibly useful (for those who are into electronics that is), they have a mysterious sense to them that still gets me after all those years of hanging out with complicated machinery. I remember clearly seeing rows and rows of them during my first university year, having only a very rough idea of what they were for but still knowing, judging by their numbers, that they must be very useful for every electronics bench to get its own. They are what epitomizes the knobs and dials (screen in this case) strange and obscure apparatus of the modern age.

So much so that I decided to program one from scratch for my final engineering project; I had very ambitious plans for it. The electronics would be managed by a Microchip PIC18F4550 – a USB microcontroller – and the application on the host PC would be programmed in C#. Its killer feature would be that its display would be 3D, giving the user one more dimension for visualizing, combining and probing waveforms. Turned out implementing the USB stack was a major bitch (should have used Microchip’s ready-made one…) so I decided to get signals through the sound card input. No big deal, the main application was agnostic as to where its data came from. Then, the 3D part was a huge headache too (80% of the code, a primitive but complete 3D engine), but I got trough it and in the end it worked well enough for a public showing. I will post all its code and some screen shots when I find the motivation too, but for reasons that will be developed upon at this time, I decided no to further its development. Simply put, I had discovered the world of Open Source and realized that platform-locking my project (DirectX, .NET) was not inline with my philosophy of getting good electronic tools in the hand of the masses.

This new one is implemented on an OS of mine (Elements, but beware, the post is very outdated) and thus completely web oriented and RESTful. The user interface is described in XHTML, SVG and JavaScript with all of it getting served along with the oscilloscope function by an ATMega328p with 32kB of static EEPROM storage. That’s a web server, TCP/IP stack, a file system and oscilloscope running on 32kB of Flash, 32kB of EEPROM and 2kB of RAM embarked on a 16 MHz chip! It had been a web server for quite a while, but tonight, I got it to behave like a usable oscilloscope. I am a happy man…

The paradox of management

It recently occurred to me that the job of a manager (so often praised in our knowledge economy) is essentially a paradox, as its ultimate objective is to make itself obsolete.

A manager is essentially a problem solver. While the nature of the problems is certainly very vague, it goes from implementing a measure pushed down from higher up in the organization to dealing with a sick employee, but essentially, it all falls under the umbrella of problem solving because managers only have a very indirect responsibility on the product or service delivered by their organization.

It follows as a logical conclusion that a well managed entity will not have any problems, but that would be no permanent achievement to the manager as he knows very well that issues will soon reappear in the changing environment he works in. Incidentally, the best manager will not only have made his organization problem free, but will have implemented the mechanisms to solve them without any sort of oversight or implication on his part, since such are the characteristics of ideal processes. At this point, he will have fulfilled his role has a manager, he will be laid off or moved elsewhere, and the group of people he once led will continue to thrive and adapt without him.

Utopia aside, it feels to me like the most efficient, elegant and adaptable systems on this world always have an organic feel to them or are even naturally organic. Look at the web, look at social media, look at cities, look at society but most importantly, look at life around you.

There will always be a need for oversight and stewardship in the future, natural selection is too cruel for blunt application on human organizations, but I foresee that the current role of manager will redefine itself to that of an enabler, where the crux of the job is no longer to direct, but rather to create the conditions or more precisely, the ecosystem where an ideal can bloom, exist and subsist.

I ought to give credit to Matthew Crawford’s inspiring book, Shopclass as Soulcraft for an hint on this idea. In fact, it would not surprise me if he had thought of it before I did.

An impressive find

It looks like a cockroach but it has no antenna and appears to have its abdomen shell sutured preventing it from flying. Nonetheless, its by far the largest insect I’ve ever encountered in nature. While at my friend’s place, I grabbed the latest issue of National Geographic, opened a random page an saw a big photo of this very bug in all its splendor. It was part of a small feature on entomophagy. Turns out this is a benacus deyrolli, or a giant water bug as its commonly referred to. I should have been more careful, the Wikipedia article mentions that

Their bite is considered one of the most painful that can be inflicted by any insect (the Schmidt Sting Pain Index excludes insects other than Hymenoptera); the longer the bug is allowed to inject its saliva, the worse the resulting bite, and as the saliva liquefies muscle tissue, it can in rare instances do permanent damage. […] Occasionally when encountered by a larger predator, such as a human, they have been known to “play dead” and emit a fluid from their anus. Due to this they are assumed dead by humans only to later “come alive” with painful results.

When I was done taking the pictures, I released it in my frontyard only to find its empty exoskeleton two weeks after in my friend’s dog mouth.

CMoy headphone amplifier

The final product

One of my friends, who creates music as a hobby, recently bought a pair of AKG 601 headphones. While I do listen to a fair amount of music, I would not consider myself an audiophile or anything close to that. However, those headphones do make a difference I can notice in the quality (or lack thereof for low bit rate MP3s) of whatever is being played. There is only one small problem with them. Being massive open headphones, my friend’s sound card is only able to put out an acceptable level of sound at maximum volume; his MP3 player, on the other hand, is simply incapable of driving them. The AKG 601 have a rated impedance of 120 Ohms while normal earbuds seem to be around 20. As a result of a soundcard’s output impedance being too high, a normal speaker output  is not capable of providing enough current to the headphones.

They are huge, expensive and leak a lot of sound, so he does not plan to use them on bus rides, but there are still some serious downsides with having to drive them at maximum volume:

  • Levels of distortion increase significantly as maximum power is reached in an amplifier. This means that running the volume at maximum produces sound of a lower quality than if it was outputted at 50% and then passed trough a more capable amplifier.
  • When he creates music and wants to listen to specific instruments or tracks that are not as loud as the rest he is stuck with the current level of volume.

To address those problems he was considering purchasing a headphone amplifier, but to me, this seemed like the perfect opportunity for a diy solution. As he is not at all familiar with the world of electronics, I offered myself for the task as it was a good and easy way to get my hands dirty with pure analog stuff and get acquainted with audio. My background is more software with the occasional digital circuit. I did learn about all the concepts in application in this project at school, but the retention capacity of my brain decreases significantly when the interest is not there, and a bunch of formulas splattered on a white board does not tell me how to use an op amp in real life.

Since parts are cheap and shipping isn’t, I decided to build one for me as well. This post details the process but its not a how-to for the CMoy as there are alrealy a ton around the web.

Circuit

I started my research on the excellent diyaudioprojects.com and found the CMoy/Grado RA-1 project. The circuit looked simple enough and according to the author, the quality was on par with a Grado RA-1 which retails at 425 $US on amazon. It turns out that the CMoy pocket amplifier, named after Chu Moy, its inventor, is a very popular design. You can find kits for it on the web that are about an order of magnitude cheaper than the RA-1 it aims at emulating.

Amplifier circuit

Chu Moy’s website provides a wealth of information, but the one that help me the most by far was Warren Young‘s tutorial on the CMoy.

Do not let yourself be fooled by the simplicity of this circuit, there is a lot more to it than meets the eye and tangentsoft’s tutorial does an outstanding job at explaining all the specificities  and what you need to be concerned about when making modification. It took me about ten minutes to get a working version on a breadboard, but actually understanding it required a fair amount of reading and thinking. Once again, Warren’s site proved ato be invaluable resource in this, especially his audiologica section. Some amplifier designs on his website are considerably more complex than this one and would be a nice progression from this project.

Power supply circuit

The power supply is no too complicated but somewhat unconventional because of its use of a virtual ground, something that was previously unknown to me. My design is generally the same except for the addition of a linear regulator and a protection diode as I did not want to run it from a 9V battery and the wall wart I had lying around was unregulated. For the amplifying part, I added a resistance in parallel with the volume pot to make it behave in a more linear fashion (I bought a log one), some decoupling ceramic caps for the op-amp’s supply lines and upped the value of C1 from 0.1uF to 1uF to let trough lower bass frequencies. Every CMoy amplifier circuit variation uses different resistance value. R2 is fairly constant at 100kOhm as it forms toghether with C1 a high-pass filter. R3 and R4 will vary depending on the gain required. The power supply part is pretty straightforward but you will need to find a value for R2 and R3 that will strike a good balance between not draining the battery too fast (should you choose to go that route) and providing the virtual ground enough current sink capability.

Power consumption is very low. I am using a 9V unregulated wall-wart with a current rating of 100mA. Since the amp cannot load it fully, the output voltage at the connector is around 12V which leaves plenty of room for subsequent regulation down to 9.5V. The linear regulator is an absolute necessity as its omission lets trough a very audible hum.

While this circuit will work with any standard parts (which I used for the prototype), it is best to use audio grade components. This is often synonym of overpriced, but in this case, since we are talking small and simple, you can get away with only investing a few more dollars. For the op-amp, I selected the  Burr Brown OPA2134 as recommended by CMoy and decided to go with polypropylene metal film capacitors instead of polyester. I also got a gold-plated IC sockets and audio jacks. The only non-standard part was the volume pot, which had to be dual-gang in order to control both channel at once.

Prototype

On the breadboard
Protype with generic components

Naturally, everything stated on a bread board. There is nothing spectacular about that, but when I first put toghether the circuit, all I had to work with was some general purpose op-amps (MC1458) and some electrolytic caps. I was unsure whether the op-amp would be sufficient or not, but I did know electrolytic caps are only to be used in a bypass configuration as they induce a fair amount of distortion when used in line. Regardless, there was improvement in comparision with not using an amp at all. At this point, I became confident this would not be another useless circuit and things could only get better with the “audio grade” parts.

Prototype with audio-grade components

When I received the components I ordered from mouser specifically for this project, I instantly swapped them on the protoype and was rewared with a increase in quality… or so I think. The term “subjective” applies especially well to the audio realm; due to known psychological effects, me knowing the components were actually better in theory rendered me incapable of judging whether there was an improvement or not. Then again, I do not really know what to look for but I would consider the overall difference to be subtle enough to be affected by skewed perception. This is why I decided to take my friend trough some blind tests. He does not know a capacitor from a resistance and much less their potential effect on sound, on the other hand, he know music and most likely has a more discerning hear than mine; he is the perfect candidate. More on that at the end of the post.

Enclosure

The original box

While the parts were on their way, I decided to get started on the enclosure right away. Naturally, I would have gone towards a plastic project box but while me and my friend were discussing the project, he suggested the use of a small wooden chest as he had one handy and felt a tupperware container would not do a piece of quality audio equipment any justice. Upon inspecting it, I figured it would be pretty easy to turn it into something visually pleasing with a bit of woodworking. I found my box at Michael’s for $3.50. I had never worked on wood (except while renovating but I would not consider this woodworking) so I was somewhat unsure of the end-result. With perspective, this is the prettiest project enclosure I have built so far and for that price,  I’ll definetly repeat this design.

The box went trough several modifications. First, the lid was removed and disassembled. The rectangular pieces of which the sides of the lid were made were cut and glued to the box. Two there added to the opening of the box to provide a bit more support for feets while the two others where glued to the bottom to raise the pcb.

The holes and marks where the hinges and lock used to be were filled with wood filler and then the edges were sanded down to give the box a rounder shape. Lastly, holes to accomodate the various connectors and holders were carefully (pine is very soft and chips easily) drilled.

Since the box was made out of pine, it needed to have wood conditionner applied on it. It took me a while to figure out how to use this product as information from some diy sites conflicts with the manufacturer’s label and everyone seems to have their particular process when it comes to preparing soft wood for staining. I finally came across a site that explained that wood conditionner was actually diluted varnish. Consequently, it needed a day of drying to properly seal the wood’s pores and allow even stain penetration. This contradicted the can’s label which directed to apply the stain within two hours of applying the conditionner. I ended up following the website’s advice and let it dry overnight. The stain came out beautiful and uniform without any blotching while tests using the manufacturer’s instructions on scraps where not so conclusive.

After staining, I applied two coats of polyurethane warnish with some light sanding in between and that was it for the box. It took three days including drying time but overall, I would estimate the amount of time invested to two hours with sanding being the longer task.

Soldering

Soldering the circuit was somewhat harder than usual because of the PCB I used but with any

Circuit in fabrication

standard board this should be an easy task. The routing is straighforward but ideally, everything affecting the signal path should be kept as close as possible so as to avoid the side effects of long wires (inductance, capacitance, EMI pickup). Mine required a fairly sized board because of the polypropylene capacitors, but with small components, everything should fit on two postage stamps and not take more than two hours to solder.

Finalization

To block any unwanted EMI, I lined the inside of the box with two layers of aluminium foil glued toghether like Mark did on his CMoy/Grado RA-1 project. Whether this is useless or not I cannot tell, but it certainly cannot hurt. I still have some old CRTs at my parent’s place so when I get the chance, I will try and see if it picks up anything.

Fitting everything inside the box.

Installing the circuit in the box is no simple task as all the connections have to be soldered while it is in there sitting in mid air. Incidently debugging also has to happen in this position. Mine did pass the smoke test but it did not work correctly the first time around. It turns out I had soldered one channel of the pot the wrong way.

Sound

As mentioned in the intro, I would not consider myself versed in the art of listening  and I much less have the capacity to describe sound with words. However, I can certainly tell it makes a noticeable difference in quality of the music. Even with my old and battered Koss headphones it sounds better but when I got to try it with my friend’s AKG-601 I was blown away and felt for a minute I should make the investment and get myself a pair.

The downside of better sound is more obvious compression artifacts; a good amplifier will not discriminate either. Some of my tunes which sounded fine on my MP3 player with earbuds are now barely listenable because of the effectiveness of the amp at reproducing what it takes as input. I finally got a around to finding a few MP3 in my collection which were of good quality, but you should nonetheless be aware that if the end product sounds bad, check the MP3s first before probing the circuit for a problem that isn’t there.

I have only listened to it for a few hours so far and apparently, it get’s better with time as parts burn-in (like engines??). This seems odd to me, but I will take the web’s word on that. I could somehow see this phenomenon coming into play with tubes and high-powered solid-state amplifiers as they are genereally under a lot of thermal stress but for this little mW scale headphone amp, I have my doubts.

(Scientific) Test

Yes, it does sound better, but that’s only my opinion. And a very biaised one because I researched and built the whole thing and incidently, would be very disapointed if all that work did not pay off. It certainly feels like adding the amp to my listening set-up improves the sound, but you can only live with a placebo effect for so long, so I got two friends including the one for which this project was started in the first place and did a blind test.

There were initially four configurations but we decided to drop one  for fear of not completing the test before the beer store closed:

  • Straight MP3 player
  • MP3 player and prototype circuit (no audio-grade components)
  • MP3 player and finished amp

The headphones were obviously the same for all tests and the volumes were adjusted to approximatively the same level. The MP3 player when used alone had to be set to its max volume which is a good thing since the whole purpose of the headphone amp is to avoid this as it dramatically increases the distortion level.

A run would consist of 1 minute of listening to the same song (Californiacation by Red Hot Chili Pepers; everyone I know likes this song) on every configuration. The subjects did not know which one it configuration they were listening with, all they could see was me shuffling wires behind a box and then handing them the headphones. We repeated the run three times so as to increase the chances of getting a statistical significance.

One subject got discouraged in the middle of test, complaining that it all sounded the same to him but despite his lack of faith and to his amazement, the results confirmed the predictions. In order of quality:

  1. Prototype
  2. Finished amp
  3. MP3

The rating scheme was a sort in order of preference, but one decided to rate using half marks so the results group the two amps closer toghether. The MP3 player was identified as worst every time while the two amps shared the top two almost equally. I would have expected the finished amp to come out first but after some careful listening to the actual track, I realised compression artifacts were more audible on it. This is probably due to the OPA2134’s better bandwith as artifacts are generally found in higher frequencies. The MP3 player just by itself did sound truly awful, Some artifacts were not present while others were exacerbated but overall, it felt a bit like listening to the FM radio.

Conclusion

Front

Simple, quick and inexpensive projects are definatly a rare occurance in my life, so this one was definetly a welcomed breath of fresh air; its nice to finish something and it gave me a break from battling with C++. It is not perfect yet but when I get the motivation, I’ll get to correcting the small bugs: mainly a minute discrepancy between the left and right gain (resistor/pot variation) and a not linear enough pot. For the time being I’ll just enjoy it as is.

Back

Building audio equipments is definelty something I will revisit in the future. It’s a break from routine and a very gentle way to get familiarised with the mysterious and unpredictable field of analog electronics: everything works at a low frequency and a low votlage so you can be confident nothing extra weird is happening. As a plus, you get something useful at the end of the day. To summarize, this project is the perfect “Hello world” equivalent.

Next step will be a full scale amp with some digital controls; the circuit is putting itself toghether in my mind as I write those lines, but it will have to wait for a while as I have other stuff that needs to get finished and still in the process of salvaging components.

My friend’s version

My friend's CMoy amp

Not that different actually, but it took a while before we could meet (with 500 km separating us) and sit down for a few hours (from 20:00 to 04:00) to finish the project. I had given him a plan and a solder iron, but we ended up completing the project together. In retrospective, there was no way he could have worked on the thing like I hope he would; I even had soldered the voltage regulator backwards and besides that, there we a massive amount of obstacles I strongly doubt someone with no electronic background could have overcome. Still, it was fun getting high on solder fumes along with him. Tests were conclusive and he is now the proud owner of a clone of a 425$-ish amp clone. The one thing we changed was how the volume pot behaves. I had originally bought a log version but found out it was only useful at 80% of its range so I added a couple resistors to make my friends’s pot behave a bit in a more linear fashion.

Gallery

Wikipedia as hope of an agnostic society

In Wikipedia, articles are evolved word by word by contributors to a stable form that reflects consensus. Hence, the rate of change in articles not about ongoing events will tend to diminish over time. Trough having spent a considerable amount reading a vast array of articles, I am confident in claiming that Wikipedia maintains a consistent agnostic point of view with regards to religion (as mandated by its encyclopedic nature). Divinity is definitely present, but it is constrained to where mentions of it are pertinent. In other words, Wikipedia is a secular organization and has become so solely by the consensus of its members; consensus trough discussion and reason.

On the hypothesis that Wikipedia is contributed to by people of all walks of life but with the common characteristics of having been educated in a modern schooling system and being intelligent enough to achieve the level of writing implicitly required. I think I can advance that any society or group of individual that attains a similar level of knowledge, regardless of where they started will, given enough time, necessarily become exempt from irrational belief. Only with Wikipedia, this stabilization came about much faster due to its relatively small size, its virtual nature and the fact that it has been relatively spared by special interest groups.

Even though the level of intelligence in society is far below that of Wikipedians, it has been steadily increasing ever since we as a species started communicating ideas.

There definitely is an emerging tendency not to affiliate to major religions (sects are a problem of a different nature) among the populations of western countries, where the average level of education is much higher than in the rest of the world. As the average individual acquires an increasingly broader knowledge of the environment around him, society as whole acquires the ability to understand concepts that once would have been too complicated of too esoteric for it to grasp. Take the Roman Empire for example, where Christianity replaced paganism as the most popular religion. It certainly took a while for common knowledge to evolve to a point where it could understand the tenets of monotheism but after a few centuries, it had almost completely eradicated polytheism for monotheism was a much more fitting choice for the conditions at the time. In the same manner, Monotheism will move away from the cultural sphere to the personal sphere and will eventually become history. Nonetheless, it’s a lengthy process; social inertia slows down its propagation down the different levels of society. Intellectuals became skeptical about the existence of an anthropomorphic god and its pertinence to the human condition more than a century ago. Then, governments followed this current of thought by separating church and state. Afterwards, attendance of religious services by the wealthier classes started diminishing noticeably only recently and eventually the lower classes of society should follow along the same path. Except for a few cases (the human brain is built to believe after all), society will in the future have completely parted itself with any sort of organized religion.

This gives me a bit of hope.

It should be noted that society or the popular web encyclopedia for that matter, both subject to the laws of evolution, will not necessarily evolve towards some ideal of rationality and scientific thinking. Should humanity adopt a different vision on knowledge and objectivity, Wikipedia will have to either adapt or cease its existence. Moles have been steadily losing their eyesight over time with even some of them having a layer of skin covering their eyes. If you spend all your time deep in sand and dirt so as to avoid the hardships of the world above, you will loose sight. Evolution does not strive at attaining some ideal, it strives at finding a best fit for a definite environment; and this sometimes mean that some characteristics which we now consider a step towards that ideal might need to be evolved away for the good of the entity concerned.