Shop OBEX P1 Docs P2 Docs Learn Events
Help! FREQOUT generates 2 freqencies — Parallax Forums

Help! FREQOUT generates 2 freqencies

n2dnrn2dnr Posts: 3
edited 2014-04-25 10:43 in BASIC Stamp
Why do I get 2 frequencies on the oscilloscope from pin 0 through 56K resistor too ground with this example? I only want one at 2500 hz. from 1 second

' {$STAMP BS2}
' {$PBASIC 2.5}


'DO


FREQOUT 0, 1000, 2500
'PULSOUT 0 , 100
'PWM 0 ,128,255
' HIGH 0
' low 0
'TOGGLE 0
'LOOP
END

Comments

  • Duane DegnDuane Degn Posts: 10,588
    edited 2014-04-25 10:12
    What are the two frequencies?

    I don't suppose one is 60Hz?
  • n2dnrn2dnr Posts: 3
    edited 2014-04-25 10:17
    I am using a 9V battery do you think 60Hz would still be an issue?
  • n2dnrn2dnr Posts: 3
    edited 2014-04-25 10:18
    It is more like the FREQ is ramping up - down - up - down ETC
  • Duane DegnDuane Degn Posts: 10,588
    edited 2014-04-25 10:27
    n2dnr wrote: »
    I am using a 9V battery do you think 60Hz would still be an issue?

    I think it could be. I think scope leads can pick up the 60Hz from induction.

    Based on your other comment, I kind of doubt this is the issue. I don't suppose you could post a picture of the scope traces?

    I'm not much of a BS2 person but hopefully someone else could help you out.
  • Tracy AllenTracy Allen Posts: 6,664
    edited 2014-04-25 10:41
    When you look at the raw FREQOUT on an oscilloscope, it is a mess. That is because the sine wave is created digitally using pulse density modulation. To see the "pure" sine wave you need to add a low-pass filter such as the one suggested in the BASIC Stamp manual on page 200. Even a single stage with 1kΩ and 0.1µF will clean it up pretty well.
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2014-04-25 10:43
    FREQOUT uses duty modulation to generate sine waves. You have to filter out the high-frequency duty stuff to get a clean trace on your scope. This is done via an RC filter (series resistor and cap to ground). Just a resistor to ground will not do the job, so what you're seeing is probably aliasing of the duty modulation masquerading as another frequency.

    -Phil
Sign In or Register to comment.