Shop OBEX P1 Docs P2 Docs Learn Events
From FREQOUT to multiple SX pin frequency outputs. — Parallax Forums

From FREQOUT to multiple SX pin frequency outputs.

Green PhantomGreen Phantom Posts: 21
edited 2008-10-27 20:09 in General Discussion
We all know that you can only use FREQOUT on the SX chip to generate a tone for the piezo speaker (for example) through one I/O pin, right?· I found a way to create multiple frequencies at one time.· Each assigned I/O pin will generate its own tone by INCreasing an SX variable inside a DO...LOOP statement.· If you want the highest frequency set at 4000 Hz, put a PAUSE 1 inside the DO...LOOP statement along with the code the INCrease a variable and send it to the corresponding Port A, B or C I/O pins of the SX chip.· Try increasing the value of one of the Byte variables by 3 or 5 and send the result to the pins designated for multiple frequency/multiple pin outputs.· Take the connection to the piezo speaker used to tie to one of the I/O pins and connect to one of the 8 pins that receive that byte variable.· Try connecting directly to a computer speaker.· According to my experiments, this will NOT damage the SX chip because instead of you needing to connect the resistors and capacitors as instructed in the sX manuals to drive an 8-ohm speaker, the computer speakers already have their own amplifier circuits.· Remember that here you are connecting the SX I/O outputs to the computer speaker jacks, NOT directly to a bare-bones speaker you find in your electronic parts benchtop drawers!· OR you can build a 741 Op-Amp or MOSFET-based amplifier and connect the SX to an 8-ohm speaker through the input connections to the amplifier circuit.· If you use the RANDOM command in SX/B and output the result to the I/O pins for the speaker, you generate "white noise!"· Through the 8-ohm speakers set up with the amplifier circuits as I explain here, the SX chip sounds like an Atari 2600 system.

Green Phantom

Comments

  • PJMontyPJMonty Posts: 983
    edited 2008-10-27 18:05
    Green Phantom,

    I'm having a hard time understanding what you're saying. However, it sounds like you are generating a different tone on different output ins and then just tying hthose pins together to drive a piezo speaker. Is this correct? If so, this is not a good idea.

    You say it won't damage the chip. That's just luck working in your favor. You're creating direct short circuits between pins using this technique when one goes high and the other other goes low. It's not damaging the chip simply because the duration of time is small. However, the idea of saving 20 cents on a few resistors while risking a $3 chip is not the best idea.

    Thanks,
    PeterM
  • Green PhantomGreen Phantom Posts: 21
    edited 2008-10-27 20:09
    PeterM:

    Let me explain some more.

    You DO NOT tie together the I/O pins directly to each other.· Here are a few possibilities I studied.

    Suppose you put this code in your SX/B program:

    DO

    ······ RC = RC + 3

    LOOP

    You connect the piezo speaker to only ONE of the I/O pins in Port C and then disconnect and reconnect the piezo speaker to another one of the I/O pins in Port C to choose a different tone...

    OR...

    You can tie together the I/O pins of Port C through an 8-bit multiplexer IC (such as the 74X151) by tying each I/O pin, RC.0 to RC.7·to the multiplexer IC's data select inputs D0 to D7, respectively,·then take the Port A 4-bit I/O pin array (8-bit for the SX52) and·for·an SX/B code put a code such as:

    PLP_B = 1

    DO

    ······ RC = RC + 3
    ······ IF RB < 255 THEN GOSUB Change_Tone

    LOOP

    Change_Tone:

    INC RA
    PAUSE 1
    RETURN

    You connect bits 0, 1 and 2 of Port A to the 74X151 multiplexer address inputs A,·B and C, respectively.· Tie the 74151 IC input "STROBE" or "G" (with a dash above it) to ground (VSS) of your power supply or to the SX chip VSS.· The 74151 has two different outputs, one true and one inverted.· The "true" output pin on the 74151 IC is labeled "Y" and the "inverted" output is labeled "W."· Connect one of the two pins on the piezo speaker to either of these two outputs and the other pin to ground.· Look up the data sheets on the 74151 TTL 8 to 1 multiplexer IC.· One of the links for the data sheet can be found at:

    http://www.jameco.com/Jameco/Products/ProdDS/1052232.pdf

    And third:

    You can hear all 8 tones though the speaker from the Port C I/O Pins through a JFET audio mixer.· Use this SX/B code, for example:

    DO

    ······ RC = RC + 3
    ······ PAUSE 1

    LOOP

    Build a JFET audio mixer circuit such as this example at:

    http://www.aaroncake.net/circuits/mixer1.asp

    Make 8 portions of the circuit connections·shown on the left of the schematic.· For each "In," connect ONE Port C I/O pin.· In the schematic you will notice each "In" has an optional ground connection.· Then from the "Out" connection in the schematic, use the speaker driver circuit provided in the SX manuals or a MOSFET or 741 Op Amplifier circuit.

    Another tip:

    If you want one of the I/O pins to generate white noise, you can enter this SX/B code:

    'Define the variable White_Noise
    White_Noise·· VAR·· Byte

    PLP_B = 1

    DO

    ······ RC = RC + 3
    ······ RANDOM White_Noise
    ······ RC.7 = White_Noise.0
    ······ IF RB < 255 THEN GOSUB Change_Tone

    LOOP

    Change_Tone:

    INC RA
    PAUSE 1
    RETURN

    Build the same multiplexer data selector circuit with the 74151 as explained.

    I hope these ideas help you undertand my concepts better.

    Green_Phantom
Sign In or Register to comment.