Propeller Signal Generator

2

Comments

  • groggorygroggory Posts: 205
    edited June 2012 Vote Up0Vote Down
    Ahle2 wrote: »
    My own!

    A modified C3 or El Jugador gives a much better result than a modified Demo Board.

    Can you post the audio circuit that you think gives the better results?
  • pik33pik33 Posts: 776
    edited June 2012 Vote Up0Vote Down
    You still can use a demoboard as signal generator - add another signal output @ pins 0..7

    It has two problems with pins 10/11 and a demoboard

    1. it has low pass filter set @1.6 kHz@-3dB (and -20dB @ 20 kHz). This is easy to patch - use 680 Ohm..1k resistor instead (or parallel to) existing 10k
    2. it has a headphone amplifier. It is designed to amplify accoustic signals, not high frequency ones.
  • jmgjmg Posts: 10,456
    edited June 2012 Vote Up0Vote Down
    Dr_Acula wrote: »
    I added a front end to your signal generator. Knobs, switches etc all work with a touchscreen.

    Amazing. What is the code-footprint of that ? COG/Main Memory / Off Chip memory and Image memory ?
  • Ahle2Ahle2 Posts: 906
    edited June 2012 Vote Up0Vote Down
    @pik33
    3. The headphone amplifier is nonlinear for AUDIO signals EVEN when patched with 680 ohm resistor. (my scope doesn't lie!)
    Bass and treble are amplified and mids are damped... I have a feeling that the spectrum resembles the "loudness curve".

    SIDcog - The sound of the Commodore 64 in a single cog: Thread, OBEX, SIDcogMedlay.mp3
    AYcog - An emulation of the AY3-8910 / YM2149F PSG: Thread, OBEX
    SNEcog - An emulation of the SN76489 PSG(and variants): Thread, OBEX
    Propeller chiptune player: Thread
  • Ahle2Ahle2 Posts: 906
    edited June 2012 Vote Up0Vote Down
    100 Hz saw

    Modified Demo Board

    DSC00350.jpg



    RC filter with 20 kHz cut off
    DSC00351.jpg
    1024 x 768 - 46K
    1024 x 768 - 42K
    SIDcog - The sound of the Commodore 64 in a single cog: Thread, OBEX, SIDcogMedlay.mp3
    AYcog - An emulation of the AY3-8910 / YM2149F PSG: Thread, OBEX
    SNEcog - An emulation of the SN76489 PSG(and variants): Thread, OBEX
    Propeller chiptune player: Thread
  • Dr_AculaDr_Acula Posts: 5,482
    edited June 2012 Vote Up0Vote Down
    @Ahle2, it sounds like it is the headphone amp, not the RC network, that is the problem. Just use the RC network then?

    @groggory - I don't know how hard sine waves would be but I agree it would be a great idea :)

    @jmg, the code is using about half the hub ram. External ram used is about 250 kilobytes. The background could be loaded from the SD card directly to the display and doesn't necessarily have to stay in external ram. The pictures that change need to be in ram for fast refresh. As an example of sizes, the rotary knob picture is 10.5k, the switch is 5.6k and the font for the numbers is 54k.

    My audio circuit is a 1k and a 10nF low pass filter, and then a 1uF polyester blocking capacitor.
    Answers: 1) A quadcopter. 2) Very high. 3) The internet. 4) A lot. 5) No.
  • Ahle2Ahle2 Posts: 906
    edited June 2012 Vote Up0Vote Down
    Adding sin wave should be easy using the LUT in ROM. Of course it will take more than 2 pasm instructions (saw, pulse and triangle takes just two instructions to generate from the phase accumulator), so the 1.25 MHz sample rate will have to be decreased to something like 500 kHz .... :(
    I will look into it tomorrow!
    SIDcog - The sound of the Commodore 64 in a single cog: Thread, OBEX, SIDcogMedlay.mp3
    AYcog - An emulation of the AY3-8910 / YM2149F PSG: Thread, OBEX
    SNEcog - An emulation of the SN76489 PSG(and variants): Thread, OBEX
    Propeller chiptune player: Thread
  • jmgjmg Posts: 10,456
    edited June 2012 Vote Up0Vote Down
    Ahle2 wrote: »
    Adding sin wave should be easy using the LUT in ROM. Of course it will take more than 2 pasm instructions (saw, pulse and triangle takes just two instructions to generate from the phase accumulator), so the 1.25 MHz sample rate will have to be decreased to something like 500 kHz .... :(

    Beau posted this Sinewave_v2.1.spin
    http://forums.parallax.com/attachment.php?attachmentid=93836&d=1341006466
    in another thread.

    It does a nice NCO based Sine table, (and square comes for -free) and has these version notes, which claim 1.25MHz scan rates.

    (06-21-2012)
    Version 2.0 - This file re-written based on the 2006 submission by Tracy Allen. It provides a 1.25MHz sampling rate over the 524kHz sample rate in the previous version

    (06-22-2012)
    Version 2.1 - Added the ability to specify Sine and Sync (Square Wave) pins to any I/O
  • cavelambcavelamb Posts: 645
    edited June 2012 Vote Up0Vote Down
    Dr_Acula wrote: »

    My audio circuit is a 1k and a 10nF low pass filter, and then a 1uF polyester blocking capacitor.

    That's what Ive been using, but my hearing is not good enough to judge audio quality anymore.
  • HShankoHShanko Posts: 402
    edited June 2012 Vote Up0Vote Down
    I'm curious. What are the 8 parameters the signal generator would have?
    Harley Shanko
  • Ahle2Ahle2 Posts: 906
    edited June 2012 Vote Up0Vote Down
    jmg wrote: »
    Beau posted this Sinewave_v2.1.spin
    http://forums.parallax.com/attachment.php?attachmentid=93836&d=1341006466
    in another thread.

    It does a nice NCO based Sine table, (and square comes for -free) and has these version notes, which claim 1.25MHz scan rates.

    Yes, 1.25 MHz is obviously possible for a pure sine wave generator that is just launched in a cog and then is free running without any realtime control of frequency, pulsewidth or wavetype.
    In my case it's a little bit more complicated.
    For every loop, one register is loaded from HUB RAM and that eats 28 cycles, so there's just 36 cycles left to do everything else. Of course I could remove the inverted signal and damping, that would save 8 cycles.
    SIDcog - The sound of the Commodore 64 in a single cog: Thread, OBEX, SIDcogMedlay.mp3
    AYcog - An emulation of the AY3-8910 / YM2149F PSG: Thread, OBEX
    SNEcog - An emulation of the SN76489 PSG(and variants): Thread, OBEX
    Propeller chiptune player: Thread
  • cavelambcavelamb Posts: 645
    edited June 2012 Vote Up0Vote Down
    HShanko wrote: »
    I'm curious. What are the 8 parameters the signal generator would have?

    It's not about the signal generator, per se,
    An eight knob object in itself would be pretty neat.
    What could you use that for?
  • cavelambcavelamb Posts: 645
    edited June 2012 Vote Up0Vote Down
    Dr_Acula wrote: »
    Goodness me!

    *rummages through parts drawers*

    He's right, by jove!


    Oh how funny! You clowns are hystercal.

    I'm down with .0001 uF.

    But some things I assume are assumed to be thru-hole - in an SMT world.

    Are they bigger than a breadbox?
    Or smaller than a pea?
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 21,227
    edited June 2012 Vote Up0Vote Down
    It depends on the voltage rating and dielectric type. A multilayer ceramic cap can easily fit an 0402 SMD footprint in that value range. But a polystyrene cap of the same value may have to be through-hole due to both its size and sensitivity to high soldering temperatures.

    -Phil
    “Perfection is achieved not when there is nothing more to add, but when there is nothing left to take away. -Antoine de Saint-Exupery
  • Ahle2Ahle2 Posts: 906
    edited July 2012 Vote Up0Vote Down
    New version in the OBEX!

    * Added sine wave
    * Added user definable waveform

    Thanks Beau, I stole some ideas from your sine wave generator... ;)
    SIDcog - The sound of the Commodore 64 in a single cog: Thread, OBEX, SIDcogMedlay.mp3
    AYcog - An emulation of the AY3-8910 / YM2149F PSG: Thread, OBEX
    SNEcog - An emulation of the SN76489 PSG(and variants): Thread, OBEX
    Propeller chiptune player: Thread
  • Mark_TMark_T Posts: 1,621
    edited July 2012 Vote Up0Vote Down
    In English "sinus" only means the passages inside your nose :) "Sinusoid" or "sine wave" are the usual terms. (Don't worry, your usage wasn't getting up my nose(!))

    I believe the sinus passages are named for their wiggly shape...
  • Ahle2Ahle2 Posts: 906
    edited July 2012 Vote Up0Vote Down
    I actually knew that, but sometimes I use swenglish words... ;)

    OOOps... I just saw that I did the same mistake in the actual object. Have to fix it tomorrow, because it's very late... zzzZZZ
    SIDcog - The sound of the Commodore 64 in a single cog: Thread, OBEX, SIDcogMedlay.mp3
    AYcog - An emulation of the AY3-8910 / YM2149F PSG: Thread, OBEX
    SNEcog - An emulation of the SN76489 PSG(and variants): Thread, OBEX
    Propeller chiptune player: Thread
  • jmgjmg Posts: 10,456
    edited July 2012 Vote Up0Vote Down
    Ahle2 wrote: »
    Yes, 1.25 MHz is obviously possible for a pure sine wave generator that is just launched in a cog and then is free running without any realtime control of frequency, pulsewidth or wavetype.
    In my case it's a little bit more complicated.
    For every loop, one register is loaded from HUB RAM and that eats 28 cycles, so there's just 36 cycles left to do everything else. Of course I could remove the inverted signal and damping, that would save 8 cycles.

    As a code approach, I see no problem with using MORE of the COG, and having multiple variants that are chosen on init ?
    The cog memory is free, and multiple versions can be educational too ?

    The nature of a 'duty' DAC is forgiving of sample rates, and faster sample rates drop the DAC (Y axis) precision anyway, so you gain X precision somewhat at the cost of Y. With an external DAC, until you exceed its rate, gains in loop speed are real gains.
  • Ahle2Ahle2 Posts: 906
    edited July 2012 Vote Up0Vote Down
    Dr_Acula wrote:
    @Ahle2, it sounds like it is the headphone amp, not the RC network, that is the problem. Just use the RC network then?
    It turned out to be the blocking capacitor after all.... duhh!!!
    The Demo Board actually gives a very good result after some more mods.
    groggory wrote:
    Can you post the audio circuit that you think gives the better results?
    Just a basic 6 dB RC filter with ~20kHz cut off and a cheap OP as a buffer.
    But there definitely are better solutions. That's the reason I will ask Phil!

    @Phil Pilgrim
    Do you have any schematic for a "cheap" but high quality filter + buffer solution with a steep filter curve?

    @pik33
    How did you achieve 12bit resolution using the video generator? I havn't had any time to analyze your code yet!

    @jmg
    I really like the idea of realtime control of all parameters at runtime. Then it can be used as an oscillator for my upcoming subtractive synthesizer.
    The thing with my implementation is that you can add "unlimited" amounts of parameters and waveforms without they reducing the sample rate of the already existing code base.
    SIDcog - The sound of the Commodore 64 in a single cog: Thread, OBEX, SIDcogMedlay.mp3
    AYcog - An emulation of the AY3-8910 / YM2149F PSG: Thread, OBEX
    SNEcog - An emulation of the SN76489 PSG(and variants): Thread, OBEX
    Propeller chiptune player: Thread
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 21,227
    edited July 2012 Vote Up0Vote Down
    Ahle2 wrote:
    @Phil Pilgrim: Do you have any schematic for a "cheap" but high quality filter + buffer solution with a steep filter curve?
    A second-order Sallen & Key filter made from a single op-amp stage would probably fit the bill adequately. If not, you can always cascade them.

    -Phil
    “Perfection is achieved not when there is nothing more to add, but when there is nothing left to take away. -Antoine de Saint-Exupery
  • pik33pik33 Posts: 776
    edited July 2012 Vote Up0Vote Down
    @pik33
    How did you achieve 12bit resolution using the video generator? I havn't had any time to analyze your code yet!

    (1) set pll at something about 200 MHz (exact value has to be computed), and video generator to generate at pins 8..15
     vcfg_val long $200002ff
     frqa_val long $25000000
    
    

    (2) from 16-bit sample value, get 7 higher bits and then compute two vscl values:
                             shr     t1,#9
                             add     t1,#1
                             mov     t2,#129
                             sub     t2,t1
                             shl     t1,#5
                             shl     t2,#5
                             add     t2,vscl_val0
                             add     t1,vscl_val0
    

    This gives 7-bit resolution. Another 5 bit has to be added: I have to shr $FFFFFFFF
                             mov     t3,rsample
                             shr     t3,#4
                             and     t3,mask5
                             mov     t4,ffffffff
                             shr     t4,t3
    


    And now output :
    
                             mov     outa, zero 'start with zero
                             mov     vscl,t1
                             waitvid zero,zero 'output zeros (7 higher bits part)
                             mov     vscl,vscl_val
                             waitvid ffffffff,t4 ' output 32 bits, some 0, some 1 (5-bit part)
                             mov vscl,t2 p12
                             waitvid ffffffff,ffffffff 'now output 1's (7 higher bits)
                             mov     outa,mask1 'output "1" for next sample processing
    

    "mask1" is "1" at bits 10,11, to generate output with standard demoboard audio pins.
    
    mask1 long  (percent)0000_0000_0000_0000_0000_1100_0000_0000
    
  • Heater.Heater. Posts: 19,695
    edited July 2012 Vote Up0Vote Down
    Mark_T,

    In English "sinus" only means the passages inside your nose "Sinusoid" or "sine wave" are the usual terms. (Don't worry, your usage wasn't getting up my nose(!))...
    I believe the sinus passages are named for their wiggly shape...


    Actually this is not totally true. From the dictionary we get:


    si·nus (sns)
    n.
    1. A depression or cavity formed by a bending or curving.
    2. Anatomy
    a. A dilated channel or receptacle containing chiefly venous blood.
    b. Any of various air-filled cavities in the bones of the skull, especially one communicating with the nostrils.
    3. Pathology A fistula leading from a pus-filled cavity.
    4. Botany A recess or indentation between lobes of a leaf or corolla.
    [Middle English, hollow in the body, from Medieval Latin, from Latin, curve, hollow.]


    Elsewhere on the net we learn that:


    SINE comes from the Latin SINUS, meaning a bend or gulf, or the bosom
    of a garment. (We know the word from its anatomical meaning: the
    cavities or bays in the facial bones - mine are badly congested right
    now - and from the names of some "bays" on the moon.) The term was
    used as a translation for the Arabic word "jayb," the word for a sine
    that also meant the bosom of a garment, and which in turn comes from
    the Sanskrit word "jiva" meaning a bowstring.


    I would happily refer to "sine" as "sinus" and expect to be understood.

    The nice thing about "sinus" is that it works for a lot of other languages with latin roots.

    But yes when writing for a young English audience today I would use sine.
  • AmaralAmaral Posts: 175
    edited July 2012 Vote Up0Vote Down
    There's a small signal being generated at pin 0 , is it just mine or it's a bug somewhere ?

    I just run the object (testBench.spin) and read it with an oscilloscope, besides pin 10 and 11 (defined by the object) I have a reading on pin 0, small but enough to lit a led.

    Amaral.
  • Dr_AculaDr_Acula Posts: 5,482
    edited July 2012 Vote Up0Vote Down
    si·nus (sns)
    1. A depression or cavity formed by a bending or curving.
    2. Anatomy
    a. A dilated channel or receptacle containing chiefly venous blood.
    b. Any of various air-filled cavities in the bones of the skull, especially one communicating with the nostrils.
    3. Pathology A fistula leading from a pus-filled cavity.
    4. Botany A recess or indentation between lobes of a leaf or corolla.
    [Middle English, hollow in the body, from Medieval Latin, from Latin, curve, hollow.]

    @heater, all true, but type "sine" into a Latin to English translator (or rely on my increasingly fading Latin from school!) and you get the English "without".

    Simply, "without" harmonics.
    SINE comes from the Latin SINUS, meaning a bend or gulf, or the bosom
    of a garment.

    But I shall ponder again the wonderful beauty of the shape so described. Strangely, sine waves look different to me now.

    Oh, and as an aside, tonight I wrote about 10 scripts for antibiotics for sinus infections.

    @Ahle2, thanks++ for this code. I shall add another switch to the touchscreen program so you can output sine waves.
    @Phil Pilgrim
    Do you have any schematic for a "cheap" but high quality filter + buffer solution with a steep filter curve?

    ? Butterworth ? Chebyshev ? Elliptic

    Would use a few op amps though.
    Then it can be used as an oscillator for my upcoming subtractive synthesizer.

    *ears prick up* Sounds great. I'd love to build a graphical front end if you get this working. Lots of knobs and sliders and things.
    Answers: 1) A quadcopter. 2) Very high. 3) The internet. 4) A lot. 5) No.
  • Heater.Heater. Posts: 19,695
    edited July 2012 Vote Up0Vote Down
    Dr_A,

    "sine" -> "without"

    Interesting, never heard that before.
  • Mark_TMark_T Posts: 1,621
    edited July 2012 Vote Up0Vote Down
    After hearing all those anatomical and pathological terms I'm now sorry I went off on a tangent!
  • Mark_TMark_T Posts: 1,621
    edited July 2012 Vote Up0Vote Down
    cavelamb wrote: »
    It's not about the signal generator, per se,
    An eight knob object in itself would be pretty neat.
    What could you use that for?

    Remote audio mixing-desk slice?
  • kuronekokuroneko Posts: 3,623
    edited July 2012 Vote Up0Vote Down
    Amaral wrote: »
    There's a small signal being generated at pin 0 , is it just mine or it's a bug somewhere ?
    Looks like a bug. The call in TestBench uses 32 for the sync pin claiming no pin. But the |< and << operators only look at the lower 5 bit anyway which makes 32 look like 0. As a quick fix you could change the start method in the PSG to:
    delayLine = (|<invertedPin) | (|<outPin) | (|<syncPin) [COLOR="blue"]& (syncPin <> 32)[/COLOR]
    
    The last bit makes sure that 32 is in fact treated as no pin (only for the syncPin).

    @Ahle: Is this no pin feature supposed to work for all pin parameters? Regardless, -1 or a NOPIN constant may be less confusing.
  • Ahle2Ahle2 Posts: 906
    edited July 2012 Vote Up0Vote Down
    @Kuroneko
    Yes, that's a bug.
    I am coding in C/C++ many hours each day (at work), that blurs my "spin vision" a little bit.
    I will fix it!

    @Phil
    Thank's.... that's an awesome site. It has got all you need to calculate the filter too!!
    SIDcog - The sound of the Commodore 64 in a single cog: Thread, OBEX, SIDcogMedlay.mp3
    AYcog - An emulation of the AY3-8910 / YM2149F PSG: Thread, OBEX
    SNEcog - An emulation of the SN76489 PSG(and variants): Thread, OBEX
    Propeller chiptune player: Thread
Sign In or Register to comment.