Problem shifting bitwise Output

Hi!

I have 7 Relais which should be switched bitwise. Im using this code

const byte volnumPinsright = 7;
byte volpinsright[] = {
  0, 1, 2, 3, 4, 5, 6}; 

void setvol(int vol){
    for (byte i=0; i<volnumPinsright; i++) {
        byte state = bitRead(vol, i);
        shifter.setPin(volpinsright[i],state);
      }
 shifter.write();
}

Im using a 74HC595 Shiftregister with this Library
http://bildr.org/2011/08/74hc595-breakout-arduino/

Do you see any logical mistakes in this piece of code? The problem is that it doesnt work properly, the values dont agree with the online conversion tools ( like this http://easycalculation.com/decimal-converter.php)

Any suggestions?

EDIT:
Here the whole code

#include <Wire.h>
#define myAdress 0x46 //I2C Adresse dieses Moduls
boolean debug = true;
//Konfigurieren der Shift register
#include <Shifter.h>
#define SER_Pin 11 //SER_IN
#define RCLK_Pin 8 //L_CLOCK
#define SRCLK_Pin 12 //CLOCK
#define NUM_REGISTERS 2
Shifter shifter(SER_Pin, RCLK_Pin, SRCLK_Pin, NUM_REGISTERS); 

//Lautstärkeregelung 
//Rechts
const byte volnumPinsright = 7; //Anzahl der Pins für die Lautstärkeregelung
byte volpinsright[] = {
  0, 1, 2, 3, 4, 5, 6}; //Pins für die Lautstärkeregelung (7 Stück)
//Links
const byte volnumPinsleft = 7; //Anzahl der Pins für die Lautstärkeregelung
byte volpinsleft[] = {
  8, 9, 10, 11, 12, 13, 14}; //Pins für die Lautstärkeregelung (7 Stück)
//Quellenwahl
int currentout = 0; //aktuelle Ausgang


void setup()
{
  
  Wire.begin(myAdress);                // join i2c bus with address #4
  Wire.onReceive(receiveEvent); // register event
if (debug){  Serial.begin(9600);}       // start serial for output
}

void loop()
{
}

// function that executes whenever data is received from master
// this function is registered as an event, see setup()
void receiveEvent(int howMany)
{
  int data[howMany];
  while( Wire.available()) // loop through all
  { 
    //dfuliod
    for (int i=0; i < howMany;i++){
      data[i] = Wire.read(); // receive byte as int
    }
  }
  work(data);
}
void work(int data[]){
  switch (data[0]){
  case 1:
    { //Lautstärke einstellen
      for (byte i=0; i<volnumPinsright; i++) {
        byte state = bitRead(data[1], i);
        shifter.setPin(volpinsright[i],state);
       

      }
 shifter.write();
    }
    
    break;
     case 2:
    { //Lautstärke einstellen
          for (byte i=0; i<volnumPinsleft; i++) {
        byte state = bitRead(data[1], i);
        shifter.setPin(volpinsleft[i],state);
       

      }
 shifter.write();
    }
    break;

  case 3:
    {//Eingang wählen 
      int output = (data[1]+1); //unsere Eingänge fangen bei 2 an.
      digitalWrite(currentout,LOW);
      delay(5); //Warten bis sich das Relais geschaltet hat.
      digitalWrite(output, HIGH);
      currentout = output;
    }
    break;
  case 4:
    {//Ausgang wählen
      if (data[1]==1){//Entzerrer aktivieren
      digitalWrite(9, HIGH);
      digitalWrite(10, HIGH);
      
      }
      else{//Entzerrer deaktivieren
      digitalWrite(9, LOW);
      digitalWrite(10, LOW);
      }

      break;
    }
  }
}

Receiving via I2C and switching the relays

Nothing jumps out and grabs me (!) as being wrong - so what values are you passing in and what patterns are going to the relays? I presume something is happening when shifter.write () is called?

Have you checked weather the shift library shifts the MSB first or LSB? The pin order may be reversed.

Hi,

Im sending values between 1 and 255 to the Arduino (0x1 and 0xFF). I guess (Im not really sure) its using msb.

So there are no errors in this code since the result differs from those online conversion tools.
I guess I have to build an serial adapter for a debug console to see what really happens. :-/

I repeat: what values are you passing in and what patterns are going to the relays? Without both there is no information for us to go on.

Okay, I had a closer look

Input (on my rasbperry)
i2cset -y 1 0x46 0x1 0x50 
Thats a value of 80
What it should be
01010000
What it is
0111000

i2cset -y 1 0x46 0x1 0x1 (1)
What it should be
0001
What it is
1000100

i2cset -y 1 0x46 0x1 0xFF (255)
What it should be
1111111
What it is
1111111

Maybe I should try to do it all by myself without the library, but I guess this will take a while since I have no Idea how to operate the shift registers manually.