Shop OBEX P1 Docs P2 Docs Learn Events
Propeller Signal Generator - Page 2 — Parallax Forums

Propeller Signal Generator

2

Comments

  • groggorygroggory Posts: 205
    edited 2012-06-29 10:31
    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: 2,347
    edited 2012-06-29 11:11
    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: 15,140
    edited 2012-06-29 12:54
    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: 1,178
    edited 2012-06-29 13:05
    @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".

  • Ahle2Ahle2 Posts: 1,178
    edited 2012-06-29 13:45
    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
  • Dr_AculaDr_Acula Posts: 5,484
    edited 2012-06-29 16:17
    @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.
  • Ahle2Ahle2 Posts: 1,178
    edited 2012-06-29 16:28
    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!
  • jmgjmg Posts: 15,140
    edited 2012-06-29 17:30
    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: 720
    edited 2012-06-29 20:25
    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 2012-06-29 23:23
    I'm curious. What are the 8 parameters the signal generator would have?
  • Ahle2Ahle2 Posts: 1,178
    edited 2012-06-30 00:35
    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.
  • cavelambcavelamb Posts: 720
    edited 2012-06-30 00:54
    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: 720
    edited 2012-06-30 01:01
    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: 23,514
    edited 2012-06-30 09:08
    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
  • Ahle2Ahle2 Posts: 1,178
    edited 2012-07-01 13:48
    New version in the OBEX!

    * Added sine wave
    * Added user definable waveform

    Thanks Beau, I stole some ideas from your sine wave generator... ;)
  • Mark_TMark_T Posts: 1,981
    edited 2012-07-01 14:02
    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: 1,178
    edited 2012-07-01 14:20
    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
  • jmgjmg Posts: 15,140
    edited 2012-07-01 17:19
    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: 1,178
    edited 2012-07-02 10:51
    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.
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2012-07-02 11:33
    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
  • pik33pik33 Posts: 2,347
    edited 2012-07-03 02:35
    @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: 21,230
    edited 2012-07-03 05:58
    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: 176
    edited 2012-07-03 07:02
    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,484
    edited 2012-07-03 07:34
    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.
  • Heater.Heater. Posts: 21,230
    edited 2012-07-03 08:22
    Dr_A,

    "sine" -> "without"

    Interesting, never heard that before.
  • Mark_TMark_T Posts: 1,981
    edited 2012-07-03 11:46
    After hearing all those anatomical and pathological terms I'm now sorry I went off on a tangent!
  • Mark_TMark_T Posts: 1,981
    edited 2012-07-03 11:48
    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 2012-07-03 16:56
    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: 1,178
    edited 2012-07-04 08:37
    @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!!
Sign In or Register to comment.