cs3318 and arduino - Page 7 - diyAudio
Go Back   Home > Forums > Source & Line > Analog Line Level

Analog Line Level Preamplifiers , Passive Pre-amps, Crossovers, etc.

Please consider donating to help us continue to serve you.

Ads on/off / Custom Title / More PMs / More album space / Advanced printing & mass image saving
Reply
 
Thread Tools Search this Thread
Old 30th January 2013, 04:00 PM   #61
MBA is offline MBA  Czech Republic
diyAudio Member
 
Join Date: Mar 2009
Linuxworks, I am still fighting to justify the use of cs3318 for pure stereo preamp (with that PITA soldering and carrier board ;-). I have no use for all the channels in my setup, no HT, no XO. What if I use the 8 channels as 4x stereo input selector controlled via sw - just control volume of the selected input and mute the rest? The datasheet reports 120 dB Inter-Channel Isolation - does it make sense or is it too much crazy? So I could spare the input relays and make an all-in-one preamp board.
  Reply With Quote
Old 30th January 2013, 06:03 PM   #62
MBA is offline MBA  Czech Republic
diyAudio Member
 
Join Date: Mar 2009
Just realized that it would be wise to buffer the input of 3318 which would mean 8 input buffers for 4x stereo...I should think faster then I write next time...;-)
  Reply With Quote
Old 30th January 2013, 06:12 PM   #63
ds23man is offline ds23man  Netherlands
diyAudio Member
 
Join Date: Oct 2006
Why not use just two channels, there is no quality gain in quadroupling.
  Reply With Quote
Old 30th January 2013, 06:34 PM   #64
MBA is offline MBA  Czech Republic
diyAudio Member
 
Join Date: Mar 2009
No... I meant to hardwire the 4 stereo inputs directly to the 8 channels of the cirrus chip and fake the input selector in 3318 via sw control: to mute 3 stereo inputs fully and let the "selected input" pass through to volume control...already obsolete (or overcomplicated) due to input buffer habit ;-)
  Reply With Quote
Old 31st January 2013, 04:05 AM   #65
diyAudio Member
 
linuxworks's Avatar
 
Join Date: Jul 2008
Location: santa clara, CA
so you want to sum all the 8 channels and just mute the inputs you don't want?

you'll pay a summed noise tax, I would guess.

muting is pretty clean on this chip, but you are still summing 4 pairs to select and I'm not sure that's going to give the best results.

relays are so simple and so clean. they are low-tech but so what?
__________________
My Photostream:http://www.flickr.com/photos/linux-works/
  Reply With Quote
Old 31st January 2013, 08:59 AM   #66
MBA is offline MBA  Czech Republic
diyAudio Member
 
Join Date: Mar 2009
Nothing against relays...as mentioned, it was more a twist of mind to justify the six high-end channels lying idle in the chip in pure stereo setup :-). But I cannot find device of similar sonic quality as 3318 with two channels only. I may come back to R-2R ladder...if I sacrifice fade-out/in while muting. I am still scared of soldering so small SMD...or I keep waiting until you finish your development and offer the 3318 module board as kit...;-))
  Reply With Quote
Old 24th March 2013, 09:00 PM   #67
maxw is offline maxw  United Kingdom
diyAudio Member
 
maxw's Avatar
 
Join Date: Jun 2004
Location: London
Anybody have any Arduino code for this IC?

Is this how you set a register?

Code:
Wire.beginTransmission(CSAddr);     // Begin I2C
Wire.write(B10000000);                 // Chip Address and R/W bit
Wire.write(0x00);                         // select the register
Wire.write(0x99);                         // set register
Here is what I've got but the device just seems to stay muted after bringing RESET high.

Code:
#include "Wire.h"

#define CSAddr 64 // 64 or 1000000b or 0x40
#define CIRRUS_RESET    8
#define CIRRUS_DISABLE_PDN_ALL B00000000  // the only bit we care about is b0=0
#define CIRRUS_MASTER_POWER 0x0e
int vol_level = 0;

void setup()
{
  Serial.begin(9600);
  
  // Power up sequence from Page 16, point 1.
  pinMode(CIRRUS_RESET, OUTPUT);
  digitalWrite(CIRRUS_RESET, LOW);
  delay(5000);
  // Power up sequence from Page 16, point 2, bring reset high
  Serial.println ("Starting powerup...");
  digitalWrite(CIRRUS_RESET, HIGH);   // disable reset (bring chip out of sleep)
  delay(5000);
  
  // Errata from http://www.digikey.com/Web%20Export/Supplier%20Content/Cirrus_598/PDF/Cirrus_PCN_CS3308-18_B0_C0.pdf?redirected=1
  Serial.println ("Applying errata thing...");
  Wire.beginTransmission(CSAddr);     // Begin I2C
  Wire.write(B10000000);              // Chip Address and R/W bit
  Wire.write(0x00);                   // select the register
  Wire.write(0x99);                   // set register
  Wire.write(B10000000);              // Chip Address and R/W bit
  Wire.write(0x1D);                   // select the register
  Wire.write(0x86);                   // set register 
  Wire.write(B10000000);              // Chip Address and R/W bit
  Wire.write(0x1F);                   // select the register
  Wire.write(0x02);                   // set register
  Wire.write(B10000000);              // Chip Address and R/W bit
  Wire.write(0x00);                   // select the register
  Wire.write(0x00);                   // set register 
  delay(5000);
  
  // Unmute by setting PDN_ALL, from page 15.
  Serial.println ("Unmuting...");
  Wire.write(B10000000);              // chip_addr and r/w bit
  Wire.write(CIRRUS_MASTER_POWER);    // select the register
  Wire.write(CIRRUS_DISABLE_PDN_ALL); // set register

}


void loop()
{
  
  Wire.write(B10000000);              // chip_addr and r/w bit
  Wire.write(0x11);                   // select Master 1 Vol-ume
  Wire.write(vol_level);              // send volume
  
  Wire.write(B10000000);              // chip_addr and r/w bit
  Wire.write(0x14);                   // select Master 2 Vol-ume
  Wire.write(vol_level);              // send volume
  
  Wire.write(B10000000);              // chip_addr and r/w bit
  Wire.write(0x17);                   // select Master 3 Vol-ume
  Wire.write(vol_level);              // send volume
  
  delay(100);
  
  if (vol_level < 254) {
    vol_level = vol_level + 1;
  }
  
  if (vol_level == 253) {
    vol_level = 1;
  }
  
  Serial.println (vol_level);
}
  Reply With Quote
Old 25th March 2013, 06:50 AM   #68
glt is offline glt  United States
diyAudio Member
 
Join Date: Oct 2004
Take a look at this example: Arduino - WireWrite
__________________
www.hifiduino.wordpress.com
  Reply With Quote
Old 25th March 2013, 09:54 PM   #69
maxw is offline maxw  United Kingdom
diyAudio Member
 
maxw's Avatar
 
Join Date: Jun 2004
Location: London
Quote:
Originally Posted by glt View Post
Take a look at this example: Arduino - WireWrite
Yeah I've read that. I've used other I2C devices without issues but they were all 5V. This time I'm using one of these to change the level. Do I put the pull up resistors on the arduino to 5V or on the CS3318 side to 3.3V?

I've updated my code a bit but still the IC is mute...


Code:
#include "Wire.h"

#define CSAddr 64 // 64 or 1000000b or 0x40
#define CIRRUS_RESET    8
#define CIRRUS_DISABLE_PDN_ALL B00000000  // the only bit we care about is b0=0
#define CIRRUS_MASTER_POWER 0x0e
#define CIRRUS_CHANNEL_POWER 0x0d
byte vol_level = 0;

void setup()
{
  Serial.begin(9600);
  
  // Power up sequence from Page 16, point 1.
  pinMode(CIRRUS_RESET, OUTPUT);
  digitalWrite(CIRRUS_RESET, LOW);
  delay(7000);
  // Power up sequence from Page 16, point 2, bring reset high
  Serial.println ("Starting powerup...");
  digitalWrite(CIRRUS_RESET, HIGH);   // disable reset (bring chip out of sleep)
  delay(5000);
  Wire.begin(); // join i2c bus
  delay(1000);
  
  // Errata from http://www.digikey.com/Web%20Export/Supplier%20Content/Cirrus_598/PDF/Cirrus_PCN_CS3308-18_B0_C0.pdf?redirected=1
  Serial.println ("Applying errata thing...");
  Wire.beginTransmission(CSAddr);     // Begin I2C
  Wire.write(B10000000);              // Chip Address and R/W bit
  Wire.write(0x00);                   // select the register
  Wire.write(0x99);                   // set register
  Wire.endTransmission();
  Wire.beginTransmission(CSAddr);
  Wire.write(B10000000);              // Chip Address and R/W bit
  Wire.write(0x1D);                   // select the register
  Wire.write(0x86);                   // set register 
  Wire.endTransmission();
  Wire.beginTransmission(CSAddr);
  Wire.write(B10000000);              // Chip Address and R/W bit
  Wire.write(0x1F);                   // select the register
  Wire.write(0x02);                   // set register
  Wire.endTransmission();
  Wire.beginTransmission(CSAddr);
  Wire.write(B10000000);              // Chip Address and R/W bit
  Wire.write(0x00);                   // select the register
  Wire.write(0x00);                   // set register
  Wire.endTransmission(); 
  delay(5000);
  
  // Unmute by setting PDN_ALL, from page 15.
  Serial.println ("Unmuting...");
  Wire.beginTransmission(CSAddr);
  Wire.write(B10000000);              // chip_addr and r/w bit
  Wire.write(CIRRUS_MASTER_POWER);    // select the register
  Wire.write(CIRRUS_DISABLE_PDN_ALL); // set register
  Wire.endTransmission();
  Wire.beginTransmission(CSAddr);
  Wire.write(B10000000);              // chip_addr and r/w bit
  Wire.write(CIRRUS_CHANNEL_POWER);    // select the register
  Wire.write(CIRRUS_DISABLE_PDN_ALL); // set register
  Wire.endTransmission();
}


void loop()
{
  Wire.beginTransmission(CSAddr);
  Wire.write(B10000000);              // chip_addr and r/w bit
  Wire.write(0x02);                   // select Master 1 Vol-ume
  Wire.write(vol_level);              // send volume
  Wire.endTransmission();
  
  Wire.beginTransmission(CSAddr);
  Wire.write(B10000000);              // chip_addr and r/w bit
  Wire.write(0x03);                   // select Master 2 Vol-ume
  Wire.write(vol_level);              // send volume
  Wire.endTransmission();

  delay(100);
  
  if (vol_level < 254) {
    vol_level = vol_level + 1;
  }
  
  if (vol_level == 253) {
    vol_level = 1;
  }
  
  Serial.println (vol_level);
}
  Reply With Quote
Old 26th March 2013, 12:33 AM   #70
diyAudio Member
 
Join Date: Jun 2011
Is that ALL the code?

...because it won't do anything. Unless there's something about Arduino C that is radically different from all the C I've ever come across.

You need a main() routine, and you need to call those routines...

int main(void)
{
setup();
loop();
}

Otherwise show us all of the code, it's impossible to debug fragmentary code.

...and there's something strange about the last few lines in the loop() routine, when the volume gets to 253, it resets to one.

I'd expect to see a bit (pin) test in a neverending loop in main and an associated upcount routine and a second bit test with an associated downcount routine.

For test purposes I'd bit-bang the serial comms in assembler, whitewire across a spare pin or two if the serial port pins won't let you use them like that. Once you've verified that the hardware works you can move on to using the built-in serial comms. Stuff like that can be really hard to debug, because all you need is a slightly incorrect setup and it all falls over. You need to work up the functionality from absolutely basic if you don't have code that you've verified previously.
  Reply With Quote

Reply


Hide this!Advertise here!
Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Digital Volume Contol - CS3318 - MAX5440 Ridin '24'z Digital Source 5 8th June 2011 01:36 PM
Sylonex and Arduino preamp oenboek Analog Line Level 17 12th March 2011 12:50 AM
Arduino for audio projects? glt Parts 5 9th March 2011 05:28 PM
Cooling fans with Arduino seahuston Chip Amps 10 23rd October 2010 05:58 AM
Can DIY audio be like Arduino glt Everything Else 1 3rd April 2009 03:57 PM


New To Site? Need Help?

All times are GMT. The time now is 06:18 AM.


vBulletin Optimisation provided by vB Optimise (Pro) - vBulletin Mods & Addons Copyright © 2014 DragonByte Technologies Ltd.
Copyright 1999-2014 diyAudio

Content Relevant URLs by vBSEO 3.3.2