Monday, July 2, 2012

Using the Arduino PT2322 library for audio control

There are a limited set of audio volume & tone processors available on the market especially in an easy to use DIP format. The PT2322 is in common use in audio equipment around the world. However it hasn't been picked up by the Arduino community; most likely because of the lack of an available library. In the process of developing an internet radio around this chip and an MP3 decoder I created a library for the PT2322. The PT2322 is available from oddWires here.

The PT2322 is an interesting chip and is very flexible for audio control. It's designed as a 5.1 audio processor enabling you to control your audio setup from your Arduino. oddWires has the only library written for the Arduino for this device. Download it here: Library and Example. In addition to its designed use you could use the 6 channels to control an active loudspeaker system using 3 channels for hi/mid/lo over two channels. It's very cost-effective if you use any of the chip amps oddWires has on the site. There is also a PCB board for LM1875/TDA2030 chip amps available here.

PT2322 is a 6-Channel Audio Processor IC utilizing CMOS Technology specially designed for audio applications. 6-channel individual input, 6-channel master volume control, 6-channel individual volume trim control, 3-band tone control (treble, middle, and bass), mute function, 3D effect function, tone defeat function are all built into a single chip having the highest performance and reliability with few external components. The features are shown below.

  • Very Low Power Consumption (DC=9V)
  • I2C Bus Control
  • 6-Channel Individual Input
  • 6-Channel Master Volume Control: 0 to -79 dB (1 dB/step)
  • 6-Channel Individual Output TRIM Volume Control: 0 to -15 dB (1dB/step)
  • 3-Band Tone Control (Treble, Middle, Bass): + 14dB , 2dB/step
  • Mute Function
  • 3D Effect Function
  • Tone Defeat Function
  • Low Noise
  • High Channel Separation
  • Low Harmonic Distortion
  • Few External Components
  • Easy to Use
  • 28-pin DIP Package 
Functional Diagram

Constructing the PT2322 circuit

At first, the wiring diagram may seem to require a lot. In fact, much of the circuitry is repeated. It consists of impedence setting resistors & DC blockers on all the inputs and outputs. Then there are a set of RC circuits for shaping the treble, mid and bass response. Hooking up the Arduino is simple as the PT2322 is an I2C device using SDA & SCL. You'll hook these up to pin 4 and 5 respectively on your controller board unless you have an Arduino Mega where the pins are 20 and 21.  The chip works from 5 to 15V DC. I used the 9V supply used to power my Arduino. A regulated supply would be preferable. the oddWires PT2322 Library

Once you have it wired up, you're ready to start. You could program it directly using the standard Arduino Wire library but an easier solution is to use the library referred to above because it handles all the control necessary to drive the device per the datasheet to perform all of its capabilities:

      int init(void);
    void muteOn(void);
    void muteOff(void);
    void _3DOn(void);
    void _3DOff(void);
    void toneOn(void);
    void toneOff(void);
    void leftVolume(unsigned char flv);
    void rightVolume(unsigned char frv);
    void centerVolume(unsigned char cv);
    void rearLeftVolume(unsigned char rlv);
    void rearRightVolume(unsigned char rrv);
    void subwooferVolume(unsigned char sv);
    void masterVolume(unsigned char mv);
    void bass(unsigned char tb);
    void middle(unsigned char tm);
    void treble(unsigned char tt);

Just call init() first and then use the functions above as you wish. An example is supplied with the library. The example has additional functionality and shows how to use four buttons and a 16 x 2 LCD to display the current settings, change settings, mute etc.

The PT2322 is available from oddWires here.