soundcard as oscilloscope

Jan 27, 2006 34 Replies

I'm trying to use my sound card as an oscilloscope but for some reason it just won't work.



I have a variac hooked up to a breadboard and basicaly just running into a voltage divider and from that into my sound card through its line in jack.



I can control the amplitude of the wave form pretty easy by controlling either a variable resistor or the variac... the problem is that that the wave form looks like crap and I can't rectify it in any way(I put a rectifier as the first component).



Heres a shot of the oscilloscope:



formatting link



It does the exact same thing when I put a rectifier in except if I but it backwards then it does nothing.



I've used several resistor ratios from 10M's down to 50k but nothing seems to work. I'm not sure if it has something to do with the sound card(it should have no problem sampling 60hz mcuh better than it is?) or if its just the wave form is crap cause of the variac or what ;/



Anyone have any ideas?



I was thinking about taking an old pc monitor I have and trying to hack an oscilloscope from it(I don't need anything fancy, just need to displace the waveform)... Is this to much work?



Thanks, AD


Yeah, looks about right. I wouldn't expect the apparent crossover distortion, but suffice it to say the line waveform isn't pretty.

Tim

-- Deep Fryer: a very philosophical monk. Website:

formatting link

Could you give us your real name? First name would be nice.

Doesn't look too bad except for some clipping and a wee distortion.

AFAIK the impedance of some sound cards is pretty low, in the tens of kohm range or so. Also, there may be a bias voltage for an electret microphone on its input. Best would be to post a schematic of what you have wired up so far.

Regards, Joerg

formatting link

heh, looks like crap to me. I'd expect the mains to be more like a sinusoid than a triangle?

From what I could gather the input impedence is 47kOhms with 2Vpp max and I have no idea bout the current.

As I said, I'm simply using a voltage divider(I've did it more complex at first but didn't work well so I just used two resistors in series and took the voltage off the smaller resistor). I tried for many combinations and such...

since I'm using a variac I can choose the voltage so I basically worked from

200Vpp and 20Vpp (so I did like 10M and 250k and 1M and 250k and it allows me to stay ~ within 2Vpp(well, max 5Vpp but)) then I tried other combinations that gave me the ~ the same pp values(all the way down to 50k).

I tried capacitively coupling the "probe"(which is just one mono channel of the stereo input) but it didn't do anything.

The thing I don't like is that you can see the sampling going on... I don't like that blocky look.

thanks, AD

The blocky look comes from a sample rate which is to low. It also looks as if your signal is 8 bit instead of 16 bit. The waveform itself looks fine by me, modern equipment and lighting have a tendency to flatten the sinewave somewhat. Also transient stuff at the zerocrossing is not unusual.

Could be many things:

(1) Using a Variac for a signal source is very hazardous!! Most variacs are autotransformers, so there's no isolation from the power line. You're probably lucky yours is wired correctly, with the neutral wire passing through as the "low" or chassis ground side. Otherwise there would be a big ZAP if the hot wire got hooked up to your sound input, the ground side. Been there, done that.

The AC line can have all kinds of distortion. In our neighborhood some transformer is saturating, as the waveform is mildly clipped. So sez my brother that works for the power company.

So you'd better find a better and safer signal source!

(2) As others have noted, sound card inputs, especially the microphone inputs, have a bit of DC bias voltage coming out, to activate electret microphones. Thats going to feed back and fight whatever circuit you're probing. Better put a 0.47uf 600 volt capacitor in series to block the DC (in both directions).

(3) Another probloem-- the sound card mike input, the ground side, is often tied directly to the computer's chassis ground. Computers usually have a lot of crud superimposed on the ground bus.. That's going to create a ground-loop with your source and add a bunch of stray gibberish in there.

So at best yu're going to end up with a pretty cruddy scope. Barely good for audio. Hope you don't intend to service anything better than a boombox with this setup!

The poor man said he used the LINE input(which is as it should have been),so you might reconsider part of your advice.

ok... I thought I remember reading somewhere where they said the frequency of the mains is "tightly" controlled... which I figure means that that it would be almost 60hz exactly and sinusodial... Mine doesn't look sinusoidal at all and I wasn't sure what it was from.

I was using the highest settings... 48khz and 16-bit(and in another oscilloscope app I used 24-bit at 96khz but same thing).

As long as this stuff is simply due to the mains not being perfect then I guess I can live with it... as long as my stuff wasn't so much the problem.

Thanks, AD

I hooked up the wall jack myself so I know its right...

I'm not so worried about screwing up the soundcard rather than my computer(I got a spare sound card incase it happens(actually I should have put both in and used the old one but I like to live on the dangerous side ;))

Well, I'm not servicing anything but just trying to learn. I like to see visually what's going on as it makes me feel much more comfortable... I just brought about 600$ of stuff(components, pcb making stuff, transformers, switches, pots, etc...) so I can get into it and I can't afford to go buy an oscilloscope now(unless maybe for 100$).

What I've done now is took an old TV and I'm going to use that. I'd found the deflector coils and stuff and now I just have to make the triggering circuits and stuff... its fun to mess with but it makes me a little nervous any time I plug it in(right now I have the variac hooked up to the deflectors so I get some squashed and rotated oval and I can control its size with the variac).

I gotta learn how to make it good though... can't seem to find any detailed info on making a decent one out of a TV ;/

oh well,

Thanks, AD

strange thing is that the jack is a line in/mic... I'm not sure what that means but it seems to work as a line in... (it has a volumn control on it so I guess you get gain from it if you need it for a mic else it acts as a line in).

AD

The frequency of the mains IS tightly controlled, so is the voltage. In fact in most countries (I only know of the UK and Malaysia) there are laws and/or regulations which mandates this. But nobody specified the quality of the 'waveform'. Only the frequency and peak-peak voltage is specified in measuring the quality of the mains supply. You can trust the frequency. You can almost trust the peak-peak voltage. But forget trying to get a perfect, noise free, sine wave out of the mains.

There are a few if's and butt's here. The frequency is tightly controlled, but only over a longer period. This means that due to load variations on the generators, the fequency can be lower or higher than 50/60Hz by a few %, but over a longer period, say one day, you'll get exactly 86400 x 50/60 cycles. This will keep all the digital clocks running right on time. The voltage however, can hardly be tightly controlled due to losses in the powerlines, which heavily depend on the load. So at your AC outlet, the specified 230V can well be somewhere between 200 and 250V.

Meindert

Well, yes, BUT quite a few audio jacks nowadays are "auto-sensing". And as there's no way to auto-sense an open circuit, which is what an electret microphone looks like, many jacks default to applying a DC voltage.

ANd the presence of a DC voltage fits with the symptom that a diode doesnt rectify the signal, it just switches it on or off depending on the diode polarity.

Regards,

A_H

You really can't make much of a scope out of a TV. I tried. The main problems are:

(1) The horizontal sweep has to always run at 15.75KHz, as the CRT high voltage is derived from that. No way around this.

(2) You have to keep the deflection yoke hooked up to the 15.75KHz sweep circuit, otherwise the high voltage won't work. So if you're going to use a different signal to sweep, you have to take off the original yoke and slip on a different one.

(3) The vertical deflection circuit is not linear, and is frequency limited to under 600 Hz or so. No way around this.

(4) You have to build a whole new horizontal sweep circuit. And the horizontal yoke is tuned to resonate at the retrace frequency, so it doesnt work very well at other frequencies.

You can make a cool looking display, but it's nowhere near even a $30 scope.

Have fun and be careful!

I don't know where you're at, but here in the US 20- or 30-year old scopes are readily available in that price range or a lot less.

AC-coupled Eicos and Heathkits with a bandwidth of a few hundred kHz to a few MHz would be overpriced at $20. More typically they're free.

$100 is the ballpark for a mostly working Tek 465, which is a really good scope (100MHz, dual channel, etc.)

I'd be lying to say we're at the peak of the glut of test equipment (that seems to have happened maybe 5 or 6 years ago, and as Don would tell us most of the tech schools dumped all their stuff before that) but there's a lot of it out there at bargain prices.

Tim.

In your typical TV from the past half-century, you're right. But the very cheap $20 TV's at drugstores will let you unhook the horizontal coil and the flyback will continue to make HV.

Again with the little cheap B/W TV's it's not quite as bad as a typical

20-year old console set, but you're right, you cannot push the deflection coils much past what they were designed for.

One can have a lot of fun with a "cool looking display" :-). But you're right, expecting to turn a TV into a scope with bandwidth out of the low audio range, and expecting it to be calibrated too, is way too much to expect from a couple dollars of effort.

And the $20 one might spend on the B/W TV at a drugstore could've ben spent at a hamfest to get a couple old Heath/Eico/etc. scopes. (Mr. Abstract Dissonance might have fun fixing those up!)

Tim.

Yeah... a much safer and perhaps better way to do it would be to build a digital storage box that generates a TV (or VGA or whatever) output to display a picture of the captured waveform. Options there are a computer with soundcard (this thread), A/D board, or perhaps something like an FPGA development board with an A/D chip hooked up to it - Xilinx has a $99 one with a VGA connector. (This is doubly tempting as it could also make a bit of a logic analyzer)

In terms of the current experiment, it seems like finding a wallwart with AC rather than DC output might be a safer way to sample the line frequency than the variac.

Yeah, me, too! :-) We can't just keep calling you "Mr. Dissonance". ;-)

It sounds like you're confusing tight control of the _frequency_ with control of the _waveform_.

The frequency, the power company can and does control.

The waveform, however, once the power leaves the power station, there isn't a thing they can do about the waveform, other than install those big power factor correction capacitors that you sometimes see on line poles.

You're seeing pretty much exactly what you should be seeing with those settings - the resolution of the monitor comes into play and could be aliasing with your sample rate - there are just too many variables in a row to expect any kind of precision from a setup like yours.

But I _do_ concur - DON'T put a variac output directly to a sound card input. Theoretically, the neutral of the mains is at ground, but that's not guaranteed, and you could set up a ground loop that, while not necessarily lethal, could screw up your measurements and/or damage your equipment.

Get some isolation in there.

I'd think a cool project now would be to build an oscillator of some kind and look at its output. A mic into the sound card could also be fun, for a few minutes. ;-) (cf. Microsoft Sound Recorder)

Have fun! Rich

For you young whippersnappers, that's been the case since before the digital clock was even thought of - last millennium, analog clocks used a synchronous motor, locked onto the line frequency; regulating the frequency is not a new phenomenon. :-)

Cheers! Rich

I know, I had one of those synchronous types too, but that is soooo looong ago.... BTW, what is the age limit for a whippersnapper?

Meindert

Join the Discussion

Have something to add? Share your thoughts — no account required.

Didn't find your answer?

Ask the community — no account required