New life for an old tv tuner.

A long long time ago I bought a cheap pci tuner card to listen to the radio. I was able to watch tv with it out of the box but the radio didn’t work. So I patched the driver and it made it into mainline.

Fast forward today, I don’t have a machine with a pci slot anymore but still wanted to listen to airwaves again as my other stereo broke. So I took out the tuner (a tnf 9835) and cooked a simple pygtk app to control it. I looks just like what you can expect from being born from such a quick hack. After trying for a while to make the hardware i2c interface work I settled for a pure software implementation. (also, pull-ups are not optional) I got all the bit masking ops right the first time (but on the other hand that was just copy pasted from drivers/media/tuners with some small edits). It is basically a nice interface around the SN761677.

Compared with my phone the sensitivity is rather poor as it needs quite a bit of an aerial but the sound quality feels better. Alas, the latter is totally subjective.

 

Jinxed.

So, my car sort of appeared.

Without its five tyres, the stereo and speakers, (ok, a cheap one but enough to listen some music), the ashtray and cigarette lighter. Among other things were missing some clothes (a hoodie I really liked and spares for a couple of days), a mix-cd one of my best friends made for me and a cheap spray of vanilla with a touch of chocolate. At one point the ceiling was dismantled because now it feels quite loose. Someone cleared the odometer and made about 100Km after that. Someone else decided that it was funny to cut the drivers seat belt. Oddly enough, the fire extinguisher and the jack were spared.

It was also filled with ashes. That brought back memories of a past I thought long forgotten. No matter how many cans of disinfectant I used or how hard I scrub I still felt dirty, dirty deep inside me. Like it was written with fire on my soul.

I also wrote ‘bribes’ for the first time on my accounting books.

On top of that my laptops power brick died but it was just a matter of a quick splice near the strain relief.

Yay.

Things are looking different today…

Clearly I’m a glutton for punishment.

Today I decided that I can’t have enough and it was time to upgrade my distro so I can play with newer things (and also because google was nagging me to use an updated browser).

I did a dist-upgrade and that not only completed without a hitch but I also had a bit more of free space afterwards. Previously I hammered the thing and then just gave up all hope.

I’m starting to like this new future were things work like they should.

Now that I jinxed it I went full steam with a do-release-upgrade. It is downloading 3277 files at the blazing speed of 20 kB/s.

Let’s see if I still have a working machine by monday.

Chasing misterious 500 errors within php.

For the last couple of days I’ve been investing time learning doing some (serious) things with Drupal and I quite like it, given that for my previous gig involving php I had to manually compile and patch php 5.2 in order to work with a monstrosity made with Textpattern and CakePHP (and a spice of hand crafted databased code).

Last morning I was almost ecstatic reading about Features and went on to make a new one just to try it out.

I select a few components, hit “Download feature” and after a while, nothing. Same happened with “Generate feature”.

On the error.log I see:
2014-10-29 07:49:31: (mod_fastcgi.c.2543) unexpected end-of-file (perhaps the fastcgi process died): pid: 11992 socket: unix:/tmp/php.socket-3
2014-10-29 07:49:31: (mod_fastcgi.c.3329) response not received, request sent: 1106 on socket: unix:/tmp/php.socket-3 for /some_site/index.php?q=admin/structure/features/create, closing connection

That was a bit odd, since the memory limit is set to an ample 256M and it died long before the time limt.

Just to be sure I tried using Apache instead of Lighttpd but no dice.

On the system log I see:

php-cgi[13015]: segfault at bf7c6fcc ip b738201a sp bf7c6fd0 error 6 in libpcre.so.3.13.1[b736d000+3f000]

With that clue I edit php.ini and shave a couple of zeros out of pcre.recursion_limit from the default of 100000. After restarting the server everything worked fine.

I shudder thinking of something that really needs a call stack 100 thousand levels deep. But on the other hand I cut my teeth on a micro with 68 bytes of ram.

Back to basics.

For a course I’m taking at the uni I spent the last weeks programming entirely in assembler for a not very small micro.

Last time I did that for real work was about 12 years ago, dinosaurs roamed the Earth and the 16F84A was popular among my friends here.

It felt quite refreshing but the compiler sometimes behaved like a real jerk.

For instance this was flagged as invalid:

label   db $BA, $DC, $0E

But trimming the spaces made it happy:

label   db $BA,$DC,$0E

(and I spent my weekly cursing budget chasing it)

Fortunately it runs fine under Wine, can be called from a makefile and the debugger/simulator works.

From busted magnetron to incense holder.

It’s been a while since I made something nice.

A couple of weeks ago I spotted a neighbour taking a microwave to the curb and brought it home with me, as they are always full of useful bits. This one was not very old but of a very simple construction. It has a mechanical timer that makes a lovely ‘ding’ when finished. It also went through a bit of hard love.

Cavity magnetrons are very cool devices. Besides providing a couple of strong magnets and aluminum plates they are made of a very pure copper allow with interesting shapes.

From time to time I like to burn some lignum vitae and upon opening this one I knew what to make of it. I chucked it on the drill press, gave it several passes of wet sandpaper and then a cloth with polishing compound. It took quite a good shine but the handling with greasy hands is giving it a light patina. The holes are filled with glow in the dark paint. I haven’t managed yet to capture the effect but they look quite good at night (and also with uv light).

I left the rest without a final polish, partly as a testament of its origins and also because probably I’ll make a cherry wood stand for it.

Adventures in smps carnage I.

A while ago while cleaning the trash pile I thought that it’d be nice to mod one of the many computer supplies to have a variable output. So I picked up the less crappy, replaced the transformer with a one with better turns ratio to achieve a higher voltage output and put a pot on the feedback loop.

At first it kind of worked but with a lot of unstable points and weird modes. Then I realized that I fed the feedback from about 50K when the nominal was near 10K (and also there is considerable input current there). A simple emitter follower took care of that, now there only remains plain oscillations.

The operating point moves a lot considering that I want the output to be adjustable between 5V and 50V and without a fixed load. The original compensation scheme was a plain integrator plus a zero, I can make things a little better slowing it down a lot but what’s the fun on that.

So instead of blindingly doing things I set out to measure the loop response using Middlebrook’s method. I cobbled up a quick python program with Gtk and GStreamer to generate the test signals with a computer soundcard. Initially I expected to just sweep the frequency and measure some points manually on the scope but there is a lot of 50Hz induced interference that together with switching residuals make that task impossible, I really need to perform a synchronous detection in order to get a meaningful result. That means I’ll have to make room for some more quality time coding to get the scope samples in an automated fashion. The usb protocol is documented here ( http://elinux.org/Das_Oszi_Protocol#0x02_Read_sample_data ).

The setup is a far cry from the ones depicted in the famous AN70 by Jim Williams. I used an H-Field probe to rule out magnetics as an interference source. I expected the output filters and the transformer to be troublesome but their effects on the point of injection are negligible. On the other hand, long wires on the feedback path (even twisted) and the snap recovery diodes aren’t a good match.

 

Isolated trigger output

So I finally added an isolated trigger output to that pulse generator. It is just a gdt from a no brand computer supply driven from another gate so it does not disturb that much the main output. The 100ohm on the secondary it’s there so I don’t forget which are the right leads and that capacitor in parallel with the 1k on the primary is not really needed but it made things nicer with the first transformer I used.

It works as expected:

The ratio is 5V / 0.8V = 0.16 , so that 1k I’ve put on the primary appears as 1k * (0.16^2) = 25.6 Ohm on the other side and matching to 50Ohm is as easy as putting a series resistor.

I already knew that the level shifter has a turn off delay of about 1.3uS compared to the output from the 4093 (look at that, it is 23 years old!). The main contributor to that is the last transistor (a PNP), as I just slapped a 1k resistor from base to emitter and called it a day. On the range of voltages I am interested even if the output latches the dissipation involved is way inside a safe zone, but the cost of that simplicity is that I am not able to bring it into cutoff just as fast. Replacing that with a 220 ohm improves things a bit but it is not the ultimate solution. Anyway, I like it as it is.

Things I hate this month.

Printers and insurance companies.

So, it happened that I needed to print something at the last moment and the printer refuses telling me that it is out of toner. The funny thing is that it ‘knows’ this just by counting the amount of pages printed and I can certainly tell it is not true, as it still feels quite heavy. But, if I command it to print a self test page it cheerfully goes on. I am just one bit flip away of using it but no time to play with its innards.

Almost two months after I was rearbumped both insurance companies (Copan and Federación Patronal. I despise you.) play dumb and try to put the blame on each other. And I am getting increasingly impatient and angry.

Meanwhile, our car is still wrecked. I’m just going to fix the lock on the trunk so it closes properly again. Lately I was thinking on selling it and buy something more family-friendly (and comfortable) and performing all the needed repairs costs way more than what the increase on the sale price can be. I don’t really care what the broken windows theory says about it.

Emptyness

Lately I’ve been living most of the time alone on a house that used to host from four to six people and boy, it feels quite strange.

I can’t say I understand them but I’m starting to do things that always seemed a little weird to me before.

I arrive in the evening to be greeted by an all encompassing silence, I turn on the lights on many rooms, otherwise I feel a bit uneasy (and it is a pitch black here). I also find myself talking a lot more to my cats and thinking out loud.

All of a sudden lots of sounds, that were always here, step to the foreground. I can hear a faucet dripping on the far end. Kind of like the first time I wore earplugs and I started to hear my inner machinery.

Shafted.

A wonderful rainy night of July I stop as the semaphore turns red. The car behind doesn’t and stomps on my back. So does the one behind it. I file complaints against both insurance companies. After a month and a half both decide that it is not their responsibility and start playing games. Meanwhile the back of my car is still trashed.

So, Copan and Federacion Patronal, even thou you treated me well when doing all sorts of boring paperwork at your premises, I do not like you. Not a single bit.