Pages: 1 [2]   Go Down
Author Topic: Need tip for digital volume control/potmeter  (Read 2174 times)
0 Members and 1 Guest are viewing this topic.
United Kingdom
Offline Offline
Tesla Member
***
Karma: 223
Posts: 6593
Hofstadter's Law: It always takes longer than you expect, even when you take into account Hofstadter's Law.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

PS - you could also try:

1. Adding a 500ms delay before you send the C0 command (the datasheet says it needs at least 200ms).

2. Adding a short delay (maybe 1ms) between sending the C0 command and sending the set-volume command.
Logged

Formal verification of safety-critical software, software development, and electronic design and prototyping. See http://www.eschertech.com. Please do not ask for unpaid help via PM, use the forum.

Norway
Offline Offline
Full Member
***
Karma: 1
Posts: 142
likes to program Arduinos!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

WOW! I hooked up a little opamp and the IC is working like a charm! THANKS ALOT dc42!
But when I'm going to build this in to my amp, should I use high quality components, and use the exact the schematic in the datasheet?
Now I'm going to test the the code in the beginning of this post! smiley-grin
again, THANKS!
Logged

United Kingdom
Offline Offline
Tesla Member
***
Karma: 223
Posts: 6593
Hofstadter's Law: It always takes longer than you expect, even when you take into account Hofstadter's Law.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I'm glad you got it working! Most components are of adequate quality these days, and following the example schematic in the datasheet is a good idea unless you really know what you are doing.
« Last Edit: March 18, 2013, 03:27:03 pm by dc42 » Logged

Formal verification of safety-critical software, software development, and electronic design and prototyping. See http://www.eschertech.com. Please do not ask for unpaid help via PM, use the forum.

Norway
Offline Offline
Full Member
***
Karma: 1
Posts: 142
likes to program Arduinos!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I've tested a bit, and the IC is still working great! I only got one question.
I've decided to use this code, because it's simple and understandable (the other one had this "current_value" thing, that I didn't got working.)
Code:
  void set_volume(uint8_t value) {
  uint8_t tens = value / 10;
  uint8_t ones = value % 10;
  Wire.beginTransmission(PT_ADDR);
  Wire.write(0b11010000 | tens);
  Wire.write(0b11100000 | ones);
  Wire.endTransmission();
  }

if I put the value to zero, set_volume(0); , the volume at maximum, 0dB. If I put the value to 70, set_volume(70); , the volume is at minimum, -70dB. How can I turn this around, making set_volume(0) minimum and set_volume(70) maximum?
« Last Edit: March 18, 2013, 04:23:24 pm by hansibull » Logged

United Kingdom
Offline Offline
Tesla Member
***
Karma: 223
Posts: 6593
Hofstadter's Law: It always takes longer than you expect, even when you take into account Hofstadter's Law.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Code:
void set_volume(uint8_t value) {
  value = 70 - value;  // added this line
  uint8_t tens = value / 10;
  uint8_t ones = value % 10;
  Wire.beginTransmission(PT_ADDR);
  Wire.write(0b11010000 | tens);
  Wire.write(0b11100000 | ones);
  Wire.endTransmission();
  }
Logged

Formal verification of safety-critical software, software development, and electronic design and prototyping. See http://www.eschertech.com. Please do not ask for unpaid help via PM, use the forum.

South East USA
Offline Offline
God Member
*****
Karma: 5
Posts: 650
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Could you post the completed schematic & finished code you have used to  get this working successfully. I too am looking for a volume control to put inline with a microns, controlled by an atmega chip.
Logged

Pages: 1 [2]   Go Up
Jump to: