BS2 and BS2sx times.
NewName007
Posts: 12
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
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
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.