Shop OBEX P1 Docs P2 Docs Learn Events
Sx28 Square Wave — Parallax Forums

Sx28 Square Wave

CenlasoftCenlasoft Posts: 265
edited 2009-03-21 23:37 in General Discussion
Hello,
I was given this code by Terry a while ago. This was to create a square wave.

Device SX28, Oschs2, Turbo, OptionX, StackX

Freq 50_000_000

OutPin Pin RA.0 Output

Interrupt NOCODE 434_782 '217 khz

OutPin =~ OutPin
Returnint

Program Start

Start:
End

It works fine but is it possible to sweep a frequency range in this interrupt?
I want to start at 180 khz and end at about 225 khz

How many steps can this code do between the stated range?

Thanks,
Cenlasoft

Comments

  • BeanBean Posts: 8,129
    edited 2009-02-25 22:22
    You can, but only in certain steps.

    With a reload value of 139 you will get (50,000,000 / 139) / 2 = 179856 Hz
    With a reload value of 111 you will get (50,000,000 / 111) / 2 = 225225 Hz

    Device SX28, Oschs2, Turbo, OptionX, StackX
    
    Freq 50_000_000
    
    OutPin Pin RA.0 Output
    
    
    reload   VAR BYTE
     
    Interrupt NOCODE
      OutPin =~ OutPin
    Returnint reload
    
    Program Start
    
    Start:
      FOR reload = 139 TO 111 STEP -1
        PAUSE 1000 ' CHANGES SWEEP SPEED
      NEXT
      GOTO Start
    End
    
    


    Bean.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    There is a fine line between arrogance and confidence. Make sure you don't cross it...



    Post Edited (Bean (Hitt Consulting)) : 2/25/2009 10:31:26 PM GMT
  • CenlasoftCenlasoft Posts: 265
    edited 2009-02-25 23:58
    Hello,
    Thanks Bean, I will try it tonight
    Cenlasoft
  • CenlasoftCenlasoft Posts: 265
    edited 2009-03-21 23:37
    Hello,
    I have been trying Terry's sweep code with no luck. I am sure it me doing something wrong. I used a scope and an LCR circuit to see if I could get to resonance. If I use the interrupt without sweep at one frequency, it works.

    Device SX28, Oschs2, Turbo, OptionX, StackX

    Freq 50_000_000

    OutPin Pin RA.0 Output

    reload VAR BYTE

    Interrupt NOCODE
    OutPin =~ OutPin
    Returnint reload

    Program Start

    Start:
    FOR reload = 139 TO 111 STEP -1
    PAUSE 1000 ' CHANGES SWEEP SPEED
    NEXT
    GOTO Start
    End

    I am trying to get resonance but the square wave produced is not accurate enough.
    Thanks for any hints.
    Cenlasoft
Sign In or Register to comment.