FREQOUT

BS2 icon BS2e icon BS2sx icon BS2p icon BS2pe icon BS2px icon

FREQOUT Example

 

 

 

Syntax: FREQOUT Pin, Duration, Freq1 {, Freq2}

Function

Generate one or two sine-wave tones for a specified duration.

Note: See SOUND for the BS1.

Quick Facts

  BS2 and BS2e BS2sx BS2p BS2pe BS2px
Units in Duration 1 ms 0.4 ms 0.265 ms 1 ms 0.166 ms
Units in Freq1 and Freq2 1 Hz 2.5 Hz 3.77 Hz 1.51 Hz 6.03 Hz
Range of frequency 0 to 32767 Hz 0 to 81.917 kHz 0 to 123.531 kHz 0 to 49.478 kHz 0 to 197.585 kHz
Related Commands

DTMFOUT, PWM

Explanation

FREQOUT generates one or two sine waves using a pulse-width modulation algorithm. The circuits in the figure below work by filtering out the high-frequency PWM used to generate the sine waves. FREQOUT works over a very wide range of frequencies so at the upper end of its range, those PWM filters will also filter out most of the desired frequency. You may find it necessary to reduce values of the parallel capacitors shown in the circuit, or to devise a custom active filter for your application.

 

Here's a simple FREQOUT command:

  FREQOUT 2, 1000, 2500

On the BS2, this command generates a 2500 Hz tone for 1 second (1000 ms) on I/O pin 2. See the table above for timing data on other BASIC Stamp models.

To play two tones on the same I/O pin at once:

  FREQOUT 2, 1000, 2500, 3000

This will generate a 2500 Hz and 3000 Hz tone (on the BS2) for 1 second. The frequencies will mix together for a chord- or bell-like sound. To generate a silent pause, specify frequency value(s) of 0.

Go to PBASIC Language home page

Open Getting Started with Stamps in Class

Open Connection Troubleshooting

BASIC Stamp Help Version 2.5.4

Copyright © Parallax Inc.

8/21/2013