8 (7.1) channel analog volume control

(*steve*)

¡sǝpodᴉʇuɐ ǝɥʇ ɹɐǝɥd
Moderator
Jan 21, 2010
25,510
Joined
Jan 21, 2010
Messages
25,510
Great, lets get this circuit working and then we'll worry about construction.
 

CommanderLake

Oct 2, 2012
227
Joined
Oct 2, 2012
Messages
227
Yipee I just knocked up the 08M2 starter kit and attached a 10k pot to the test board and it reads the value with the ADC!
I also have the velleman symmetrical power supply ready to go, the transformers are here now I'm just waiting for the farnell delivery with all the important bits.

Just got the last delivery!

All breaded up now I need to get the programming sorted.
 
Last edited:

CommanderLake

Oct 2, 2012
227
Joined
Oct 2, 2012
Messages
227
This picaxe has no SPI support so I have to do it the hard way but I dont know how to separate the input variable from the ADC into bits so I can do SPI manually?
 

(*steve*)

¡sǝpodᴉʇuɐ ǝɥʇ ɹɐǝɥd
Moderator
Jan 21, 2010
25,510
Joined
Jan 21, 2010
Messages
25,510
Remember I said:

Note that you'll have to check that whatever PICAxe you get supports the protocol used by this chip (SPI?). I think it's standard, but better to be safe than sorry

You're going to have to do what's called bit-banging. You need to manually take control of the output pin(s) and toggle them on and off the right way.

It's not ideal for a beginner.
 

CommanderLake

Oct 2, 2012
227
Joined
Oct 2, 2012
Messages
227
I know I can do that but I cant split the byte variable from the ADC to bits so I can "bit bang" them.
 

BobK

Jan 5, 2010
7,682
Joined
Jan 5, 2010
Messages
7,682
for (i=0; i<8; i++) {
output_bit(adc_val & 1);
adc_val >>= 1;​
}
 
Last edited:

CommanderLake

Oct 2, 2012
227
Joined
Oct 2, 2012
Messages
227
This is my code:

Code:
high C.2
symbol sout=C.0
symbol vnob=C.1
symbol cs=C.2
symbol sclk=C.4
symbol vol=b0
	let vol=0

main:
	readadc 1,b1
	if b1=vol then
		pause 10 
		goto main
	endif
	vol=b1
	b1=b1*3/4
	low cs
	for b2=0 to 1
		if b1 & 128=128 then high sout else low sout
		high sclk
		low sclk
		if b1 & 64=64 then high sout else low sout
		high sclk
		low sclk
		if b1 & 32=32 then high sout else low sout
		high sclk
		low sclk
		if b1 & 16=16 then high sout else low sout
		high sclk
		low sclk
		if b1 & 8=8 then high sout else low sout
		high sclk
		low sclk
		if b1 & 4=4 then high sout else low sout
		high sclk
		low sclk
		if b1 & 2=2 then high sout else low sout
		high sclk
		low sclk
		if b1 & 1=1 then high sout else low sout
		high sclk
		low sclk
	next
	for b3=0 to 47
		high sclk
		low sclk
	high cs
	goto main

But the & operator gives syntax error?
 
Last edited:

BobK

Jan 5, 2010
7,682
Joined
Jan 5, 2010
Messages
7,682
Sorry, I forgot, you are not progamming in C. No idea what the syntax would be in PICAXE basic.

Bob
 

(*steve*)

¡sǝpodᴉʇuɐ ǝɥʇ ɹɐǝɥd
Moderator
Jan 21, 2010
25,510
Joined
Jan 21, 2010
Messages
25,510
From doing a little research, you need an X1 or X2 part if you want the SPI interface.

Google for "picaxe spi biit-bang" and you will see that some people have tried (and indeed succeeded) in getting it working without the X1 or X2 part.
 

CommanderLake

Oct 2, 2012
227
Joined
Oct 2, 2012
Messages
227
ITS ALIVE!!! Volume control is so smooth with the picaxe at 16MHz its as if the pot were directly controlling the volume!!!
 

(*steve*)

¡sǝpodᴉʇuɐ ǝɥʇ ɹɐǝɥd
Moderator
Jan 21, 2010
25,510
Joined
Jan 21, 2010
Messages
25,510
That is very good.

I was fearing you may have issues with the SPI interface.

The next trick is to see if you can parallel up these chips (or determine how to connect multiple to the same SPI logic)

THEN we can start talking about the PCB :).
 

CommanderLake

Oct 2, 2012
227
Joined
Oct 2, 2012
Messages
227
My main problem was that I forgot to connect the Mute pin high, once I connected that my code worked.
I didn't bother trying 1 at a time this is all it takes to control 3 extra daisy chained devices
for b2=0 to 47
high sclk
low sclk
next
I'm already controlling them all in parallel its fully functional and I've redesigned the PCB.
 
Last edited:

(*steve*)

¡sǝpodᴉʇuɐ ǝɥʇ ɹɐǝɥd
Moderator
Jan 21, 2010
25,510
Joined
Jan 21, 2010
Messages
25,510
Excellent.

Since you have a PCB design, why not share it with us?
 

CommanderLake

Oct 2, 2012
227
Joined
Oct 2, 2012
Messages
227
Schematic
Schematic.png


PCB top
PCBtop.png


PCB bottom
PCBbottom.png
 

CocaCola

Apr 7, 2012
3,635
Joined
Apr 7, 2012
Messages
3,635
Looks pretty clean (note I didn't verify the circuit itself)... My only input is to verify hole sizes and make sure they are large enough... One thing I do for linear voltage regulators is make the middle (ground) hole a step larger so it's easier to get the solder to flow from top to bottom of the board... This is because the TO220 package sinks the ground pin so well sometimes it's a bugger to get the solder to actually migrate, the larger hole just makes it easier...

Also are those screw down terminals? If so consult the datasheet for them, most of them are tabbed to lock into each other when placed side by side, so when you chain them like this, if the holes are all properly spaced you can lock them all together and get a more solid 'one' unit mount vs multiple single mounts...

Overall the routing is clean, I would personally increase the trace width on the main power rails for sure and even on the other traces when you can... I'm simply not a fan of skinny traces unless there is a requirement or necessity for them...

There are also a few aesthetic changes I would do, but that is purely my personal anal preference, nothing else... For example if you are curious, look at R6, and the hole to the right, notice how the one trace from the top doesn't aim for the center of the hole? That bugs me :) Also on C3 and C4 look at the square pads, one trace comes off 90 degrees to the left then quickly cuts to the 45 degree corner, yet the other one comes off the pad at 45 degrees,again just anal aesthetics of mine...
 
Top