Shop OBEX P1 Docs P2 Docs Learn Events
Generating frquency — Parallax Forums

Generating frquency

Has anybody written a program in Basic Stamp to generate any frequency and checking (Debug) to read the frequency? Appreciate the Help

Comments

  • That's not really a thing one can do with the BASIC Stamp. There is a FREQOUT command that will generate a specified frequency for a given period. There is no FREQIN command that let's you read an external frequency. You could use PULSIN twice (once for the side, once for the low side) to get the period and then do some math. The Propeller family has hardware that will let you generate frequencies and using 32-bit values, gives you more room when manually reading them.

  • Tracy AllenTracy Allen Posts: 6,656
    edited 2022-02-23 17:26

    Don't forget the COUNT command. For example,

    COUNT 1, 1000, myFreq
    FREQOUT 2, 2000, myFreq, 3*myFreq/2
    will count transitions on pin p1 for 1000 milliseconds, then play back a chord on p2 with that frequency and a fifth above for 2000 ms.

  • bluejay,

    Erco had done a project where the BS2 would listen for a note and then display it's value and play it.
    I believe he used the COUNT command as Tracy explained.

  • ercoerco Posts: 20,244
    edited 2022-03-04 19:09

    @Genetix said:
    bluejay,

    Erco had done a project where the BS2 would listen for a note and then display it's value and play it.
    I believe he used the COUNT command as Tracy explained.

    Excellent recall, Genetix! Just the opposite of the OP's request!

  • ercoerco Posts: 20,244

    A pseudo-workaround solution would be to VIDEO a BS2 generating various sounds, then let the BS2 listen to the playback and detect frequencies.

    Or use two Stamps, one to send and one to receive.

  • Interesting video. However wi and w2 is not defined as a variable.

  • ercoerco Posts: 20,244
    edited 2022-03-05 18:31

    @bluejay said:
    Interesting video. However w1 and w2 is not defined as a variable.

    I'm a rebel. I prefer to use predefined variables B0,B1,B2 etc and W0, W1, W2 etc. People fill pages naming variables and to me, brevity beats wordiness any time for clarity in the short programs I write. But then again I'm a hack, not a professional programmer. I use GOTOs too! (GASP!)

    https://homepages.cwi.nl/~storm/teaching/reader/Dijkstra68.pdf

Sign In or Register to comment.