Oscilloscope Stray Signals

For the discussion of the sciences. Physics problems, chemistry equations, biology weirdness, it all goes here.

Moderators: gmalivuk, Moderators General, Prelates

User avatar
Girl-With-A-Math-Fetish
Posts: 205
Joined: Mon Jun 30, 2014 9:02 am UTC
Location: The Complex Plane in the Mandelbrot Set
Contact:

Oscilloscope Stray Signals

Postby Girl-With-A-Math-Fetish » Mon Nov 24, 2014 4:57 am UTC

I was mucking around with my scope today and I realized that touching the probe would display a distinct stray signal. I realized that I was acting as an antenna and that I was picking up mains. On average, from where I was sitting, it'd show that I was picking up 100-150mV or so. Sometimes I'd pick up a full volt or even more. When you do this with your scopes, is the signal this great? Or am I just sitting in a very e-smoggy location? Or is my scope borked?

Sorry for the really crappy audio/video quality, but:

https://www.youtube.com/watch?v=fPcQYt23IoM
I'm sexually attracted to the International Space Station. You have now had your daily dose of Internet.

User avatar
Neil_Boekend
Posts: 3220
Joined: Fri Mar 01, 2013 6:35 am UTC
Location: Yes.

Re: Oscilloscope Stray Signals

Postby Neil_Boekend » Mon Nov 24, 2014 10:39 am UTC

Yes scopes do pick up the net. Coaxial cables less so than banananana plug cables (in a BNC adapter).
I haven't got a scope here so I can't check whether 100-150 mV is low or high. It feels low though, did you attach any cables at all? 'Round here a multimeter will usually display a couple of V when the leads are extended. (although I must admit that the last time I used even a multimeter is years ago)
Proper grounding solves it.
Mikeski wrote:A "What If" update is never late. Nor is it early. It is posted precisely when it should be.

patzer's signature wrote:
flicky1991 wrote:I'm being quoted too much!

he/him/his

User avatar
Girl-With-A-Math-Fetish
Posts: 205
Joined: Mon Jun 30, 2014 9:02 am UTC
Location: The Complex Plane in the Mandelbrot Set
Contact:

Re: Oscilloscope Stray Signals

Postby Girl-With-A-Math-Fetish » Tue Nov 25, 2014 12:04 am UTC

Neil_Boekend wrote:Yes scopes do pick up the net. Coaxial cables less so than banananana plug cables (in a BNC adapter).
I haven't got a scope here so I can't check whether 100-150 mV is low or high. It feels low though, did you attach any cables at all? 'Round here a multimeter will usually display a couple of V when the leads are extended. (although I must admit that the last time I used even a multimeter is years ago)
Proper grounding solves it.


Yeah I noticed that if I touched something with chassis ground, that the signal significantly drops. I do remember my scope would only show about 20-30mV unless I rapidly tapped together the leads. The cables... well, you mean other than the scope probe? Nope. If I touched a power cable or something, I would get about 1V of a reading. Now I really see why my teacher stressed the importance of grounding logic chips. I mean, I used them long before I took the class (I hardly learned anything in the class since it was so basic despite three years of it I pretty much knew everything going in there). And I knew that we had to ground unused pins on logic chips because of them acting as antennas and picking up noise that could screw up the logic. But its one thing to understand the concept and another to really see the reasoning behind it in action. So strange. SCIENCE!
I'm sexually attracted to the International Space Station. You have now had your daily dose of Internet.

User avatar
Neil_Boekend
Posts: 3220
Joined: Fri Mar 01, 2013 6:35 am UTC
Location: Yes.

Re: Oscilloscope Stray Signals

Postby Neil_Boekend » Tue Nov 25, 2014 11:01 am UTC

Girl-With-A-Math-Fetish wrote: The cables... well, you mean other than the scope probe? Nope.

no, I sort of mean the scope probes. Many tests are done at low frequencies where the cable quality doesn't really matter. We often used these type of connectors:Image
with bananananana cables like you use on a multimeter instead of real probes. This can be easy, although these tests do tend to pick up a lot more stray signals.

In university (HBO, I'm not quite sure how that translates) our scopes had BNC connectors on them. You could plug a scope probe in them but often we'd simply use a BNC to 2x bananana and a few bananana cables. Our school only used breadboards on simple stands with sufficient banananana plugs to connect most stuff so our breadboard projects usually used banananana dem to connect to measurement equipment.
It allowed for quickly cleaning up your work space, unplugging power and scope in seconds and storing your project in tact in a closet. In theory at least :D.

The next part is just in case you are studying to become an electrical engineer.

Scope probe cables are specialised in 2 things:
1. Transmitting high frequency signals without distortion from one end to the other.
2. Keeping interference out.
These two demands require coaxial cables. The less flexible the better. Higher frequency or lower distortion means extremely inflexible cables. One project used signals up to 40 GHz, these cables were approx Ø 2 cm and should not be bend tighter than, say, 40 cm radius. It probably wouldn't have been easy either but I never tried.

When actually working with them flexible cables are easier. Low frequency signals (except close to mains frequency) can usually be measured quite well with simple bananana plug cables like you use on a multimeter.
For example checking the timing on a 555 astable multivibirator at 1 kHz. Often you don't care about the exact signal shape, you usually just want to see the frequency and sometimes the duty cycle.

An experiment:
Set up a signal generator with a simple square block signal. Start, for example, at a kHz (don't pin me on it, but I'd guess that under a kHz nothing much will happen, except for around mains. The distortion we are looking for might not happen until much higher though, depending on approximately a million things).
Split the signal directly after the signal generator with a BNC splitter.
Route one to your scope with a decent BNC cable. This is your reference.
Convert the other to bananana dem with such a convertor as in the picture. Route only the center pin of the BNC with a bananana cable to another BNC-bananana adapter on another input of the same scope. With the connectors in the picture you should connect red-red. Since you have already grounded with the BNC cable connecting the grounds (black) isn't really required. Don't ever ever connect red-black in such a setup. It can result in expensive smoke and angry teachers.
Display them both, look at what happens to the signal over the bananananananananana cable.
Shift the frequency of the signal generator, see what higher frequencies do.
Exchange the banananana cable with a longer one if you have it. Longer cables tend to change this.
Disconnect the cables from the signal generator and check the signal you get at mains frequency (60 Hz in the US). There should be a big difference between the bananana cable and the BNC.
Move the bananana cable without disconnecting it while you look at the scope at mains freq. Move the BNC cable.

This will help you figure out when a real scope probe is required versus when a bananananana cable is sufficient. It will also help you detect certain problems in circuits and when to consider these effects in your designs.
Mikeski wrote:A "What If" update is never late. Nor is it early. It is posted precisely when it should be.

patzer's signature wrote:
flicky1991 wrote:I'm being quoted too much!

he/him/his

User avatar
Girl-With-A-Math-Fetish
Posts: 205
Joined: Mon Jun 30, 2014 9:02 am UTC
Location: The Complex Plane in the Mandelbrot Set
Contact:

Re: Oscilloscope Stray Signals

Postby Girl-With-A-Math-Fetish » Tue Nov 25, 2014 11:10 pm UTC

Oh this is a real scope probe, not a banana (why all the nanas lol) cable. I'm just a hobbyist, really, and I don't do as much with electronics as I used to. I lost my touch with it. The BNC thing seems unnecessary at the moment, but I guess I should build a 555 test circuit just to see how accurate the scope is.
I'm sexually attracted to the International Space Station. You have now had your daily dose of Internet.

User avatar
PM 2Ring
Posts: 3652
Joined: Mon Jan 26, 2009 3:19 pm UTC
Location: Mid north coast, NSW, Australia

Re: Oscilloscope Stray Signals

Postby PM 2Ring » Wed Nov 26, 2014 2:06 am UTC

Probably a Discworld ref:

“Nanny Ogg knew how to start spelling 'banana', but didn't know how you stopped.”
― Terry Pratchett, Witches Abroad

FWIW, when I was 10 my Christmas present was a cathode ray oscilloscope, in kit form. (My step-dad was an electronics technician, and the kit was one of the products of the company that he worked for). It kept me amused for a few years. I eventually donated it to my high school.

User avatar
Girl-With-A-Math-Fetish
Posts: 205
Joined: Mon Jun 30, 2014 9:02 am UTC
Location: The Complex Plane in the Mandelbrot Set
Contact:

Re: Oscilloscope Stray Signals

Postby Girl-With-A-Math-Fetish » Wed Nov 26, 2014 3:23 am UTC

PM 2Ring wrote:Probably a Discworld ref:

“Nanny Ogg knew how to start spelling 'banana', but didn't know how you stopped.”
― Terry Pratchett, Witches Abroad

FWIW, when I was 10 my Christmas present was a cathode ray oscilloscope, in kit form. (My step-dad was an electronics technician, and the kit was one of the products of the company that he worked for). It kept me amused for a few years. I eventually donated it to my high school.


Ehehehe I thought so :P

My dad got this for me when I was 9ish. Maybe 8 or 10. I don't remember exactly when. Might have not been 9 since we lived in Aussie that year. He used to fix the things before he moved to America (might have been before he met my mom. He somehow knew I'd want one when I became older. I still remember the first day I saw it. I was super intrigued by the bluish green line that flickered across the screen, and I think I sat there for a fair amount of time playing with all the knobs x3
I'm sexually attracted to the International Space Station. You have now had your daily dose of Internet.

User avatar
Neil_Boekend
Posts: 3220
Joined: Fri Mar 01, 2013 6:35 am UTC
Location: Yes.

Re: Oscilloscope Stray Signals

Postby Neil_Boekend » Wed Nov 26, 2014 7:25 am UTC

Girl-With-A-Math-Fetish wrote:(why all the nanas lol)

Leftover from the last Madness. Not a forum filter, but a chair-keyboard interface filter.
Girl-With-A-Math-Fetish wrote:but I guess I should build a 555 test circuit just to see how accurate the scope is.

Do: they are cheap, easy and quite useful in many applications. At low frequencies they are quite good. I believe the limit for a normal 555 is about 500 kHz but I don't know the signal deformaton at that freq.
A khz is useful for PWM-ing a LED.
150 - 200 kHz is useful PWM-ing a motor. Don't go too low with a motor, they emit noise at the PWM freq and you wanna stay away from the hearing range for animals. Bats can hear over 100 kHz and eat bugs.
Mikeski wrote:A "What If" update is never late. Nor is it early. It is posted precisely when it should be.

patzer's signature wrote:
flicky1991 wrote:I'm being quoted too much!

he/him/his

Seraph
Posts: 342
Joined: Mon Jul 16, 2007 4:51 pm UTC

Re: Oscilloscope Stray Signals

Postby Seraph » Wed Nov 26, 2014 7:14 pm UTC

Girl-With-A-Math-Fetish wrote:Oh this is a real scope probe, not a banana (why all the nanas lol) cable. I'm just a hobbyist, really, and I don't do as much with electronics as I used to. I lost my touch with it. The BNC thing seems unnecessary at the moment, but I guess I should build a 555 test circuit just to see how accurate the scope is.

I'd think that unless your scope is really broken it will be orders of more accurate than your 555 test circuit. That is, any error you see timing wise will almost certainly be in the test circuit. The frequency of a 555 clock is determined by a capacitor and some resistors, both of which are not components that are known for their precision. For a few bucks you can buy an oscillator (These are generally 4-pin devices, voltage goes in, a clock signal comes out) from someplace like digikey that will be pretty accurate, or you could buy your own crystal and put together a pierce oscillator.

User avatar
Girl-With-A-Math-Fetish
Posts: 205
Joined: Mon Jun 30, 2014 9:02 am UTC
Location: The Complex Plane in the Mandelbrot Set
Contact:

Re: Oscilloscope Stray Signals

Postby Girl-With-A-Math-Fetish » Thu Nov 27, 2014 8:36 am UTC

Seraph wrote: For a few bucks you can buy an oscillator


By "a few bucks" what do you mean? < 10 bucks?
I'm sexually attracted to the International Space Station. You have now had your daily dose of Internet.

User avatar
Neil_Boekend
Posts: 3220
Joined: Fri Mar 01, 2013 6:35 am UTC
Location: Yes.

Re: Oscilloscope Stray Signals

Postby Neil_Boekend » Thu Nov 27, 2014 9:08 am UTC

Sorry, I misread your idea to use a 555 to measure your scope. It doesn't work, as Seraph said.
According to this 555 datasheet there are multiple types of timing errors in the thing. 2.25% base timing error, + 150 ppm per°C + 0.3% per V supply.
Shape deformation isn't even mentioned. There could be a 10% V difference between the beginning and the end of the block and it would still be within these specs.
Something like this:
Image
This is because this isn't a problem in most 555 applications. You just need to saturate a MOSFET transistor into full conducting or something like that. And shape deformation probaly depends strongly on the quality of the other components.

All in all you'll be able to measure the accuracy of the 555 with your scope instead of the other way around.
It is, however, a nice source for the cable test. You can assume next to no change with your probes and thus it is a reasonable reference.
Mikeski wrote:A "What If" update is never late. Nor is it early. It is posted precisely when it should be.

patzer's signature wrote:
flicky1991 wrote:I'm being quoted too much!

he/him/his

User avatar
Girl-With-A-Math-Fetish
Posts: 205
Joined: Mon Jun 30, 2014 9:02 am UTC
Location: The Complex Plane in the Mandelbrot Set
Contact:

Re: Oscilloscope Stray Signals

Postby Girl-With-A-Math-Fetish » Thu Nov 27, 2014 12:58 pm UTC

Neil_Boekend wrote:It is, however, a nice source for the cable test. You can assume next to no change with your probes and thus it is a reasonable reference.


Hmmm... now I only have to find all of my 555s and electronics components xD
I'm sexually attracted to the International Space Station. You have now had your daily dose of Internet.

User avatar
Neil_Boekend
Posts: 3220
Joined: Fri Mar 01, 2013 6:35 am UTC
Location: Yes.

Re: Oscilloscope Stray Signals

Postby Neil_Boekend » Thu Nov 27, 2014 1:09 pm UTC

Girl-With-A-Math-Fetish wrote:
Neil_Boekend wrote:It is, however, a nice source for the cable test. You can assume next to no change with your probes and thus it is a reasonable reference.


Hmmm... now I only have to find all of my 555s and electronics components xD

Only if you have no signal generator. For the cables experiment you simply need a square-ish signal with configurable frequency. The source can either be a 555, a signal generator, a different oscillator with an output mosfet or a small alien with an insanely fast hand (might not exist) and a push button.
Mikeski wrote:A "What If" update is never late. Nor is it early. It is posted precisely when it should be.

patzer's signature wrote:
flicky1991 wrote:I'm being quoted too much!

he/him/his

User avatar
Girl-With-A-Math-Fetish
Posts: 205
Joined: Mon Jun 30, 2014 9:02 am UTC
Location: The Complex Plane in the Mandelbrot Set
Contact:

Re: Oscilloscope Stray Signals

Postby Girl-With-A-Math-Fetish » Fri Nov 28, 2014 10:50 am UTC

Neil_Boekend wrote:Only if you have no signal generator. For the cables experiment you simply need a square-ish signal with configurable frequency. The source can either be a 555,


I unfortunately don't. My dad's the kind of guy that'll buy me one piece of expensive equipment on a whim, without understanding (ironically so since he used to fix these things) the importance of the other tools.
I'm sexually attracted to the International Space Station. You have now had your daily dose of Internet.

User avatar
Neil_Boekend
Posts: 3220
Joined: Fri Mar 01, 2013 6:35 am UTC
Location: Yes.

Re: Oscilloscope Stray Signals

Postby Neil_Boekend » Fri Nov 28, 2014 12:43 pm UTC

Not all signal generators have to be expensive. They can even be free. Did you know an Android device can abuse it's audio port to create a limited function generator? There are many similar apps (this one doesn't require additional rights, as a signal generator should) and Apple devices will probably have similar possibilities.

You can connect them by stripping the cables on a 3.5 mm (1/8") plug headphones (preferably broken headphones with a good plug) or with a 3.5 mm plug from ebay.
Depending on what you want you could also connect directly to BNC. Be sure to get a stereo because in some weird cases a mono one can damage your phone. Usually it doesn't but I can't guarantee it. You could also connect them via a 3.5 mm stereo to 2x 3.5 mm mono plug.

If you'd rather have a separate device Ebay has multiple options:

They are not always expensive (warning, will probably sell for a bit more than $0.99)
Also, this thing only goes to 20 kHz for square waves. For sine signals it goes to 500 kHz so a decent comparator circuit will bump that to 500 kHz.
If you don't mind building a box for it $14.07 will get you a square wave generator up to 65 kHz.
Old ones are often still quite good. $100 will get you an HP/Agilent that goes up to 11 MHz for square waves (at least, according to the data sheet)

Warning, I have not owned any of these devices. I merely want to point out that not all signal generators are expensive.
Mikeski wrote:A "What If" update is never late. Nor is it early. It is posted precisely when it should be.

patzer's signature wrote:
flicky1991 wrote:I'm being quoted too much!

he/him/his

User avatar
Girl-With-A-Math-Fetish
Posts: 205
Joined: Mon Jun 30, 2014 9:02 am UTC
Location: The Complex Plane in the Mandelbrot Set
Contact:

Re: Oscilloscope Stray Signals

Postby Girl-With-A-Math-Fetish » Sat Nov 29, 2014 4:59 am UTC

Neil_Boekend wrote:Did you know an Android device can abuse it's audio port to create a limited function generator?
You can connect them by stripping the cables on a 3.5 mm (1/8") plug headphones (preferably broken headphones with a good plug) or with Be sure to get a stereo because in some weird cases a mono one can damage your phone.


This should be good for me for now :3
I have a cable that's double headed (for plugging in an MP3 player to a speaker). Would this work?
I'm sexually attracted to the International Space Station. You have now had your daily dose of Internet.

User avatar
PM 2Ring
Posts: 3652
Joined: Mon Jan 26, 2009 3:19 pm UTC
Location: Mid north coast, NSW, Australia

Re: Oscilloscope Stray Signals

Postby PM 2Ring » Sat Nov 29, 2014 5:14 am UTC

Why not give it a try and see what happens? Assuming your 'scope's properly earthed, neither device should cause the other to blow up. :)

But as Neil said, the simplest way to get the audio signal from your phone into your 'scope is to use an old earphone cable plugged into the phone's earphone socket.

If you can program, it's pretty easy to generate simple wave files. But you can also get them in .WAV format from sites like this one. WAV is good for stuff like this because it's basically the raw waveform with a little bit of header info that describes the data format. Of course, an MP3 file would be much smaller, but MP3 uses lossy compression, so the waves you get when you play back an MP3 aren't exactly the same as the waves that were recorded.

User avatar
Girl-With-A-Math-Fetish
Posts: 205
Joined: Mon Jun 30, 2014 9:02 am UTC
Location: The Complex Plane in the Mandelbrot Set
Contact:

Re: Oscilloscope Stray Signals

Postby Girl-With-A-Math-Fetish » Sat Nov 29, 2014 12:31 pm UTC

PM 2Ring wrote:If you can program, it's pretty easy to generate simple wave files.


I know really rudimentary programming, and I'd assume it shouldn't be too hard to generate sounds.
I'm sexually attracted to the International Space Station. You have now had your daily dose of Internet.

User avatar
PM 2Ring
Posts: 3652
Joined: Mon Jan 26, 2009 3:19 pm UTC
Location: Mid north coast, NSW, Australia

Re: Oscilloscope Stray Signals

Postby PM 2Ring » Sun Nov 30, 2014 7:18 am UTC

Here's a fairly simple sine wave generator I wrote a few years ago for Python 2; it won't run on Python 3. It uses Python's standard wave module to handle the "bookkeeping" details of creating WAV files. It should be fairly easy to modify it to make other types of waves, even if you aren't very familiar with Python.

The files it creates always contain a whole number of cycles, with the first sample at a zero crossing (i.e., on the X axis) and the last sample being one sample before a zero crossing, so if you loop it the sound should be smooth with no glitches.

Code: Select all

#! /usr/bin/env python

'''  Simple sine wave tone generator
Saves data as a mono WAVE file.

Written by PM 2Ring 2012.11.27
'''

import sys, getopt, wave
from math import sin, pi
from struct import pack

#Scaling factor for 16 bit samples
mm = 2**15 - 0.5

#Frequency, Duration, Volume
def tone(frequency, duration, volume, rate):
    #Adjust duration to give a whole number of cycles
    c = frequency * duration
    duration = int(0.5 + c) / frequency
    print >>sys.stderr, 'Cycles:', frequency * duration
    print >>sys.stderr, 'Adjusted duration:', duration
   
    volume *= mm
    a = 2 * pi * frequency / rate
    n = int(0.5 + rate * duration)     
    #n += 1                      #Add 1 to get zero crossings at first & last samples.

    #Make wave, convert floats to bytes in Little Endian, and pack into strings
    return n, [pack('<h', int(0.5 + volume * sin(i * a))) for i in xrange(n)]

def main():   
    #Default args
    rate = 44100                #Sampling rate. This default is the standard CD sampling rate.
    frequency = 110.0           #Tone frequency in Hz
    duration = 0.5              #Tone duration in seconds
    volume = 0.8                #Volume. 0 <= v <= 1.0
    fname = "sine.wav"

    def usage(msg=None):
        s = msg != None and '%s\n\n' % msg or ''
        s += '''Sine wave tone generator. Saves data as a WAVE file.

Usage
%s [-h] [-f frequency=%f] [-d duration=%f] [-v volume=%f] [-r sampling rate=%d] [-n] filename=%s'''
        print >>sys.stderr, s % (sys.argv[0], frequency, duration, volume, rate, fname)
        raise SystemExit, msg != None

    try:
        opts, args = getopt.getopt(sys.argv[1:], "hf:d:v:r:n:")
    except getopt.GetoptError, e:
        usage(e.msg)

    for o, a in opts:
        if o == '-h': usage(None)
        elif o == '-f': frequency = float(a)
        elif o == '-d': duration = float(a)
        elif o == '-v': volume = float(a)
        elif o == '-r': rate = int(a)
        elif o == '-n': fname = a

    if len(args) > 0:
        fname = args[0]

    print >>sys.stderr, 'Creating wave.\nSampling rate:', rate
    print >>sys.stderr,\
    'Frequency: %f, Duration: %f, Volume: %f' % (frequency, duration, volume)

    n, samples = tone(frequency, duration, volume, rate)

    print >>sys.stderr, 'Saving to %s ...' % fname
    f = wave.open(fname, 'wb')
    f.setnchannels(1)
    f.setsampwidth(2)
    f.setframerate(rate)
    f.setnframes(n)
    f.writeframesraw(''.join(samples))
    f.close()

if __name__ == '__main__':
    main()

User avatar
Girl-With-A-Math-Fetish
Posts: 205
Joined: Mon Jun 30, 2014 9:02 am UTC
Location: The Complex Plane in the Mandelbrot Set
Contact:

Re: Oscilloscope Stray Signals

Postby Girl-With-A-Math-Fetish » Sun Nov 30, 2014 7:27 am UTC

PM 2Ring wrote:Here's a fairly simple sine wave generator I wrote a few years ago for Python 2


Oh wow, that IS pretty straight forward. Now I can see why Randall always talks about how awesome it is. I wonder what Perl is like, since he talks about that even more.
I'm sexually attracted to the International Space Station. You have now had your daily dose of Internet.

User avatar
PM 2Ring
Posts: 3652
Joined: Mon Jan 26, 2009 3:19 pm UTC
Location: Mid north coast, NSW, Australia

Re: Oscilloscope Stray Signals

Postby PM 2Ring » Sun Nov 30, 2014 7:47 am UTC

Non-Perl users often refer to Perl as executable line noise. :) It's generally acknowledged that Perl's not very easy to read until you've learned a bit about its syntax rules. Whereas Python is much more readable by non-Python users. Although some Python constructions can be a bit daunting to outsiders it's (mostly) quite easy to read, which is why Wikipedia encourages its use as a form of executable pseudo-code.

Python programmers are encouraged to make their code easy to read, and the language enforces clear layout of the code, to a degree. Unlike other languages that use braces or special keywords to mark out the block structure of a program, Python uses white space, i.e. the indenting of the code is syntactically significant. This annoys some people who are used to the conventions of other languages, and it can seem a bit weird at first, but most Pythonistas soon come to love the cleaner look of Python code.

Perl has a bit of a tradition of trying to condense programs down to inscrutable one-liners. There was an advantage in doing that in the olden days when people wrote code on terminals connected to mainframes, but these days it's just annoying, and makes Perl even harder to read if you're not a "Perl Monk". :)

But this is really a topic for the Language Wars section of the Coding forum...

User avatar
Girl-With-A-Math-Fetish
Posts: 205
Joined: Mon Jun 30, 2014 9:02 am UTC
Location: The Complex Plane in the Mandelbrot Set
Contact:

Re: Oscilloscope Stray Signals

Postby Girl-With-A-Math-Fetish » Sun Nov 30, 2014 9:25 am UTC

PM 2Ring wrote:the indenting of the code is syntactically significant.
But this is really a topic for the Language Wars section of the Coding forum...



Ahahaha :P I am familiar with basic ol' BASIC xD
I naturally indent my stuff for the sake of cleanliness, so I'm fine with that xD
I'm sexually attracted to the International Space Station. You have now had your daily dose of Internet.

User avatar
Neil_Boekend
Posts: 3220
Joined: Fri Mar 01, 2013 6:35 am UTC
Location: Yes.

Re: Oscilloscope Stray Signals

Postby Neil_Boekend » Mon Dec 01, 2014 7:50 am UTC

I often hear people saying that programming is just math with a different syntax. If that is true then it should be right up your alley.
I can't be sure though since I suck at both programming and math.
Mikeski wrote:A "What If" update is never late. Nor is it early. It is posted precisely when it should be.

patzer's signature wrote:
flicky1991 wrote:I'm being quoted too much!

he/him/his

User avatar
Sizik
Posts: 1221
Joined: Wed Aug 27, 2008 3:48 am UTC

Re: Oscilloscope Stray Signals

Postby Sizik » Mon Dec 01, 2014 1:06 pm UTC

On that note GWAMF, have you heard of Project Euler? It's a series of mathematical programming challenges, which should be right up your alley.
gmalivuk wrote:
King Author wrote:If space (rather, distance) is an illusion, it'd be possible for one meta-me to experience both body's sensory inputs.
Yes. And if wishes were horses, wishing wells would fill up very quickly with drowned horses.

User avatar
Girl-With-A-Math-Fetish
Posts: 205
Joined: Mon Jun 30, 2014 9:02 am UTC
Location: The Complex Plane in the Mandelbrot Set
Contact:

Re: Oscilloscope Stray Signals

Postby Girl-With-A-Math-Fetish » Wed Dec 03, 2014 5:08 am UTC

Yeah it's just the syntax that messes me up xD
And I think I've heard of Project Euler, but I don't think I looked into it. I shall now. :D
I'm sexually attracted to the International Space Station. You have now had your daily dose of Internet.

FancyHat
Posts: 341
Joined: Thu Oct 25, 2012 7:28 pm UTC

Re: Oscilloscope Stray Signals

Postby FancyHat » Wed Dec 03, 2014 1:54 pm UTC

Girl-With-A-Math-Fetish wrote:Oh wow, that IS pretty straight forward. Now I can see why Randall always talks about how awesome it is. I wonder what Perl is like, since he talks about that even more.

I don't know if you already know about the following kind of thing, but you might like to try it out, out of mathematical interest:-

Code: Select all

#! /usr/bin/python

a = 1.0     # This can be any value.
b = 0.1     # This should usually be less than one.  It can be negative.

n = 1000    # That's how many data points to output.

x = 0.0
v = a

while n:
    print x
    x = x + v       # These are the two interesting lines.
    v = v - b*x     # Notice there's no trigonometry or exponentiation.
    n = n - 1

I've never written anything in Python before, as far as I can remember.

Here it is in Perl (which I've learned to some extent):-

Code: Select all

#! /usr/bin/perl -w

$a = 1.0;    # This can be any value.
$b = 0.1;    # This should usually be less than one.  It can be negative.

$n = 1000;   # That's how many data points to output.

$x = 0.0;
$v = $a;

for (my $i = $n; $i--;) {
    print "$x\n";
    $x = $x + $v;       # These are the two interesting lines.
    $v = $v - $b*$x;    # Notice there's no trigonometry or exponentiation.
}
I am male, I am 'him'.

User avatar
Sizik
Posts: 1221
Joined: Wed Aug 27, 2008 3:48 am UTC

Re: Oscilloscope Stray Signals

Postby Sizik » Wed Dec 03, 2014 3:06 pm UTC

For some simple graphical output, replace

Code: Select all

print x

with

Code: Select all

if x > 0:
    print ' '*32 + '+'*int(10*x)
else:
    off = int(-10*x)
    print ' '*(32-off) + '-'*off
gmalivuk wrote:
King Author wrote:If space (rather, distance) is an illusion, it'd be possible for one meta-me to experience both body's sensory inputs.
Yes. And if wishes were horses, wishing wells would fill up very quickly with drowned horses.

User avatar
chridd
Has a vermicelli title
Posts: 828
Joined: Tue Aug 19, 2008 10:07 am UTC
Location: ...Earth, I guess?
Contact:

Re: Oscilloscope Stray Signals

Postby chridd » Thu Dec 04, 2014 4:41 am UTC

Sizik wrote:For some simple graphical output, replace

Code: Select all

print x

with

Code: Select all

if x > 0:
    print ' '*32 + '+'*int(10*x)
else:
    off = int(-10*x)
    print ' '*(32-off) + '-'*off
^ That will need to be indented.
Perl equivalent:

Code: Select all

if($x > 0) {
   print ' ' x 32, '+' x int(10*$x), "\n";
} else {
   my $off = int(-10*$x);
   print ' ' x (32-$off), '-' x $off, "\n";
}
~ chri d. d. /tʃɹɪ.di.di/ (Phonotactics, schmphonotactics) · she(?)(?(?)(?))(?(?(?))(?))(?) · Forum game scores
mittfh wrote:I wish this post was very quotable...
chridd (on Discord) wrote:
Dummy wrote:Sorry You're Gay Dads
SYG'D
marionic (on Discord) wrote:sleep in grave

User avatar
Girl-With-A-Math-Fetish
Posts: 205
Joined: Mon Jun 30, 2014 9:02 am UTC
Location: The Complex Plane in the Mandelbrot Set
Contact:

Re: Oscilloscope Stray Signals

Postby Girl-With-A-Math-Fetish » Thu Dec 04, 2014 10:33 am UTC

Wow! Python is super simple! It's as easy and straightforwards to understand as LUA/BASIC, but is more powerful :D
I think I know what programming language I'm going to learn next ^_^

Yes, this shall serve my purpose. I do in fact need a graphical output ^_^

Hmm... this weekend, I shall try and learn Python. Well, start learning it. Anyone know of a light-duty free compiler for Python?

Funny thing is someone on another site wants to teach me JavaScript. So sooner or later, I should be able to generate the image I want ^_^
I'm sexually attracted to the International Space Station. You have now had your daily dose of Internet.

User avatar
PM 2Ring
Posts: 3652
Joined: Mon Jan 26, 2009 3:19 pm UTC
Location: Mid north coast, NSW, Australia

Re: Oscilloscope Stray Signals

Postby PM 2Ring » Thu Dec 04, 2014 11:30 am UTC

@FancyHat: Ah, the good old digital simple harmonic oscillator. Thanks for posting that.

That sort of algorithm is way faster than using a math lib to do trig. And that approach can be used to do filtering as well as generating waves. But the downside (IIRC) is that it's a little tricky to pick the parameters required to produce a wave of a given frequency (and sampling rate).

I guess the classic reference on this topic is Digital Signal Processing in C by Reid and Passin. FWIW, I first learned about this stuff in a short article by Reid and Passin in the C Users Journal of May 1992 (which I still have). I did write some programs that used these techniques back in the day, but I haven't played around with it for ages.

Dan H
Posts: 11
Joined: Tue Mar 26, 2013 7:45 pm UTC
Location: West Chester, OH

Re: Oscilloscope Stray Signals

Postby Dan H » Sun Dec 07, 2014 7:15 am UTC

Girl-With-A-Math-Fetish wrote:Anyone know of a light-duty free compiler for Python?

Python is interpreted rather than compiled (well, there is a compile step, but it's hidden from you). There are many free distributions. The simplest one is at http://www.python.org. Free distributions with more bells and whistles are available other places; look for ipython or enthought canopy to find two of the ones I've seen people using.

wumpus
Posts: 533
Joined: Thu Feb 21, 2008 12:16 am UTC

Re: Oscilloscope Stray Signals

Postby wumpus » Sun Dec 07, 2014 5:48 pm UTC

Dan H wrote:
Girl-With-A-Math-Fetish wrote:Anyone know of a light-duty free compiler for Python?

Python is interpreted rather than compiled (well, there is a compile step, but it's hidden from you). There are many free distributions. The simplest one is at http://www.python.org. Free distributions with more bells and whistles are available other places; look for ipython or enthought canopy to find two of the ones I've seen people using.


For a JIT "compiler" you could try pypy, which is a nearly ready edition of python that is somewhere in speed between normal python and JIT Java.
If you insist on compiling your python (but can still load the interpreter), there are cython and pyrex (which really exist for writing fast python modules and interfacing with C/C++ libraries).

I'd stick with standard Python ("Cpython") unless you really need a compiler for some reason (size on a raspberry-type device or so).

-note: some of us are old enough to remember not having a compiler and thinking in terms of either writing in assembler or using an interpretive language so "wanting to write in a computer language" doesn't mean the same as "needing a compiler". You don't want to know about the pascal compiler for the Apple2.

User avatar
Girl-With-A-Math-Fetish
Posts: 205
Joined: Mon Jun 30, 2014 9:02 am UTC
Location: The Complex Plane in the Mandelbrot Set
Contact:

Re: Oscilloscope Stray Signals

Postby Girl-With-A-Math-Fetish » Tue Dec 09, 2014 12:34 am UTC

Augh! A wumpus! *shoots an arrow*
*moves to 13*
I'm sexually attracted to the International Space Station. You have now had your daily dose of Internet.

User avatar
PM 2Ring
Posts: 3652
Joined: Mon Jan 26, 2009 3:19 pm UTC
Location: Mid north coast, NSW, Australia

Re: Oscilloscope Stray Signals

Postby PM 2Ring » Tue Dec 09, 2014 3:24 am UTC

wumpus wrote:I'd stick with standard Python ("Cpython") unless you really need a compiler for some reason (size on a raspberry-type device or so).

-note: some of us are old enough to remember not having a compiler and thinking in terms of either writing in assembler or using an interpretive language so "wanting to write in a computer language" doesn't mean the same as "needing a compiler". You don't want to know about the pascal compiler for the Apple2.


Ah, I remember Apple2 Pascal...

I agree with wumpus's recommendation to stick with standard Python ("Cpython") to get started. Python made a few radical changes going from version 2 to 3. Many people & places are still using Python 2, mostly because some 3rd party packages still don't have versions that are suitable for Python 3. And some of us have written vast amounts of Python 2 code that we're too slack to update. :) But since you're just starting on Python now I guess it'd be a good idea to learn Python 3; it's easy enough to learn the obsolete features of Python 2 if you ever find yourself in the position of needing to read or modify old code. FWIW, there is a way to automate conversion of Python 2 code to Python 3, 2to3.

The official Python docs have tutorials for learning Python. They are designed to be used by people who are already familiar with at least one other programming language, though total beginners can use them too.

The Python 2 Tutorial
The Python 3 Tutorial

User avatar
Girl-With-A-Math-Fetish
Posts: 205
Joined: Mon Jun 30, 2014 9:02 am UTC
Location: The Complex Plane in the Mandelbrot Set
Contact:

Re: Oscilloscope Stray Signals

Postby Girl-With-A-Math-Fetish » Tue Dec 09, 2014 11:11 pm UTC




Oooh these are nice ^_^ I'm reading them right now :3
I'm sexually attracted to the International Space Station. You have now had your daily dose of Internet.

User avatar
Minerva
Posts: 947
Joined: Sat Nov 11, 2006 2:58 pm UTC
Location: Australia
Contact:

Re: Oscilloscope Stray Signals

Postby Minerva » Fri Jan 09, 2015 6:23 pm UTC

Yes, if you touch the end of an oscilloscope probe it's pretty typical to see a messy sine wave at 50 (or 60) Hz from mains grid hum.

The audible hum if you touch the end of a plug connected to an audio amplifier input is exactly the same thing.
...suffer from the computer disease that anybody who works with computers now knows about. It's a very serious disease and it interferes completely with the work. The trouble with computers is you play with them. They are so wonderful. - Richard Feynman

User avatar
Girl-With-A-Math-Fetish
Posts: 205
Joined: Mon Jun 30, 2014 9:02 am UTC
Location: The Complex Plane in the Mandelbrot Set
Contact:

Re: Oscilloscope Stray Signals

Postby Girl-With-A-Math-Fetish » Mon Jan 12, 2015 1:28 am UTC

Minerva wrote:Yes, if you touch the end of an oscilloscope probe it's pretty typical to see a messy sine wave at 50 (or 60) Hz from mains grid hum.

The audible hum if you touch the end of a plug connected to an audio amplifier input is exactly the same thing.


Ahh yes, I have wondered what that was. I mean, I knew of such effect, but it didn't occur to me that it was what was causing the hum.
I'm sexually attracted to the International Space Station. You have now had your daily dose of Internet.


Return to “Science”

Who is online

Users browsing this forum: No registered users and 8 guests