Shop OBEX P1 Docs P2 Docs Learn Events
help with frequency tracker and generator — Parallax Forums

help with frequency tracker and generator

AnubisbotAnubisbot Posts: 112
edited 2008-09-07 23:36 in Propeller 1
Hi, i am working on a solid state tesla coil what should run at 4Mhz .

I want to use the propeller to generate the differential 4 Mhz pulse to drive 2 BC 546 to beaf it up to drive 2 bigger mosfets in push pull mode.
And i want it to be self tuned, so i need to track the resonance frequency of the secondary coil with a antenna..

Would be spin good to use , or is it to slow to change the PLL frequency on the fly?
And if i have to us e PASM, could some one help me with the code since i never wrote any PSAM [noparse]:([/noparse]


Any help or ideas are welcome and would help big times......

Post Edited (Anubisbot) : 9/6/2008 6:32:39 PM GMT

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2008-09-06 19:13
    Spin should be fine for controlling the tuning. I assume you're using one of the cog counters to generate the 4MHz pulses. You don't have to change the frequency that quickly and you only have to load a new value into the FRQA/B register to adjust the frequency.

    If you want to determine the resonant frequency of the secondary coil, you don't detect a frequency, you normally detect the power output (or output voltage) which goes up near resonance. Typically, you have a detector coil or nearby antenna followed by a diode and capacitor so you have a simple half-wave rectifier and you measure the voltage across the capacitor, then you tune for peak voltage.

    The Propeller can measure voltages easily using one of the cog counters all in Spin. Read the Application Note (AN001) on the use of the cog counters. Download the ADC (analog to digital converter) object from the Object Exchange and read the comments and documentation.
  • AnubisbotAnubisbot Posts: 112
    edited 2008-09-06 19:59
    Hi Mike,
    yes i want to use the NOC PWM for the pushpull of the 4MHz , and thank for the tip with the ADC and the voltage peak to mesure.

    But what i still dont get is how to set the two pins for the differential output.

    CON
            _clkmode        = xtal1 + pll16x
            _xinfreq        = 5_000_000
    
    PUB NCO_PWM_single_ended_mode
    '             mode  PLL        BPIN     APIN
      ctra    := %00100_000 << 23 + 1 << 9 + 0  'Establish mode and APIN (BPIN is ignored)
      frqa    := $8000_0000                     'Set FRQA so PHS[noparse][[/noparse]31] toggles every clock
      dira[noparse][[/noparse]0] := 1                              'Set APIN to output
      repeat                                    'infinite loop, so counter continues to run
    
    



    I know i have to set mode bits to %00101 but i still dont get how to set the the 2 pins??
    would this %00101_000_00000000_011111_000_100000 be the right ctra for differential mode with pin 15 and 16 ??

    Best regards
    Anubisbot
  • Mike GreenMike Green Posts: 23,101
    edited 2008-09-06 20:19
    From page 205 in the Propeller Manual, I get: %0_00101_000_00000000_001111_000_010000

    The BPIN and APIN fields contain the B and A pin numbers with values from %000000 to %011111 for I/O pins 0 to 31.
  • Beau SchwabeBeau Schwabe Posts: 6,566
    edited 2008-09-06 20:30
    Anubisbot,

    Please post pictures of your final project or work in progress, I would love to see them.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Beau Schwabe

    IC Layout Engineer
    Parallax, Inc.
  • AnubisbotAnubisbot Posts: 112
    edited 2008-09-06 21:44
    Beau Schwabe (Parallax) said...
    Anubisbot,

    Please post pictures of your final project or work in progress, I would love to see them.

    I will post some pictures later, as soon i have my basic test circuit set up.

    But i think i may use the mode %00011 PLL differential , but i still dont get how to calculate the frequency with the PLLDIV
    ?? Since i am still so new to the propeller i dont get it ??
    Do u have a example on how to set the PLL differential mode to 4MHz on pin 15 and 16 ??
    And may be a little more simple explanation on how to calculate and set the Frequency??

    Best regards Anubisbot shocked.gif
  • AnubisbotAnubisbot Posts: 112
    edited 2008-09-06 22:43
    CON
            _clkmode        = xtal1 + pll16x
            _xinfreq        = 5_000_000
    
    PUB NCO_PWM_single_ended_mode
    '             mode  PLL        BPIN     APIN
      ctra    := %0_00101_000_00000000_001111_000_010000
      frqa    := 5400                     'Set FRQA so PHS[noparse][[/noparse]31] toggles every clock
      dira[noparse][[/noparse]16..15] := 1                              'Set APIN to output
      repeat
    



    this should give me on pin 15 and 16 a 100.5Khz freq.

    And it does it but only on pin 15 (or 16 when i swap 16 and 16 in the dira brackets )

    What do i do wrong????

    Update :

    I found the problem , it was :=1 for the dira

    CON
            _clkmode        = xtal1 + pll16x
            _xinfreq        = 5_000_000
                _PLA        = 5.375
    PUB NCO_PWM_single_ended_mode
    '               mode  PLL           BPIN       APIN
      ctra    := %0_00101_000_00000000_001111_000_010000
      frqa    := Round(_PLA*100000.0)                     'Set FRQA so PHS[noparse][[/noparse]31] toggles every clock
      dira[noparse][[/noparse]16..15] ~~                              'Set APIN to output
      repeat
    




    So now i have the generator for my push pull frequency
    Next i have to set up the ADC and them i will make a first test run with 12V input and then later with 32V.
    I will update the post as soon i have some more news and pictures...

    Post Edited (Anubisbot) : 9/6/2008 11:47:13 PM GMT
  • AnubisbotAnubisbot Posts: 112
    edited 2008-09-07 14:20
    CON _clkmode = xtal1 + pll16x
        _xinfreq = 5_000_000
     _PLA        = 537  
    VAR long parameter
    
    PUB go | x
    x:=100
      cognew(@entry, @parameter)
       parameter :=  _PLA*x      
       repeat
    
    
    DAT
    
            org
    
    entry   mov dira, diraval              'set APIN to output
            mov ctra, ctraval              'establish counter A mode and APIN
            mov frqa, par                  'set counter to increment 1 each cycle
    
    
    
    :loop   rdlong value, par              'get an up to date freq
            mov frqa, value                'set FRQA from value
            jmp #:loop                     'loop for next cycle
    
    diraval long |< 16 + |< 15                                    'APIN=15 BPIN=16
    ctraval long %0_00101_000_00000000_001111_000_010000          'NCO/PWM APIN=15 BPIN=16
    
    value   res 1
    
    



    After all night up, i have figured it out how it works in asm.
    So far so good. No i have a stupid question, is it possible to start 2 new cogs with Pasm from the same spin file??? If so how does it work in the the dat section.

    If it would be possible i could use the frequency tracker in easy to set the new freq to the parameter variable.???

    Or is there another way to link 2 PASM Cogs with each other with a common variable ??

    Like always all ideas are welcome, and do help...
    Best regards
    Anubisbot idea.gif
  • potatoheadpotatohead Posts: 10,261
    edited 2008-09-07 23:36
    You can start 2 new cogs.

    Just differentiate each assembly program with an org, and a label that you can use to pass the entry point to the cognew command.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Propeller Wiki: Share the coolness!

    Chat in real time with other Propellerheads on IRC #propeller @ freenode.net
Sign In or Register to comment.