Announcement

Collapse
No announcement yet.

Writing signal generators in ChucK

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Writing signal generators in ChucK

    Since I don't have a signal generator, and I am a software engineer, I had the thought that I could just write a simple program to generate whatever signals I needed. Then, suchayo posted asking for signal generator software and it inspired me to actually figure out how I would do it. http://www.energeticforum.com/renewa...tml#post103110

    I decided to write it in ChucK, since it is designed for audio generation, and has free runtimes available for OS X, Windows, and Linux. It makes doing stuff like this incredibly trivial. There are built in generators for sin waves, square waves, triangle waves, and impulses.

    ChucK => Strongly-timed, On-the-fly Audio Programming Language

    Code:
    // connect SinOsc to dac
    SinOsc s => dac;
    // set initial frequency to 440 hz
    440 => s.freq;
    // let time pass for 1 second
    1::second => now;
    Attached is the output of that program. Sorry it's fuzzy. The built in soundcard on my mac mini puts out 250 millivolts. Hook it up to a home stereo amplifier to get more.

    I'll have to fiddle around a little more to figure out how to do amplitude modulation. It's probably not too hard.

    This is the scope I have, by the way. It's great:

    SparkFun Electronics - DSO Nano - Pocket-Sized Digital Oscilloscope
    Attached Files
    Last edited by fzzzy; 07-09-2010, 09:59 AM.

  • #2
    Can we get amplitude modulation with that solution?

    From My Work on Rife




    I am thinking of real time multiple sine wave / PWM calculator that send the value to soundcard.

    onboard MIDI solution already available like "NCH Tone Generator" that allow many frequency at once.


    Also, what is the transistor inside audio amplifier? Isn't it good if we can use our computer as signal generator which should produce very accurate frequency?

    Comment


    • #3
      Thanks for the link to the rife page. I'll have to read it later, too much to read right now.

      The graphics you included in your post appear to confuse the terminology a bit, according to the wikipedia page on harmonics Harmonic - Wikipedia, the free encyclopedia

      The sin waves should be labeled:

      fundamental (original sine in the first graphic, fundamental in the second graphic)
      1st overtone (1st harmonic in the graphics)
      2nd overtone (2nd harmonic in the second graphic)

      OR:

      1st harmonic (original sine in the first graphic, fundamental in the second graphic)
      2nd harmonic (1st harmonic in the graphics)
      3rd harmonic (2nd harmonic in the second graphic)

      Since the math is easier, let's use what wikipedia calls harmonics instead of what it calls overtones. The 1st harmonic is the fundamental, the basic frequency. The second harmonic is the fundamental frequency times 2. The third harmonic is the fundamental frequency times 3. Etc.

      To do amplitude modulation we just add the different signals together. When the higher frequency wave is negative and the low frequency wave is positive, the negative subtracts from the positive, etc.

      Code:
      SinOsc fundamental => dac;
      440 => fundamental.freq;
      
      SinOsc second_harmonic => dac;
      880 => second_harmonic.freq;
      
      1::second => now;
      Here's the result:



      A replication of the second image, with the fundamental, second harmonic, and third harmonic:

      Code:
      SinOsc fundamental => dac;
      440 => fundamental.freq;
      
      SinOsc second_harmonic => dac;
      880 => second_harmonic.freq;
      
      SinOsc third_harmonic => dac;
      1320 => third_harmonic.freq;
      
      1::second => now;


      These graphs were captured by the program Signal Scope Pro (I downloaded the demo version)

      I'm learning a lot from doing this! It's great!

      Comment


      • #4
        Originally posted by sucahyo View Post
        Also, what is the transistor inside audio amplifier? Isn't it good if we can use our computer as signal generator which should produce very accurate frequency?
        Yes, if we can come up with a simple circuit that does the amplification instead of using an audio amplifier that would be great. I don't know what's inside audio amplifiers but I'm guessing it's just some power transistors. I'll research it more to find out.

        Comment


        • #5
          Originally posted by sucahyo View Post
          onboard MIDI solution already available like "NCH Tone Generator" that allow many frequency at once.
          From just quickly looking at the nch homepage, it looks like NCH Tone Generator can do the same thing that I am doing here. However the way I am doing it with ChucK is easily programmable, free, and runs on all 3 major platforms.

          Comment


          • #6
            Hi here is what i have come up with so far! (request for a sound Gen)

            This is not done in Chuck though and its windows only, its a scratchpad idea/beta if you will and i am all open to suggestions towards features ect.

            looks like this atm.....


            here is the files, its a 1.33 meg exe Energetic SoundGen.exe
            and here is a little pdf (basic atm) telling what does what! SoundGen.pdf

            anyway its far from refined,will work on it more tomorrow

            Best regards
            Jay
            The history of science shows that theories are perishable.With every new truth that is revealed,we get a better understanding of Nature and our conceptions and views are modified. - Nikola Tesla

            Comment


            • #7
              Nice. What's it implemented in? I'm not going to be able to use it since I'm on a Mac, but I might be able to port it, depending on how it is implemented.

              Comment


              • #8
                Another thing on the topic of signal generators. Does anyone have any references to places that Tesla mentioned the frequencies of his impulses? I know the impulse frequency was the single most important variable when it came to producing different results (pressure, painful pressure, heat, cool breezes, and healing effects)

                With the sound card method we are only going to be able to generate frequencies up to 44.1 kHz. With a fancier sound card we can get frequencies up to 192 kHz. I'm pretty sure this is not going to be enough -- if I recall correctly I read somewhere tesla mentioning needing to get up into the gigahertz range, but I may be misremembering. Tesla talked about thousands or millions of impulses per second, but I can't find where I was reading that at the moment. I will go back and read some of Tesla's lectures.

                The sound card method will be perfectly fine for applications requiring frequencies smaller than 44.1 kHz, and general experimentation.

                Comment


                • #9
                  ...

                  @arkzero you r a genious!!

                  i am a computer tecnic, so i have some knolowdge on coding, i also produce electronic music as hobbie... you maked me feel layperson with your work, and you made it a blink of eye! awsome!!

                  i have allready downloaded the beta version, but will be interested in the improved one!

                  thank you

                  Originally posted by fzzzy View Post
                  With the sound card method we are only going to be able to generate frequencies up to 44.1 kHz. With a fancier sound card we can get frequencies up to 192 kHz. I'm pretty sure this is not going to be enough -- if I recall correctly I read somewhere tesla mentioning needing to get up into the gigahertz range, but I may be misremembering.
                  so how was tesla achieving so high frequencys at his time without computers, sound cards, signal generators or fancy technology like we have today?

                  hugs
                  Last edited by TanTric; 07-10-2010, 04:03 AM.
                  Light, I Am!

                  You are Not a Body that has a Spirit, You are a Spirit that Has a Body! There is no Path to Peace, Peace is the Path!

                  Comment


                  • #10
                    Originally posted by TanTric View Post
                    so how was tesla achieving so high frequencys at his time without computers, sound cards, signal generators or fancy technology like we have today?

                    hugs
                    High voltage generator, capacitor, spark gap, and induction coils. He also spent a lot of time researching magnetic spark gap quenching and other forms of reducing the interval of the spark gap discharge. Maximizing the Q or the sharpness of the impulse generated by the gap might be the key to getting extremely high frequencies.

                    "Experiments with Alternate Currents of High Potential and High Frequency"

                    by disruptively discharging a condenser through the primary, we set up a vibration in the secondary circuit of a frequency of many hundred thousand or millions per second, if we so desire
                    Capacitors were called condensers in tesla's day, and "disruptively discharging" means spark gap.

                    So I answered my own question, here is one quote from tesla about impulse frequencies. "many hundred thousand or millions per second" is in the hundreds of kilohertz to hundreds of megahertz range. Soundcards aren't going to be able to get these frequencies. Soundcard signal generators will still be useful for other kinds of experiments with harmonics and other things.

                    Is there any method for getting signals in hundreds of kilohertz to hundreds of megahertz range out of a computer? The USB page on wikipedia talks about data rate but it doesn't talk about signaling speed.
                    Last edited by fzzzy; 07-12-2010, 07:53 AM. Reason: I said "reducing the Q" but meant "maximizing the Q" (increasing the sharpness of the impulse slope)

                    Comment


                    • #11
                      Air-quenched gap

                      In this experiment, Tesla is disrupting the spark gap between A and B with a "draught" of air.

                      Figure 2 from the lecture



                      From the bottom up:

                      G: alternator (ac generator)
                      P: Primary coil
                      S: secondary coil
                      M: mica plates
                      A, B: spark gap terminals
                      C: condensers (capacitor) or leyden jars
                      p: primary coil
                      s: secondary coil
                      a, b: spark gap terminals
                      K: "knobs or spheres [...] of the proper size and set at a distance suitable for the experiment."

                      Each time the arc is broken between A and B the jars are quickly charged and discharged through the primary p p, producing a snapping spark between the knobs K K. Upon the arc forming between A and B the potential falls, and the jars cannot be charged to such high potential as to break through the air gap a b until the arc is again broken by the draught.
                      Magnet-quenched gap


                      In this next experiment, Tesla is disrupting the spark gap with an electromagnet.

                      Figure 4 from the lecture



                      A, B: adjustable knobs
                      J: jaws of brass
                      N, S: electromagnet
                      M: mica
                      L: screws
                      R: rods

                      Figure 5 from the lecture

                      Comment


                      • #12
                        Originally posted by arKzeRo View Post
                        This is not done in Chuck though and its windows only, its a scratchpad idea/beta if you will and i am all open to suggestions towards features ect.
                        Nice .

                        Can you add support for wave like Adrija Puharich mention?

                        or to produce frequency with all harmonic in the range like used for Teslar Watch?

                        signal for health watch by Puharich


                        Signal captured from human body:




                        Originally posted by fzzzy View Post
                        Another thing on the topic of signal generators. Does anyone have any references to places that Tesla mentioned the frequencies of his impulses? I know the impulse frequency was the single most important variable when it came to producing different results (pressure, painful pressure, heat, cool breezes, and healing effects)
                        MHZ, but I think the signal fall time is more important that it may require higher frequency on transistor implementation.


                        BTW, can we produce DC sine wave? sine wave that have the wave all above zero volt?

                        Comment


                        • #13
                          Fzzzy, i wondered the same thing, i wondered if there was a way to "get at" the clock frequency of the motherboard which of course runs into many MHz....there HAS to be a pin on there somewhere thats ticking away like crazy

                          Comment


                          • #14
                            Top job with the signal generator

                            @Jay(arkzero) / @all

                            Wonderful work with this signal generator! -Thanks!

                            I was thinking; to make the ultimate signal generator, if it also had a left and right channel so that each channel could be controlled. I.e. put out of phase (180degrees), amplitude etc, then this program could be used to drive the Rodin Coils also..! That might be asking a bit much of you though..!

                            I use a large-ish (800watt) car amplifier to drive resonant circuits (Dollards LMD networks) and the like, and the program you have made will work well for this..!

                            The main trouble however is with the amplifiers. Standard off the shelf amplifers won't amplify frequencies (I have found) much above ~60khz (cps). Audio amplifers often state a frequency response of 20-20khz. The actual range is often higher than 20khz though - (up to 60khz). However if a high voltage vacuum tube amplifier system were designed that was driven with such a signal generator then i'm sure some interesting Tesla circuits could be constructed!

                            Cheers all.
                            "Doesn't matter how many times you kick the coyote in the head, it's still gonna eat chickens". - EPD

                            Comment


                            • #15
                              Originally posted by Sputins View Post
                              I use a large-ish (800watt) car amplifier to drive resonant circuits (Dollards LMD networks) and the like, and the program you have made will work well for this..!
                              Can you provide the details of your LMD replication? I would like to do this and it would be nice to have some part numbers for components that are known to work.

                              Comment

                              Working...
                              X