+ Reply to Thread
Page 1 of 3
1 2 3 LastLast
Results 1 to 10 of 29

Thread: Waveform Generator

  1. #1
    Inactive eth0 is on a distinguished road eth0's Avatar
    Join Date
    Apr 2007
    Location
    Oxfordshire, UK
    Posts
    61

    Default

    Hi all,
    Just wondering what you guys thought to the idea of a waveform generator chip?

    I'm aware that there is a "pulser" that i'm told generates a short-edge square wave, but i was wondering if there was merit in producing a chip that could allow the user to pick the waveform e.g Sine,Square, Triangle, Sawtooth etc, it's frequency and value range.

  2. #2
    Jok
    Jok is offline
    Inactive Jok is on a distinguished road Jok's Avatar
    Join Date
    Apr 2007
    Posts
    133

    Default

    Basically, the sine would...be a sine output. 0 to 1, a square would have 2 outputs, 0 to 1 and 1 to 0, triangle...3 outputs, Sawtooth...1-0-1-0-1-0.

    Yes, I have no idea how it'd work :P If you manage to explain to me, I might be able to make something like this.

  3. #3
    That furred thing
    Black Phoenix will become famous soon enough Black Phoenix will become famous soon enough Black Phoenix's Avatar
    Join Date
    Feb 2007
    Location
    Kyiv, Ukraine
    Posts
    2,742

    Default

    Sine is math sine function, sawtooth is modulus function, square wave is extended sign of sine function (0 if <= 0; 1 if > 0), triangle wave is something like 2 sawtoothes, etc
    I'm a wire-crazy person with a tail.

    Take a daily journey into my brain

    D2K5


  4. #4
    Inactive Yerocrg is on a distinguished road Yerocrg's Avatar
    Join Date
    Mar 2007
    Location
    New Jersey, U.S.A.
    Posts
    91

    Default

    I think that you could get a square wave by simply attaching a 'round' gate to a 'sine' gate.
    <div class='quotetop'>QUOTE(Infinity) [url="index.php?act=findpost&pid=3853"]<{POST_SNAPBACK}>[/url]</div>[quote]Wire igniter? I think it'll turn to hell...[/quote]

    <div class='quotetop'>QUOTE(TAD2020) [url="index.php?act=findpost&pid=11109"]<{POST_SNAPBACK}>[/url]</div>[quote]Would only require a heavenly modified wire stool to do this.[/quote]

  5. #5
    That furred thing
    Black Phoenix will become famous soon enough Black Phoenix will become famous soon enough Black Phoenix's Avatar
    Join Date
    Feb 2007
    Location
    Kyiv, Ukraine
    Posts
    2,742

    Default

    You cant, that won't be square (That will look like steps)
    I'm a wire-crazy person with a tail.

    Take a daily journey into my brain

    D2K5


  6. #6
    Inactive yaworski is on a distinguished road yaworski's Avatar
    Join Date
    Feb 2007
    Location
    Poland
    Posts
    79

    Default

    I think that you could get a square wave by simply attaching a 'round' gate to a 'sine' gate.[/b]
    You're wrong. This would generate 3 states for the wave:
    if sin(x) <= -0.5 -> -1
    if -0.5 < sin(x) <= 0.5 -> 0
    if sin(x) > 0.5 -> 1
    (assuming the round function is working like in real math ).

    You would just quantize the continuous function down to 3 values. But this is not a square wave which (when ideal) should have only 2 values changing with some frequency. You can get a square wave from pulser.

    Sin wave should be easy to code since it could just output the value of sin(accumulatedvalue) where accumulatedvalue can be calculated like it is done in accumulator gate.
    Code:
    GateActions["sinwave"] = {
    Â*Â*Â*Â*group = "Time",
    Â*Â*Â*Â*name = "Sinusoidal Wave",
    Â*Â*Â*Â*inputs = { "Rate", "Hold", "Reset" },
    Â*Â*Â*Â*timed = true,
    Â*Â*Â*Â*output = function(gate, Rate, Hold, Reset)
    Â*Â*Â*Â*Â*Â*Â*Â*gate.accumulator = gate.accumulator or {}
    Â*Â*Â*Â*Â*Â*Â*Â*local accvalue = GateActions["accumulator"].output(gate.accumulator, Rate, Hold, Reset)
    Â*Â*Â*Â*Â*Â*Â*Â*return math.sin(math.rad(accvalue*90))
    Â*Â*Â*Â*end,
    Â*Â*Â*Â*reset = function(gate)
    Â*Â*Â*Â*Â*Â*Â*Â*gate.accumulator = {}
    Â*Â*Â*Â*Â*Â*Â*Â*GateActions["accumulator"].reset(gate.accumulator)
    Â*Â*Â*Â*end,
    Â*Â*Â*Â*label = function(Out, Rate, Hold, Reset)
    Â*Â*Â*Â*Â*Â*Â*Â*return "Rate:"..Rate.." Hold:"..Hold.." Reset:"..Reset.." = "..Out
    Â*Â*Â*Â*end
    }
    
    I put accvalue*90 because I think that without this the change of the value would be too slow, but anyway this can be adjusted by the Rate input. It takes the value from Accumulator gate so the Rate input works like the A input in the Accumulator gate.

    I didn't copy the whole code from the Accumulator on purpose, because I like when the code is reusable (there is smaller chance of having error somewhere, and if the error will be found in accumulator code and gets fixed this will automatically fix the sin wave for example).

    ----edit----

    You cant, that won't be square (That will look like steps)[/b]
    Hehe you were faster than me .

    ----edit----

    I'll explain why I created the gate.accumulator variable. This is used to simulate the calls that are done by wiremod to the gate's functions. It also stores the state for the simulated Accumulator gate inside my gate's gate variable (so it is persisted through all calls to the output function to the SinWave gate). This can (and should) be done for all gates that store their values through invocations and we want to use them inside our gates (this make the code more readable).

    ----edit----

    Sawtooth
    Code:
    GateActions["sawtoothwave"] = {
    Â*Â*Â*Â*group = "Time",
    Â*Â*Â*Â*name = "Sawtooth Wave",
    Â*Â*Â*Â*inputs = { "Rate", "Hold", "Reset" },
    Â*Â*Â*Â*timed = true,
    Â*Â*Â*Â*output = function(gate, Rate, Hold, Reset)
    Â*Â*Â*Â*Â*Â*Â*Â*gate.accumulator = gate.accumulator or {}
    Â*Â*Â*Â*Â*Â*Â*Â*gate.prevValue = gate.prevValue or 0
    Â*Â*Â*Â*Â*Â*Â*Â*if gate.prevValue >= 1 then Reset = 1 end
    Â*Â*Â*Â*Â*Â*Â*Â*local accvalue = GateActions["accumulator"].output(gate.accumulator, Rate, Hold, Reset)
    Â*Â*Â*Â*Â*Â*Â*Â*gate.prevValue = accvalue
    Â*Â*Â*Â*Â*Â*Â*Â*return accvalue
    Â*Â*Â*Â*end,
    Â*Â*Â*Â*reset = function(gate)
    Â*Â*Â*Â*Â*Â*Â*Â*gate.accumulator = {}
    Â*Â*Â*Â*Â*Â*Â*Â*GateActions["accumulator"].reset(gate.accumulator)
    Â*Â*Â*Â*Â*Â*Â*Â*gate.prevValue = 0
    Â*Â*Â*Â*end,
    Â*Â*Â*Â*label = function(Out, Rate, Hold, Reset)
    Â*Â*Â*Â*Â*Â*Â*Â*return "Rate:"..Rate.." Hold:"..Hold.." Reset:"..Reset.." = "..Out
    Â*Â*Â*Â*end
    }
    
    Triangle
    Code:
    GateActions["trianglewave"] = {
    Â*Â*Â*Â*group = "Time",
    Â*Â*Â*Â*name = "Triangle Wave",
    Â*Â*Â*Â*inputs = { "Rate", "Hold", "Reset" },
    Â*Â*Â*Â*timed = true,
    Â*Â*Â*Â*output = function(gate, Rate, Hold, Reset)
    Â*Â*Â*Â*Â*Â*Â*Â*gate.accumulator = gate.accumulator or {}
    Â*Â*Â*Â*Â*Â*Â*Â*gate.prevValue = gate.prevValue or 0
    Â*Â*Â*Â*Â*Â*Â*Â*gate.RateDir = gate.RateDir or 1
    
    Â*Â*Â*Â*Â*Â*Â*Â*if (gate.prevValue >= 1 and gate.RateDir == 1) then gate.RateDir = -1 end
    Â*Â*Â*Â*Â*Â*Â*Â*if (gate.prevValue <= 0 and gate.RateDir == -1) then gate.RateDir = 1 end
    
    Â*Â*Â*Â*Â*Â*Â*Â*if Reset == 1 then gate.RateDir = 1 end
    Â*Â*Â*Â*Â*Â*Â*Â*local accvalue = GateActions["accumulator"].output(gate.accumulator, Rate * gate.RateDir, Hold, Reset)
    Â*Â*Â*Â*Â*Â*Â*Â*gate.prevValue = accvalue
    Â*Â*Â*Â*Â*Â*Â*Â*return accvalue
    Â*Â*Â*Â*end,
    Â*Â*Â*Â*reset = function(gate)
    Â*Â*Â*Â*Â*Â*Â*Â*gate.accumulator = {}
    Â*Â*Â*Â*Â*Â*Â*Â*GateActions["accumulator"].reset(gate.accumulator)
    Â*Â*Â*Â*Â*Â*Â*Â*gate.prevValue = 0
    Â*Â*Â*Â*Â*Â*Â*Â*gate.RateDir = 1
    Â*Â*Â*Â*end,
    Â*Â*Â*Â*label = function(Out, Rate, Hold, Reset)
    Â*Â*Â*Â*Â*Â*Â*Â*return "Rate:"..Rate.." Hold:"..Hold.." Reset:"..Reset.." = "..Out
    Â*Â*Â*Â*end
    }
    
    I hope I didn't do any mistake

  7. #7
    Inactive Yerocrg is on a distinguished road Yerocrg's Avatar
    Join Date
    Mar 2007
    Location
    New Jersey, U.S.A.
    Posts
    91

    Default

    Actually, I meant using 'sinr' or whatever the one is that outputs between 0 and 1.
    <div class='quotetop'>QUOTE(Infinity) [url="index.php?act=findpost&pid=3853"]<{POST_SNAPBACK}>[/url]</div>[quote]Wire igniter? I think it'll turn to hell...[/quote]

    <div class='quotetop'>QUOTE(TAD2020) [url="index.php?act=findpost&pid=11109"]<{POST_SNAPBACK}>[/url]</div>[quote]Would only require a heavenly modified wire stool to do this.[/quote]

  8. #8
    Inactive Qjet is on a distinguished road Qjet's Avatar
    Join Date
    Mar 2007
    Location
    Canada
    Posts
    287

    Default

    sinr and sind both output -1 to 1

    and you would use CEILING on sin to get the square

    phoenix is right on basically all counts

    except triangle
    triangle is abs(2-(X%4))-1
    which is 5 gates: modulus, constant, subtract, absolute, decrement.

    edit: oops mistake

    edit2: i just noticed the 50 lines of code above me were for sawtooth...

    don't do the huge if statements and variables use this formula.

    edit3: NO WAIT MY FORMULAS TRIANGLE. wtf am i thinking.
    sawtooth formula (x%2)-1 and inverted sawtooth 1-(x%2)

  9. #9
    That furred thing
    Black Phoenix will become famous soon enough Black Phoenix will become famous soon enough Black Phoenix's Avatar
    Join Date
    Feb 2007
    Location
    Kyiv, Ukraine
    Posts
    2,742

    Default

    Qjet, shouldn't it be Abs(1-(X%2)) ??
    I'm a wire-crazy person with a tail.

    Take a daily journey into my brain

    D2K5


  10. #10
    Inactive Qjet is on a distinguished road Qjet's Avatar
    Join Date
    Mar 2007
    Location
    Canada
    Posts
    287

    Default

    No waveforms have a range of 1 to -1. and the triangle waveform has a frequency of 4(actually thats the frequency i gave it thats not a true triangle waveform): Here is a list of formula for each wave
    Code:
    Triangle: 1-abs(2-((x*2)%4))
    Square: ceil(1-(x%2))
    Saw: x%2-1
    InvSaw 1-X%2
    Sin: sind(x*180) OR sinr(x*pi)
    Pulse: floor(x%1)
    
    tell me if i missed any!

    edit1: to be honest. I would like to see a waveform gate
    it would have 1 input and 6 outputs with these 6 waveforms for each one.

+ Reply to Thread
Page 1 of 3
1 2 3 LastLast

Similar Threads

  1. Wire - Field Generator(s)
    By AlgorithmX2 in forum Wiremod Addons
    Replies: 195
    Last Post: 01-10-2010, 08:38 AM
  2. Wired Random Number/Colour Generator
    By Snitchio in forum Ideas & Suggestions
    Replies: 2
    Last Post: 11-24-2008, 11:59 AM
  3. Wire + Life Support generator and motor...
    By Infinity in forum Ideas & Suggestions
    Replies: 16
    Last Post: 06-09-2007, 02:06 PM
  4. Need the pack that has the "Generator" and "Razor" models...
    By Mr. Brightside in forum Help & Support
    Replies: 2
    Last Post: 06-06-2007, 10:16 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts