Shop OBEX P1 Docs P2 Docs Learn Events
BS2 and BS2sx times. — Parallax Forums

BS2 and BS2sx times.

NewName007NewName007 Posts: 12
edited 2005-10-18 10:21 in BASIC Stamp
I was reading in the basic stamp manual and came upon the chart (table 5.24 pg187) that the BS2 works in units of 1ms and units in frequency is 1Hz. The example freqout 2, 1000, 2500 was given, they said this means on a BS2 a 2500Hz tone is generated on pin 2 for 1 second. Then they said refer to the chart for other stamps, the BS2sx works in units of 0.4 mS and 2.5Hz. How would the same freqout comand translate when using the BS2sx? Would it give a different result or would it still generate a 2500Hz tone for 1 second?

Comments

  • Jayguy5000Jayguy5000 Posts: 139
    edited 2005-10-18 04:50
    Hey,
    by the looks of the chart you would multiply 0.4 by 1000 to find how long the signal would be generated. Then you would multiply 2.5Hz times the frequency which was 2500Hz and you would get 62.5KHz. Correct me if I am mistaken but the BS2sx can generate a tone up to 81.917KHz so 62.5KHz is easily done by the sx. then again I could be totally mistaken.
    ~Jeremy

    P.S. Could some one let me know if my math is correct?

    Post Edited (Jayguy5000) : 10/18/2005 11:13:12 AM GMT
  • Kevin WoodKevin Wood Posts: 1,266
    edited 2005-10-18 10:21
    The numbers given for the BS2/BS2e make the math easy for those chips. 1ms is one millisecond, which is 1/1000th of a second. So for a 1 second tone, you are saying play the tone for 1000 units that are each 1/1000th of a second long. 1Hz is one Hertz, which is one unit of frequency. If you wanted to play a 1KHz tone (the same tone played on TV when you see the color bars), you would play a tone that was 1000 units of 1Hz each. For a 2.5KHz tone, you would play a tone that was 2500 units of 1Hz each. Since there is a 1 to 1 correlation with the units, it works nicely. For the other chips, you need to use the conversion factors given in the table.

    First you need to first determine the duration of the tone, such as 5 seconds, and the frequency(pitch) of the tone, such as 3KHz. Then you have to divide by the period in the chart to get the number for your code, using the units given in the chart. So for the BS2sx:

    Duration:
    1. Convert seconds to milliseconds --> 5 sec * 1000ms/sec = 5000ms
    2. Divide by units conversion factor --> 5000ms / 0.4ms = 12500 units that are each 0.4ms in duration
    3. Use this number of duration units in your freqout command for the duration value

    Frequency(Pitch):
    1. Convert Kilohertz to Hertz --> 3Khz = 3000Hz
    2. Divide by units conversion factor --> 3000Hz / 2.5Hz = 1200 units that are each 2.5Hz in frequency(pitch)
    3. Use this number of frequency units in your freqout command for the frequency(pitch) value

    For example: FREQOUT 2, 12500, 1200 for a 3KHz tone played for 5 seconds on a BS2sx.

    This example would produce a 1.2KHz tone played for 12.5 seconds on the BS2/BS2e.

    If you see a FREQOUT command, such as FREQOUT 2, 3500, 15000 (or any numbers you aren't certain of), and want to determine the tone duration and frequency, multiply the # of units in the freqout command by the conversion factor in the chart for your BS2 module to get the duration in milliseconds and frequency in Hz.
Sign In or Register to comment.