Friday, April 17, 2009
In the background while I'm writing this Sky are showing a film called "Doomsday", it's a sort of post-apocalypse mad-max rip-off set in scotland. Loonies on motorbikes, thunderdome type scenes.
I can't really imagine why they didn't just call it "Mad Mac's" and have done with it.
Friday, April 10, 2009
A recent batch of 25 turned out to have four failures, when moved up and down they would not remain flat, basically the actuator at the foot end of the bed was not being controlled correctly - it was not moving as far as the actuator at the head end, only about 60% of the distance. The four were so consistent (all showing nearly the same degree of tilt) that we decided it pretty well had to be a software issue, hard as that was to explain.
But it wasn't - let me digress back a few years to the start of the project:
When the first bed hardware (frame and actuators) arrived for us to design the control electronics it came with a example mattress. These medical mattresses are not as you might expect - designed with disease control in mind they are waterproof and made of materials that can survive being steam cleaned. Basically they're dense and covered with some polymer that resembles rubber. And they are supplied, as most things are, in a plastic cover.
I must stress that in the eternal war of man against mattress these may be regarded as special forces, highly trained and motivated opponents. If you are asking yourself "what war?" then you are either damned lucky or have not yet made love in an uncooperative bed. But that's another saga.
So, picture the scene - we have a dirty-great mattress standing up on end against a wall with a polythene cover that needs to be removed. Along comes an unsuspecting Leon, I guess he winds up doing this because he just happened to be tall enough to reach the top of the mattress. As the only other person involved who is tall enough to have done this I must now give thanks to the gods of laziness who were smiling upon me on this occasion, because Leon walked over to the mattress as I was getting to my feet, grabbed the polythene bag near the top of the mattress and tugged it off with a manly flourish.
It was probably the last manly flourish or tugging off he managed for some time, because as he did this the friction between the polythene and the mattress built up a massive static charge which then discharged between the centre of the mattress and the part of Leon that happened to be closest to it as he lent backwards... The flash was visible in a brightly lit room, and the crack, while not exactly thunder, certainly wasn't a tiny little "click!" either... Leon clutched at his groin, managed a strangled squeak and collapsed. The mattress then celebrated its victory over humanity by slowly collapsing on top of him, which was followed by a general collapse of everyone who'd witnessed this event...
"You... Bastards..." Leon managed to say, after some considerable time had elapsed. "Get this... this... THING... off me"
Well, actually he probably said it a few times before we noticed, we were far too busy trying to breathe. Excessive laughter can be dangerous...
Anyway, the upshot of this is that removing the bags from these bloody mattresses is deadly. You don't do it fast. Given the chance you don't do it at all, you give the mattress in its bag to some poor unsuspecting suckers and let them find out for themselves, as we did.
"Do you know what happens if you remove the bag quickly?" I asked the supplier.
"Don't" they said.
"You don't know?"
"No - don't remove the bag quickly"
"Thanks. I'll tell Leon that."
Knowing this at the start I designed the electronics with more of an eye to static protection than is normal, and it was successful because we have built a fair number of these beds without further problems (though other equipment the beds take a dislike to has been destroyed by it, they don't always choose the kinetic energy weapon option).
So, what about these four failing beds? Well, yep - static damage. They'd been built, calibrated (to define the range of movement allowed, etc), and then the mattresses had been fitted, only this time they'd done four of them differently - someone had put the mattress on the bed before pulling the bag off and also done this in such a way (yet to be determined) that the discharge was through the same actuator of all four beds. This then overpowered and destroyed a filter component (ironically something that was only there to protect the rest of the electronics from this very static) and did so in almost the same way on all four beds. It went from looking like a ~10nF capacitance to resembling a ~25K resistance, with all four having more or less the same resistance when dead... This added resistance then loaded the actuator's position sense pot, destroying the linearity, so the bed control loop thought the beds were flat when they weren't.
This input protection laughs at human-body model static discharges, you understand. Eats them for breakfast, so gods alone know how much energy is involved with these combat mattresses.
I now suspect this is the real reason why nurses are forever warning people not to sit on the beds during hospital visits. They're trying to do us all a favour, they know the evil forces that lurk beneath that innocent looking exterior. Be afraid. Be very afraid...
Interesting, eh? What? Well I didn't say it was very interesting... Oh, well, suit yourselves...
The idea has occasionally wandered across my mind (leaving a messy trail) that the audio outputs of a modern PC should be capable of generating fairly high quality audio test signals, and further that if the PC audio inputs are up to scratch they could be used to digitise the results of stuffing these test signals through external equipment-under-test, so that with a bit of signal processing jiggery-pokery the PC should be capable of quickly providing THD readings, frequency response curves (for RIAA networks and the like) and so on and so forth, basically the sort of things I used to do (albeit crudely) in the seventies with test gear that cost monopoly money (to build, that is, couldn't just buy it. Or would have cost the earth if I'd had any money. I was making it up as I went along with bits and pieces I managed to beg, borrow or, um, liberate).
This is hardly original, I hear you think. "Well, it was when I first did it" I respond grumpily, "analysing audio output stages using boxcar sampling thirty years ago. All my own ideas, too. Were you even born? Huh?" And other suchlike grumping sounds that an olde dinosaur makes when challenged. Where was I? Oh, yes...
In fact, aside from electrical noise (hard to avoid inside a PC) I'd have thought that a modern audio DAC/ADC combination from even the cheap end of the PC market would comprehensively outperform the hardware I was using back then. Hah! Foolish crem...
So, tonight while I'm feeling a little under the weather (man flu setting off an opportunistic dental abscess) I decide to have a play with this idea rather than doing anything particularly demanding. A few minutes in Delphi generating an accurate sinewave (no - I'm not slowing down - you can generate an inaccurate sinewave in seconds, but doing it properly requires it to be generated with correct dithering (TPDF) applied to the fractional bits that would otherwise be truncated, and that needs a little thought) and lo - I'm sat here listening to a 1KHz sinewave. Sounds nice enough and everything's looking good for a quick and dirty THD test set until I look at the waveform on t'scope.
(A special hell is reserved for anyone even thinking about questioning the triangular dither. If you think it could be better using a shaped function then you need to brush up on dithering - shaped functions are only suitable for final output - you really don't want to skew the noise frequency distribution going in to the gear under test. Running error accumulation instead of dither? Just don't. Tie the dither generation into the ADC with synchronous correction in the readback? Good thinking but not with unknown systems inbetween... Besides, it's not always a sinewave and I'd hardly tell you what I'm intending to do with this eventually, would I? triangular it is then. Good...)
Now, I admit I was expecting a reasonably clean looking sinewave. Dumb, but I admit it. Oh, crem-the-eternal-pessimist was expecting noise, and hum, and mush of various kinds, but with a smooth sinewave hiding underneath it all none the less. A sinewave lurking behind the sort of noise and mush that will average out give enough signal processing, is the point. Hah! Idiot. I'm not feeling well, that's my excuse.
Here it is:
Magnified (x2.5 post sampling):
Well, it's a sinewave, I suppose, but at first sight it looks like a sinewave generated using a raw 8-bit DAC. Very reminiscent of the stepped waveforms I'd expect from a cheap embedded design that didn't care much, not a supposed high quality (hah) DAC system.
So, does this motherboard, which claimed good audio qualities, use short DACs? A moment of experimentation and it becomes clear - it's not a short DAC but the cheapskate designers of the motherboard haven't applied any analogue reconstruction filter to the output... Nada. Zip. Not even a token RC filter...
Same again, but at 10KHz:
I suppose we should be thankful that they've at least upsampled the digital data to 96KHz, so at least most of the shit they're throwing out is well outside the audio band. Mind you, I bet they did that so they can cut back on the DAC length/ADC input filters and then just didn't bother to fit either. Gah...
Oh, I know, I could always use off-board audio hardware but that's not the point; if this is the normal sort of performance the idea's useless. Gah.
My laptop does rather better, clean looking sinewaves at 1KHz and 10KHz, so filtered at least, though that might be just the headphone driver not keeping up with the edges ;)
[that lot was edited into some degree of coherence after some sleep]
Maybe I was being too picky anyway. Even for simple tests I'd probably use the stereo outputs to generate antiphase signals and then use a differential amplifier to get rid of as much common mode noise as possible, so it's no great bother to put a quick and dirty reconstruction filter in/in front of that stage... I wonder if it's worth doing the same sort of thing going back in; turn the signal into a differential pair for the stereo inputs and subtract them in software? Have to think about that, doubt it'd do that much good. Hmm...