i2c relay volume control logic.

For questions and comments on programming in general. And for any items that don't fit into the forums below.

Moderators: Benj, Mods

Post Reply
robin223
Posts: 9
Joined: Thu Jul 10, 2014 10:41 pm
Has thanked: 3 times
Been thanked: 1 time

i2c relay volume control logic.

Post by robin223 »

Hello,
I wonder if you can help me with a problem I'm having with a design -

I'm programming for an i2c controlled volume control which consists of 8 latching relays driven by x2 pcf8574an chips
and darlington drivers, PCF-1 sets the switch in one direction, PCF-2 resets it. Volume is controlled from a potentiometer.

My current solution is something like;

Read pot value average as a BYTE - get byte value from lookup table - Send inverted Byte to PCF-2 (to reset relays) - send uninverted byte to PCF-a (to set relays)

The problem with this solution is that if the previous byte is asking for the same switch position it still allows current to flow through
the relay coil.

Is it possible to use a calculation within flowcode referencing the last byte sent to the i2c address
and send a zero on the bits that need no change.

For example -


If the last value from the lookup table was 01101101

Currently it does this -

average pot value (Byte)= 253
lookup table byte = 0b00011111
inverted value sent to Pcf 1 = 0b11100000
uninverted Value sent to Pcf 2 = 0b00011111

But I'd like it to do this (referencing the last byte sent and only sending a pulse to the relay coils when required) -

average pot value = 253

Lookup table Byte = 0b11111111
Value sent to Pcf 1 = 0b01100000
Value sent to Pcf 2 = 0b00010010


Here is a schematic of the board I'm using for switching.
http://www.amb.org/audio/delta1/delta1_ ... e1_big.png

Hope this makes sense, I'm quite new to all this!

Thanks!

Robin.

robin223
Posts: 9
Joined: Thu Jul 10, 2014 10:41 pm
Has thanked: 3 times
Been thanked: 1 time

Re: i2c relay volume control logic.

Post by robin223 »

Sorry, meant to attach the file I'm working on. Not tested this yet....
Attachments
Volume Control Experiment 1.fcfx
(8.37 KiB) Downloaded 322 times

User avatar
LeighM
Matrix Staff
Posts: 2178
Joined: Tue Jan 17, 2012 10:07 am
Has thanked: 481 times
Been thanked: 699 times

Re: i2c relay volume control logic.

Post by LeighM »

Hi Robin,

For that you need to use exclusive OR

Code: Select all


bitsThatHaveChanged = newValue ^ previousValue

outputToRelayDriver = newValue & bitsThatHaveChanged

Hope that helps,
Leigh

Post Reply