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

Propeller Signal Generator

13»

Comments

  • OldFartRadiomanOldFartRadioman Posts: 30
    edited 2012-08-31 13:26
    Quick noob question. I am needing to run two instances of the function generator, different frequencies different pins. I assume I will have to run them in different cogs? From Spin how do I control the objects from the main process? I need to change frequency and level on the fly.
  • OldFartRadiomanOldFartRadioman Posts: 30
    edited 2012-09-01 09:14
    Answering my own question the following code seems to work
    CON
      _CLKMODE = xtal1 + pll16x
      _XINFREQ = 5_000_000 
         
    OBJ
      psg[2] : "PropellerSignalGenerator"
      
     
    PUB main | i
    
      'Start "Propeller Signal Generator" and output signal on pin 10 (inverted signal on pin 11)
      psg[1].start(10, 11, 32) ' Sync pin = 32 = No pin
      psg[0].start(12,13,32)
      psg[0].setParameters(psg#SINE,1000,0,0)
    
      'Point to an 8 samples big (2^3) U16 waveform in memory           
      psg[1].setUserWaveform(@userWaveform, 3) 
      
      repeat
    
       
       'Generate high level guard tone for 200 millisecounds
        psg[1].setParameters(psg#SINE, 2175, 0, 0)
        waitcnt(cnt + 80_000 * 200)
    
       'Generate generate function tone for 40 millisecounds
        psg[1].setParameters(psg#SINE, 1950, 0, 0)
        waitcnt(cnt + 80_000 * 40)
    
       'Generate low level guard tone for 5 secounds         
        psg[1].setParameters(psg#SINE, 2175, 4, 0)
        waitcnt(cnt + 80_000_000 * 5)
         'Mute for 5 secounds         
        psg[1].setParameters(psg#MUTE, 2175, 4, 0)
        waitcnt(cnt + 80_000_000 * 5)
       
    
    dat
    userWaveform  word -$7FFF, $0000, $7FFF, $4444, $1111, $2222, $3333, $4444
    
  • Ahle2Ahle2 Posts: 1,179
    edited 2012-09-02 04:28
    First of all I just want to say welcome to the forums OldFartRadioman!
    I'm sorry that I'm not responding very fast these days, but I am not be very active in the Propeller community at the moment. I must say that I am little bit surprised that no one else has responded to your comment?!
    You seem to have solved your issues without any help, so I guees everything is working out the way you want.(or?)

    So what are you building with Prop? (I guess it has something to do with radio)

    /Johannes


  • OldFartRadiomanOldFartRadioman Posts: 30
    edited 2012-09-02 07:30
    Thanks for the reply. Better in the long run to dig in figure it out on your own. Yes on the radio, this sequence of tones should key a base radio remotely and then wake up some firemen. Tried pointing both instances of pfg to the same output pins and it worked but sounded better mixing two pins external. Next project is to wrap a UI around it and put it in a little box to live in my tool bag. I am going to try to put a Tychon Forth wrapper around pfg to play with it interactively.
  • Christof Eb.Christof Eb. Posts: 1,197
    edited 2012-09-05 04:00
    Hi Ahle2/Johannes,
    thank you for posting your great generator. I need a generator, that can send out bursts 3...100 cycles of sine waves with f=20....20kHz. The switch on/off must be at zero-crossing.
    I tried to understand your generator, but got completely lost. I can read asm a little bit. Would you mind to explain a little bit? How/When are the parameters read? What exactly do the two timers? I wanted to insert a few lines of code to switch on/off at zero-crossing depending on an additional parameter.
    Christof
  • Ahle2Ahle2 Posts: 1,179
    edited 2012-09-07 13:07
    Thanks for the kind words! :)

    When are the parameters read?
    One parameter is read every sample. That way adding more parameters will not eat extra cycles.

    Psuedo
    [COLOR=#3E3E3E]CogAddressPointer[/COLOR][COLOR=#3E3E3E]++[/COLOR][COLOR=#3E3E3E]
    [/COLOR][COLOR=#3E3E3E]HubAddress[/COLOR][COLOR=#3E3E3E]Pointer[/COLOR][COLOR=#3E3E3E]++[/COLOR][COLOR=#3E3E3E]
    [/COLOR][COLOR=#3E3E3E]*CogAddress[/COLOR][COLOR=#3E3E3E]Pointer[/COLOR][COLOR=#3E3E3E] = *[/COLOR][COLOR=#3E3E3E]HubAddress[/COLOR][COLOR=#3E3E3E]Pointer[/COLOR][COLOR=#3E3E3E]
    
    If CogAddress[/COLOR][COLOR=#3E3E3E]Pointer[/COLOR][COLOR=#3E3E3E] == The last "internal register" address
      HubAddress[/COLOR][COLOR=#3E3E3E]Pointer[/COLOR][COLOR=#3E3E3E] = First "external register" address
      CogAddress[/COLOR][COLOR=#3E3E3E]Pointer[/COLOR][COLOR=#3E3E3E] = First "internal register" address
    [/COLOR]
    


    What exactly do the two timers?
    They are used as "duty DACs"; One for the normal signal and one for the inverted signal.
    I need a generator, that can send out bursts 3...100 cycles of sine waves with f=20....20kHz. The switch on/off must be at zero-crossing.

    That is, of course, possible to do. It may be needed to make the code twice as big and half the sample rate. Is that acceptable?


  • DroneDrone Posts: 433
    edited 2013-05-04 00:56
    This object seems to have disappeared from the "new" OBEX (see below). What is the latest version of this object? I have V1.2.2 from awhile back.

    http://obex.parallax.com/objects/872/

    404 - Page Not Found

    Sorry, the page you're attempting to access can no longer be found.

    If you were attempting to reach a project located on the previous Propeller Object Exchange you will discover that your old links no longer function, and we apologize for any inconvenience this may have caused. We will create redirects for some of the more frequented project pages.

    Please try out the new site to locate your projects, if you were the owner of the project then a link will appear in your user account, else use the categories to find objects of interest.
  • PublisonPublison Posts: 12,366
    edited 2013-05-04 04:04
    Drone wrote: »
    This object seems to have disappeared from the "new" OBEX (see below). What is the latest version of this object? I have V1.2.2 from awhile back.

    http://obex.parallax.com/objects/872/

    404 - Page Not Found

    Sorry, the page you're attempting to access can no longer be found.

    If you were attempting to reach a project located on the previous Propeller Object Exchange you will discover that your old links no longer function, and we apologize for any inconvenience this may have caused. We will create redirects for some of the more frequented project pages.

    Please try out the new site to locate your projects, if you were the owner of the project then a link will appear in your user account, else use the categories to find objects of interest.

    Use the old OBEX http://obexclassic.parallax.com/objects/872/. Looks like 1.2 is the latest version.

    I'm finding a few objects are missing in the new OBEX.
  • DroneDrone Posts: 433
    edited 2013-05-04 08:05
    Publison - Thank you for the link to the old OBEX. I didn't know it was still around.
    Perhaps Parallax should provide the link to the old OBEX in the new OBEX splash page while the objects are migrating(?)
  • DroneDrone Posts: 433
    edited 2013-05-04 08:06
    Publison - Thank you for the link to the old OBEX. I didn't know it was still around.
    Perhaps Parallax should provide the link to the old OBEX in the new OBEX splash page while the objects are migrating(?)
  • User NameUser Name Posts: 1,451
    edited 2013-09-22 12:56
    Propeller Signal Generator was a huge help in cranking something out in a hurry yesterday. Many thanks to Ahle2 for making it available. PSG does a great job of leveraging the capabilities of the Prop. :)
  • Ahle2Ahle2 Posts: 1,179
    edited 2013-09-22 15:40
    Thanks!

    May I ask what you used it for?

    /Johannes
  • User NameUser Name Posts: 1,451
    edited 2013-09-22 17:59
    Ahle2 wrote: »
    May I ask what you used it for?

    High voltage power supply.

    Sine wave output was applied to audio power amplifier. Amplifier output drove primary of line-output transformer. Output of transformer was applied to voltage multiplier stack.

    I loved the ability to sweep frequency smoothly, without discontinuity. Also, the high sample rate made filtering easy and preserved amplitude stability.

    I'd been looking at a variety of more expensive solutions when I realized this one was right in front of my face and could be arranged in a moment. :)

    The code was wonderfully easy to use, but the simplicity belied the cleverness within. Took me a bit of time to understand how you managed the whole affair!
  • Ahle2Ahle2 Posts: 1,179
    edited 2013-09-24 01:49
    Cool! It's nice to hear that something I wrote can enable others to achieve good results with little efftort.


    PASM coding is ALL about trickery. It's just too fun! :)

    The Retronitus engine for an example, uses a lot of tricks to achieve high sample rate and a lot of features in just under 2k. Much development time went into trickery and magic. Actually, I was forced to use trickery because I often ran out of code space and/or the sample rate was not as high as I wanted.

    /Johannes
  • OrionOrion Posts: 236
    edited 2013-11-28 17:52
    I have been messing around with the square wave and duty cycle on this object and cannot seem to get it to output a 50% duty cycle consistently.

    psg.setParameters(psg#SQUARE, 100000, 0, psg#PW50)

    This outputs the following square wave. Every other cycle the on or off period changes. Any ideas why its not 50% every cycle? This seems to happen regardless of the frequency.

    NewFile9.bmp
    NewFile10.bmp
    NewFile11.bmp
    NewFile12.bmp
  • Ahle2Ahle2 Posts: 1,179
    edited 2013-11-29 02:51
    The short answer is aliasing.

    At 100 kHz one period is just 12.5 samples. If you generate a frequency not a multiple of the 1.25 Mhz sample rate used by PSG you will have this issue. The higher the generated frequency is the bigger the aliasing error will be. Real signal generators operates at Ghz sample rates and therfore the aliasing issue is much less obvious.
    It seems like you want to generate a pure square wave and nothing fancy. In your case I would use one of the other objects that use the counter in PLL mode to generate an aliasing free square wave.

    /Johannes
  • OrionOrion Posts: 236
    edited 2013-11-30 10:03
    Thanks. I suspected it was something along those lines but I'm ASM clueless.

    Great Object BTW.
  • I have 100 ohm resistors on the pins of the propeller chip from the Propeller Education Kit. I am using the Bit Scope Micro connected to a Raspberry Pi 2B+ to view the signal. I connected the ground from the Bit Scope Micro to the ground of the Education Kit. The sine wave is quite distorted. I am use to using Tektonix o'scopes to troubleshoot radios. This 1khz signal does not look like a beautiful clean 1khz signal directly from the AWG on the Bit Scope or the ones I have seen while troubleshooting radios. Any suggestions? My goal is to troubleshoot 2 broken DC to DC converters; the signals going into and out of the PWM IC.

    Thank you
Sign In or Register to comment.