Sunday, September 6, 2015

Time to switch to Raspberry Pi?

Raspberry Pi Model 2 looks cool for its price. Better than a single core BeagleBone Black I'm using.
It has 4 USB ports so I can try to connect my USB audio along with WiFi dongle.
Why not to upgrade?

There are lots of distributions out there but I need a stable one with at least two features:
1. MPD that can play via USB Streamer (requires working USB Class 2 Audio mode)
2. Working I2C bus library

So I bought my new toy and started to slowly work on that...

So far I have MPD playing through HDMI, that's a good beginning

Saturday, July 25, 2015

A real-life NodeJS application

After I resoldered prematurely died amplifier chips and put it all together again I decided to take some easy steps to help my amplifier live longer.
The one of easy ways I see is to unmute it when MPD starts playing and mute when it stops or pauses. That will shut down PWM modulation and basically turn off the power stage so I don't need to manually turn it on or off,

That's seems to be a good job for NodeJS!
Node works just fine on Linux boards like BeagleBone or Raspberry Pi and there are lots of success stories how folks do all kinds of stuff.
No need to invent a wheel and there is a neat Node mpd client ready to use,

I already have some python scripts to control my PWM modulator so the idea is to use Node to invoke them when needed. Sounds easy.

So here my first working Node application. It's not polished but just a simple proof of concept.

var fs = require('fs');
var exec = require('child_process').exec;
var mpdlib = require('mpd'), cmd = mpdlib.cmd;

// hardcoded paths to mute & unmute scripts
var cmd_play = "python /root/cr/unmute.py";
var cmd_stop = "python /root/cr/mute.py";
var errorMonitorInterval = 600000;

var refreshMPD = function() {
   client.sendCommand(cmd("status", []), function(err, msg) {
     if (err) console.log(err);
  if (msg) {
   var data = mpdlib.parseKeyValueMessage(msg);
   console.log(data.state);
   if(data.state == "play"){
    execute(cmd_play, console.log);
   } else if (data.state == "stop" || data.state == "pause") {
    execute(cmd_stop, console.log);
   };
  }
   });
 };

// if something wrong happens I don't want it to flood my log file
var firstErrDate, lastErrMessage = "", errCount = 0;
setInterval(function () { 
 if(errCount>1){
  var date = new Date();
  d = date.toLocaleString();
  console.log("[" + d + "]:\t" + "Last error happend " 
  + errCount + " times in the last " 
  + Math.round((date - firstErrDate) / 60000) + " minutes.");
 }
}, errorMonitorInterval);

var logError = function(err, when){
 var date = new Date();
 d = date.toLocaleString();
 
 var message = err.message || err;
 if(!firstErrDate || lastErrMessage != message){
  if(errCount > 1){
   console.log("[" + d + "]:\t" + message + " happend " + errCount + " times so far."); 
  }
  firstErrDate = date;
  lastErrMessage = message;
  errCount = 1;
  console.log("[" + d + "]:\t" + message + " when " + when);
 } 
 else{  
  errCount++;
 }
}

var execute = function(command, callback){
 try{
     exec(command, function(error, stdout, stderr){ 
      if(error){
       logError(error, "executing \'" + command + "\'");
       callback(error.name); 
      }
      else {
       callback(stdout); 
      }
     });
 }
 catch(err){
  logError(err, "executing \'" + command + "\'");
  callback(err.name);
 }
};

var getDate = function(){
 var d = new Date();
 return d.getMonth() + 1 + "/" + d.getDate() + "/" 
  + d.getFullYear() + " " + d.getHours() + ":" 
  + d.getMinutes() + ":" + d.getSeconds();
};

//===================================
var client = mpdlib.connect({
  port: 6600,
  host: "localhost",
});

client.on("system-player", refreshMPD);
client.on("system", function(name) {
 if(name == "mixer") refreshMPD();
});
client.on("ready", refreshMPD);

The only problem I found with running NodeJS on BBB is that sometimes music has drop-offs. But it is easy to fix as we can lower the priority with nice command. Like:
>nice node amp.js

and music just plays. And amplifier stays ice cold when music is off.
Sweet!

Thursday, April 16, 2015

How to fry TAS5631B. Guaranteed.

The happiness couldn't last forever and I found a pretty much stable way to make a toast out of TAS5631B,
Here is my simple recipe:

  • Connect VDD (+12) to the board
  • Short any single speaker output to the GND
  • Connect PVDD (+50)
  • Voila, /SD and READY outputs are always low and can't be cleared via /RESET or power cycle.
  • Cry and order a new chip

Datasheet says "The TAS5631B does not require a power-up sequence." and "it is recommended to hold RESET in a low state while powering up the device". Not sure holding down RESET can prevent mosfets from a premature death.

How could I find it out?

Well, that was my bad. I connected the power supply with 3-wire power cable. For some (probably good) reason power supply has the Earth electrically connected with the output GND.
As you may know, most scopes have the negative probe connected to Earth.

I fried two of my boards while I figured out why my scope doesn't show any signal...

I'm wondering now if there any way to test for a grounded output before applying PVDD.

Saturday, December 20, 2014

Got it together but not for a while

Finally we settled in our new house. Can't say I'm done with our new IKEA kitchen but it is usable now. So it's time to have some hobby fun and play with my amp and speakers.

Finally I put all six channels together with BeagleBone Black and two switching power supplies - one for power amp and one for the BBB. Also I got very sexy VFD display from eBay for a very good price so I'd like it to show some useful information very soon.

Standard Debian seems to be a good choice but I found two problems with it (updates a pretty frequent so the latest one may work better):
1. it can't find my USBStreamer if it was reconnected
2. MPD playback has noticeable drops.
Then I found a great distribution - Voyage MPD. It is outdated but it doesn't have these two problems I mentioned above. But this distribution would not work for folks who want to use HDMI output - HDMI itself works but HDMI audio output is not available.

So I mounted my NAS, set it all up and finally got my music played without drops and pops!

But my happiness did not last for long. I wanted more. So I tried to put some coefficients into loudness biquad... And got my tweeters fried in a faction of a second. As well as one TAS5631B chip.  Woofers and midranges survived.
So I got a very good lesson - always disconnect speakers when you play with biquads! And use a scope first!

Thursday, October 2, 2014

Привет аудитории!

Как оказалось, большинство из немногочисленных посетителей этого блога приходят из рунета, через гугловский поиск картинок. Этот пост специально для тех, кто не говорит по-английски.

Почему пишу по-английски? Потому что живу далеко за пределами исторической Родины, ну и для тренировки, конечно.
Постите комменты на русском, если хотите.
Если кому нужны схемы/файлы - могу поделиться.

Ну и немножко тезисов:

1. Я не аудиофил и не особо тусуюсь на соответствующих форумах, хотя и черпаю оттуда ценные сведения. Я подхожу к делу прагматически - максимум выхлопа за минимальные деньги. Плюс оно обязательно должно быть интересно. Ведь с какого-то момента каждый последующий вложенный доллар уже не приносит удовольствия на целый доллар, и чем дальше - тем меньше.
Я с удовольствием (по возможности) принимаю во внимание советы по совершенствованию акустики помещения, экранирования и т.д., но люди, рассуждающие о направленности проводников или слышимой разнице между воспроизведением loseless c HDD и SSD приводят меня в странное эмоциональное состояние. Но это не страшно, у каждого свой уникальный комплекс заблуждений, в том числе и уменя. И в результате я редко хожу на русскоязычные форумы, поскольку процент максималистов там, к сожалению выше, а я пиписькой не вышел, чтобы меряться ей с Великими Гуру.

2. Я программист, а не электронщик, поэтому могу допускать (и допускаю) глупые косяки. Как электрические, так и механические. Просьба не бить. Если кто-то укажет мне на них, буду крайне благодарен.

3. Я не обладаю идеальным слухом. Не надо спрашивать меня, что звучит лучше, а что хуже - все очень субъективно и слишком сильно зависит от помещения и эмоционального состояния.

4. У меня есть семья, дом и работа, поэтому проекты мои идут крайне неторопливо.


Всем привет!

Sunday, July 6, 2014

One move is worse than two fires

Almost done putting it alltogether.
I got crososver working, BBB with Voyage MPD plays without any drops. The only piece to figure out is volume control (but who neds it?)...

But I have to move to another house. And remodel a kitchen there.
So my exciting project is postponed for several months...

Thursday, March 27, 2014

LCD Screen for Tektronix TDS-544A

Here a story how I replaced a CRT screen with LCD one.

Thanks a lot to the document named "TDS 520B Mod CM Digitizing Oscilloscope Component Service Manual", it reveals some details on scope's guts.

After my lovely CRT screen became a piece of glass, I started to look for alternatives our Chinese brothers can offer.
Not too many.
According to the Service Manual, the scope resolution is 640x480. But the problem is that nowadays it is not very easy to find an affordable LCD with such native resolution. 6.5" 640x480 screens are mostly used in cars and industrial equipment so they are not as cheap as widescreen 800x480 ones. For example, 4:3 screens start from $150 when 16:9 start from $60 with controller.

So I bought AT070TN90 7" 800x480 LCD panel with a controller for less than $70 with shipping from a US seller on eBay.
Luckily controller has 4:3 mode so LCD can display 640x480 picture without any pixel transformation issues. But the bad thing about 4:3 mode is that controller fills unused areas with blue. It sucks. I need to cover it with something. But I have to make a front panel for this screen anyway.

Finally I got new screen working. It took some time to complete. So here what else I needed:

  • anodized aluminium panel (eBay)
  • Radioshack perfboard
  • 12V DC/DC converter (eBay)
  • 1-ft VGA cable (eBay)
  • aluminium bar to make nuts
  • #4-40 tap
  • some wires, screws, and washers
  • epoxy glue
  • nylon PCB stands

AT070TN90

Realtek LCD controller board
Frame was cut from anodized aluminium:

Last test
Radioshack perfboard, 12V DC/DC converter and LCD controller with 1-ft VGA cable
Where to get some power for the LCD
OSD menu buttons. LCD power wires connected to J574 are on the top.
 Finally I put it all together:
The resutl
But for some strange reason some pixels at the bottom of the screen are missing. No way to correct it using OSD menu, but it doesn't affect the signal graph area.

I'm satisfied (but CRT screen was much better). It is a nice feeling when you bring a good device back to life.