Poor man’s code generator

A short time ago, I wanted to find a simple code generator that would run on Windows for helping me to maintain hand-rolled SPICE models files. I was a bit surprised to find none that were no-brainers to install or use. However, I did figure out that OpenOffice’s mail merge feature can be used as a poor-man’s code generator. There’s more than one way to do it, but the process described at Worldlabel.com is the most straightforward for my brain. The key is to “print out” to several files or a single file–depending on what you are generating.

SPICE library management

The following post is all geekspeak. You have been warned.

I am trying to keep my SPICE modeling as platform and vendor-neutral as possible. To help with this, I have come up with the following structure for managing libraries. The idea is to have a file system, e.g.:

- models
    - diodes-inc
        - diodes
        - transistors
        - zeners
    - fairchild
        - transistors
    - onsemi
        - transistors

and in each category (i.e., subdirectory) store your individual model files. The file system, in addition to providing a structure to manage different kinds of parts from of different places, also helps to differentiate models for the same part from different sources.

Now here’s the fun part. So that I don’t have to have a million different .inc or .lib commands in the SPICE simulation’s source (one for each part I use, e.g.,

.lib C:\SpiceDev\models_raw\fairchild\transistors\MMBT2907A.lib

), I aggregate all the models in a given subdirectory into a single library file. Thus, C:\SpiceDev\models_raw\fairchild\transistors in addition to having several individual model files also has the file C:\SpiceDev\models_raw\fairchild\transistors\transistors.lib in it that is an aggregation of all the other files ending in .lib, .mod, or .sp3. So now if I want to use a Farchild transistors, I only need to include a single file:

.lib C:\SpiceDev\models_raw\fairchild\transistors\transistors.lib

Of course I don’t maintain the aggregate library file by hand. Instead I have written an AutoHotkey script that does the job. I place the script in a fixed place and then create links (i.e., shortcuts) to it from the directories containing the model files; but it will also work if you drop the script itself into the directory in which you want to make an aggregate library.

The script goes through each file in a directory (non-recursively) and if the file has a .lib, .mod, or .sp extension it appends its contents to a file named {directory-name}.lib . Both the extension of the output file and the list of aggregated input file extensions can be easily changed in the source code.

One important note: If you want to call the script using a shortcut, make sure the SetWorkingDir command in the code is commented out (as it is below) and also make sure the ‘Start In’ field for the shortcut is blank or points to the desired directory. Enjoy.

;
; AutoHotkey Version: 1.x
; Language:       English
; Platform:       WinXP
; Author:         Copyright (C) 2009 Mithat Konar
; License:        GNU/GPL2
;
; Script Function:
;	Copies contents of all files with extensions specified below into {directotyname}{outFileExtension}
;

#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
;SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.

; To use with a shortcut, make sure SetWorkingDir command above is commented out and
; make sure the 'Start In' field for the shortcut is blank or points to the desired dir.

;===============================================================================
; user-set constants
;===============================================================================
outFileExtension=.lib	; the extension for the output (with dot!)
inExtList=lib,mod,sp3	; list of valid model file extensions (without dots!)

;===============================================================================
; "Main"
;===============================================================================
SplitPath, A_WorkingDir , outFile	; get the name of the active directoty. 

; use %outFile% as working file, then move to %outFile%%outFileExtension%
FileDelete, %outFile%					; just in case, we delete any old version now
FileDelete, %outFile%%outFileExtension%	; just in case, we delete any old version now

FileAppend, *======================================================================*`n, %outFile%
FileAppend, * Generated by %A_ScriptName% on %A_NowUTC% UTC from`n, %outFile%
FileAppend, * %A_WorkingDir%`n, %outFile%
FileAppend, *======================================================================*`n`n, %outFile%
Loop, *.*
{
	if A_LoopFileExt in %inExtList%
	{
		FileAppend, *** File: %A_LoopFileFullPath% ***`n, %outFile%
		Loop, Read, %A_LoopFileFullPath% , %outFile%
		{
			FileAppend, %A_LoopReadLine%`n
		}
		FileAppend, `n`n, %outFile%
	}
}
FileMove, %outFile%, %outFile%%outFileExtension%, 1
FileDelete, %outFile%

LTspice and tube models

Linear Technology’s LTspice is becoming quite popular among audio circuit designers, both professional and amateur. There is a lot to recommend it, but there is at least one issue that is crucial to be aware of if you are planning to use vacuum tube or other third-party models based on arbitrary behavioral voltage or current sources. And that is: LTspice’s implementation of arbitrary behavioral voltage or current sources is not completely SPICE 3 compatible.

In particular (from the LTspice help files),

LTspice uses the caret character, ^, for Boolean XOR and “**” for exponentiation. … This means that when you import a 3rd party model that was targeted at a 3rd party simulator, you may need to translate the syntax such as x^y to x**y or even pwr(x,y).

I ran into exactly this issue when experimenting with SPICE 3 versions of my own tube models.

Google Sites banned

As of 24 June 2009, access to Google Sites has been blocked in Turkey.

Just for giggles, here’s the official English explanation: “The decision no 2009/392 dated 24/06/2009, which is given about this web site (sites.google.com) within the context of protection measure, of Denizli 2. Sulh Ceza Mahkemesi has been implemented by ‘Telekomünikasyon İletişim Başkanlığı’.”

Lest you think that the above is a Google translation, here it is again translated by Google from the official announcement in Turkish: “Denizli 2nd Magistrates of the Criminal Court, dated 24/06/2009 and 2009/392 in the context of this web site nolu PROTECTION MEASURES (sites.google.com) the decision about the Telecommunications Communication Başkanlığı’nca apply.”

Home Cloud

clouds
If the recent rash of netbooks is any indication, cloud computing may actually be gaining traction.

The aspect of cloud computing that’s the most attractive for me is being able to access all your stuff no matter where you are–provided you have a computer with a decent Internet connection and a fairly standard browser. However, there are two very bothersome aspects of cloud computing. First, if you cannot connect to the provider of your cloud service (e.g., your ISP is flaky, the service’s servers are ill, the site has been banned in the country you are in, etc.), you are screwed. Second, no matter what guarantees the provider gives you, your stuff is in someone else’s hands–meaning the provider can legally sniff your stuff for more effective marketing (Google) or it may be illegally hacked into.

However, there is a fairly easy approach to ameliorating both these problems, especially now that capable server hardware has become so profoundly cheap. The idea is simple: instead of having Google, Google Apps, Zoho or whomever host your Cloud apps, host them in your own home on a dedicated computer. As long as you don’t plan to open your Home Cloud to tons of users, the performance demands on the hardware will be pretty small.

When you host your Cloud apps from home, if your ISP goes nuts you will still be able to access your stuff from within your home LAN. While this won’t help you if you need to access your stuff from Starbucks, it is better than not being able to access it from anywhere. Also, when you host your Cloud apps from home, your data stays at home. It still may be open to hacking, but it won’t be available for other purposes. In addition, a would-be hacker would have to specifically target your server, whereas in a hosted situation one breach of the server may make all users’ data available to the hacker.

One downside to the Home Cloud concept is that it places the burden of backing up data on the home user. But this can be greatly simplified by appropriate Home Cloud software.

A bigger problem with the Home Cloud is what all the cool people are now calling “monetization”. In other words, how do you make money off it? End users are becoming increasingly accustomed to getting services for free. Google makes money feeding you ads. Zoho makes money by selling premium services mostly to businesses. Are users willing to pay for Home Cloud software? One possible way forward is to adopt the media server model: dedicated server hardware that’s preloaded with everything needed to make it go and that requires a minimum of user configuration. We may be living in a time where it may actually be easier to sell hardware that encapsulates a task than software.

I’m aware of only a few projects that have a Home Cloud spirit. eyeOS and Lucid Desktop are OSS home-hostable apps that give the user a virtual Web-based desktop. Another project to keep an eye on is Tiny Tiny RSS–essentially a home hostable replacement for Google Reader. All three of these projects are open source software, and it will be interesting to see where all three of these projects go.

A rare moment of accountability

skids
On my way to the office today, a white van barreling down a road that joined mine at a T junction nearly removed my car, and possibly me, from service. Fortunately, disaster was averted by some heavy breaking and staccato tire squealing on my part (no ABS on the 1997 Fiat-TOFAS Tipo).

This in itself is not news. Near-misses in traffic are a million a day here. What made this event special was that the driver pulled over at a suitable spot some 300 meters on, rolled down his window, and poking both arms and his head out of the window gestured toward me for forgiveness.

And it all happened so quickly that I didn’t have a chance to give him a warm huggie to let him know that while I was annoyed at his carelessness I still appreciated his accountability.

P.S. For those of you who thought this entry might have something to do with audio, I have no reason to think that the white van had anything to do with speaker sales.

Can’t find the word

I am looking for a word that means, “I don’t want to leave, but you are making it impossible to stay.” Does it exist?

Bloody f***ing h***


I tried keeping quiet, I really did, but Blogger.com getting banned in Turkey finally broke me down.

Silence


I’ve been experimenting with keeping quiet.

More histrionics

It should come as no surprise that there are more histrionics. Specifically, this.

I am saying nothing because I am at a loss for words.

And there was guarded rejoicing

I hope this is a sign of things to come rather than the manifest end of a potential compromise.

In/out

Out
Joining the recently banned 50Webs is the hugely huge purveyor of Internet radio, Shoutcast. I am just too tired of this to even think up a comment. YouTube is still banned.

In
It looks as though Google Groups have been restored. Ditto comment above about being tired of this.

More bannings

Yeah, I know this is getting old … but no one I know is actually maintaining a history of this deal.

YouTube is blocked again. A newcomer to the blocked list is 50Webs, a web hosting service. A court case in Ankara is responsible for the YouTube ban; a case in Erzurum for the 50Webs ban.

Google Groups are still banned, and WordPress is still accessible

Yeah, it’s getting old … but it’s no less stupid.

Google: out. WordPress: in. Maybe.

On the heels of the Google Groups ban, it appears as though access to WordPress.com (and this blog) has been restored … after an 8 month ban. Whether this lifting of the WordPress ban is a temporary glitch or a real change in policy remains to be seen. The weirdness is not letting up.

Google Groups: banned

Yup. Google Groups has been banned in Turkey. I have no idea why.

Le Mepris

That’s French for “Contempt”—as in the 1963 film by Jean-Luc Godard.

I am teaching a film course this term and decided to try to work “Le Mepris”. I just re-viewed the film before my lecture tomorrow. I meant to watch just the first few minutes but ended up watching the whole thing.

The film is so awesomely awesome on so many levels that it always messes me up. It’s revved by brain and my gut into hyper mode. I really should learn to avoid it. And Godard really ought to have made more like it.

What does this have to do with audio? Almost nothing—except maybe that the music for the film is, like much of the rest of the film, awesomely awesome and does a somewhat subtle though effective job of messing with the semiology of conventions.

Not getting it (a new and different way)

Someone else is not getting it, but in a much different way. As previously discussed, there is a move to close the AKP here for unconstitutional activities—threatening the secularity of the state in particular. Now, I would think that if a bunch of fundamentalist Christians managed to come to power in the EU and started advocating that the Pope become the One True Leader of EU states, more than one EU government would have a problem with that. But apparently I was mistaken.

I guess the really telling quote is, “‘In a normal European democracy, these kind of political issues should be discussed in parliament and decided at the ballot box, not in the courtroom.’” The statement shows that the EU just doesn’t grasp the depth of the issue. For one thing, true democracy does not yet exist in Turkey. And as long as the friends of fundamentalists are in power, it never will. Friends of fundamentalism benefit from, among other things, the ignorance brought about by an underfunded education system, the increasing politicization and desecularization of the available education system, and a technically illegal but still rampant feudal system in the East.

Another aspect that the statement seems to miss is that the AKP has used the holes found in a battered and beaten constitution to make amendments that consolidate their power and guarantee that they can engage in whatever kinds of activities they see fit. More than one totalitarian state has started along similar lines—even some European ones.

In an ideal world, democracies find thier way and correct their mistakes. And sometimes in non-ideal ones as well.

What I said

This is pretty much what I tried to say in my previous post, but Mustafa Özyürek managed to put it much more bluntly: “The approach of ‘I have the majority, I can pass anything in Parliament’ is not correct.’”

The inconvenience of checks and balances

According to this report, the AKP’s strategy to avoid closure is to amend the constitution “… to take the authority to file a lawsuit against a political party away from the chief prosecutor and hand it to Parliament instead.” In other words, if you are the party in power you can never be held accountable for illegal activity and you get to badger opposition parties with threats of closure if they get out of line.

Seems like a good checks-and-balances setup to me. <– (note: sarcasm)

The histrionics of an angry child?

Angry monkey
This place just keeps getting weirder. First, the fundamentalist-friendly powers in government passed laws opening the way to lifting the headscarf ban in universities on the heels of getting their people into the Higher Education Board. This seemed to be the straw that finally got whatever pro-secularists in government to start playing hardball. (Sorry about the mixed metaphor. It was the only way I could think of the incorporate two links.)

This has sent the fundamentalist-friendly into a tizzy. The word on the street is that the “Ergenekon investigation” is now being used as an excuse to intimidate outspoken opponents of the ruling party. There’s also talk that this is part of a strategy to distract people from an attempt to implement a constitutional ammendment that would make it impossible to close the AKP.

This really reminds me of the destructive histrionics that pissed-off (and maybe a little frightened) children engage in when life doesn’t go their way. They don’t care what damage they do and whom they hurt. They can’t be bothered to be reflective. But I have no doubt that the tizzy-fitters don’t see it this way.

These people have a mission more important than man. It gives them strength. And strength with stupidity is a disasterous combination.

P.S. Youtube is unreachable again. Funny how these blockages start on the weekend. I wonder what it is this time and if it has anything to do with the above…

Next Page »


 

July 2009
S M T W T F S
« Jun    
 1234
567891011
12131415161718
19202122232425
262728293031