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.
i2c relay volume control logic.
Re: i2c relay volume control logic.
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
- 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.
Hi Robin,
For that you need to use exclusive OR
Hope that helps,
Leigh
For that you need to use exclusive OR
Code: Select all
bitsThatHaveChanged = newValue ^ previousValue
outputToRelayDriver = newValue & bitsThatHaveChanged
Leigh