Arduino Yun / SPI Problem / Power Measuring CS5463

/dev: Actually, those look ok. See Section 6.1.11. That high bit is toggling between DRDY and !DRDY as the chip performs conversions.

You commented out the CONFIG read/write, so I have no idea what happened. You must think I'm Santa Claus, who knows when you are sleeping, and knows when you're awake... ;)

Cheers, /dev

Sounds great that the status register makes sense, I only commented the Config read out in order to see the status values by itself, when i was testing the config register the values where changing after every reading cycle which did not make sense to me, shouldn't they be persistent over time?

Cheers

shouldn't [the CONFIG register] be persistent over time?

Yes, it should not change. However...

To be blunt, we can't trust your interpretation of what you saw. You must show us the code and the output it produces... together.

After that, you'll need to hook up your LA to confirm that the sketch really sends and receives what it prints. You may need to attach screen prints of the LA software for us to interpret.

It's all about verification, at many levels.

I have done some testing and checked the values that I am sending over SPI.
I observed that the Arduino is sending the correct values to the CS5463, although the CS5463 responds to it with two phrases alternately.
In some cases it responds ([0][0][0][1]) which would be correct for the Config register. The first byte is the response to the register selection and byte 2-4 are my high middle and low byte. This results in a low byte value of 1 on my serial monitor.
The second case however delivers a ([0][128][0][1]) which means that the MSB of the high byte is a logic one instead of the expected logic 0.
I confirmed this behavior with the serial monitor and both the logic analyzer and my oscilloscope. After rebooting the Arduino the CS5463 behaved in the same way.
I lowered the SPI CLK to 1MHz (arduino clock divider=16) but it did not change the behavior.
EDIT: After checking more of the brodcasted bytes I also found the value ([0][128][0][5]) in the config register. There must be something wrong that makes it change over time. Could it be a wrong initialization of the SPI BUS and the CS5463 chip itself?

I attached the code I am using and the pictures of the LA and oscilloscope.
Right now I am rereading the spec sheet to get the correct configuration for measuring a 50Hz sinus wave.

Cheers!
Blizzart

CS563_SPI_Config.ino (5.37 KB)

Osci_Case_1.png

That clock signal looks nasty, but it could be aliasing. You should zoom in (sample faster) to see how they look. I’m a little suspicious because there’s similar noise on the other lines. How long are these wires?

Do you have decoupling bypass caps? See Figure 18, which shows three. I don’t see any on the schematic.

For now, I think I’d let the MODE pin just float LOW, instead of driving it from the Arduino.

Cheers,
/dev

Yes, there looks like a lot of nasty ringing on that clock pulse. It is very much worth it zooming in on them to get a better view. It looks like there are only four clocks per group, where the logic analyzer shows four? It seems like the scope has enough resolution to not be aliasing those pulses, but zooming in would prove that one way or another.

I agree, the noise on the other signals, which are coincident with the clock, makes me suspect long leads and insufficient bulk and/or bypass capacitance at the chip.

I checked the leads on my oscilloscope and shortened them as much as possible, and made sure that the ground connection is decent.
Then I zoomed in on the clock line and and snapped a couple of pictures for you.


I also measured the SPI pins straight on the arduino with no connection to the CS5463 to provide a reference of the signal.


I added some decoupling caps to the VA+ and VD+ inputs with a capacity of 1uF each. (C1 and C2 in the schematic)

EDIT:
I found a mistake in my code, the WRITE byte in my enum should be 64 instead of 32.
After commenting out the reading of the status register the config register behaves completely normal and I can write values to it and verify them through the read process.
However, when I leave the status read in the code, my config values are still changing.

That clock signal looks reasonable. Adding some larger bulk capacitance is usually good, but for bypass caps, larger is not better: smaller caps can better smooth high frequency current changes. Usually 0.1uF or 0.01uF caps are used for bypass caps. The reference schematic uses 0.1uF. I would add some in addition to the caps you have. The larger caps smooth out the slower high current variations, the smaller ones take care of the higher frequency switching variations.

ShapeShifter:
That clock signal looks reasonable. Adding some larger bulk capacitance is usually good, but for bypass caps, larger is not better: smaller caps can better smooth high frequency current changes. Usually 0.1uF or 0.01uF caps are used for bypass caps. The reference schematic uses 0.1uF. I would add some in addition to the caps you have. The larger caps smooth out the slower high current variations, the smaller ones take care of the higher frequency switching variations.

Thanks, for the explanation. I do understand the characteristics and behavior of a capacitor and high frequency signals or spikes on a power line, I added another 0.01uF capacitor for the power inputs.

I changed to a new version of code with more register writes.
The writing process seems totally fine in the LA.

I can read out the same register values as long as I only read one register and comment out everything else, as soon as I read the config and status in one sketch or any combinations of two registers the values are changing over time.
Code is attached.

CS5463_SPI_V4.0.ino (9.31 KB)

I agree, those signals look much better! There should also be a bypass cap on Vref. That may affect the readings, but doubt it would affect the register contents.

Could I suggest something like this at the end of loop, to pace the output and keep serial interrupts from delaying the SPI transfers? It keeps the LA traces together a little nicer:

  Serial.flush(); // let all the serial TX interrupts finish...

  static uint32_t lastTime = 0; // I would usually put this at file scope and
                                // initialize it to millis() at the end of setup
  while (millis() - lastTime < 1000) // or 2000ms?
    ;
  lastTime = millis();
}

This will make it a little easier to capture, too.

What output do you get when you read any two registers?

There is an IC bit in the status register that indicates an “invalid command” (if IC == 0). Be sure to check that.

And you’re reading too many bytes for VOLTAGE_RMS, CURRENT_RMS, POWER and TEMPERATURE. Those are 1-byte registers. Although the spec says

Section 5.14:
Register writes must be followed by three bytes of data.
Register reads can return up to four bytes of data.

…I can only find one-byte or three-byte registers. ???

Cheers,
/dev

Blizzart:
I changed to a new version of code with more register writes.
The writing process seems totally fine in the LA.

LA_WriteREG_1.JPG

I can read out the same register values as long as I only read one register and comment out everything else, as soon as I read the config and status in one sketch or any combinations of two registers the values are changing over time.
Code is attached.

Hi Blizzart, I also facing the same issue, reading CONFIG or STATUS only is ok (comment out everything else)
I am using Arduino Nano 5V. I unable to get a correct TEMPERATURE register reading as well, my room temperature expected around 24-26’C. But readings i get are

TEMPERATURE: 
10000
11110110
0
-2560


TEMPERATURE: 
10000
11110110
0
-2560


TEMPERATURE: 
10001
100100
0
9216

Below is the SPI setting i tried

  //start the SPI library;
  SPI.begin();
  SPI.setBitOrder(MSBFIRST);
  SPI.setClockDivider(64);
  SPI.setDataMode(SPI_MODE0);

  digitalWrite(CS, LOW);
	
  digitalWrite(RESET_PIN, LOW);
  delay (100);
  digitalWrite(RESET_PIN, HIGH);
  delay (100);
	
  //Sync commands 
  SPI.transfer(SYNC1);    
  SPI.transfer(SYNC1);     
  SPI.transfer(SYNC1);    
  SPI.transfer(SYNC0); 
   
  digitalWrite(CS, HIGH);

Do you have a working solution? can share?

Hey dennislwy,

I’m sorry for the delayed reply.
The problem you are facing is that you’re trying to read out the CS5463 with 16MHz over SPI, but it only supports speeds up to 4MHz.
You are using the wrong code for setting up the SPI frequency (they changed it at some point), now you’re not setting a divider any more, but the frequency itself.
This code should work:

 //start the SPI library;
  SPI.begin();
  SPI.beginTransaction(SPISettings(1000000,MSBFIRST,SPI_MODE0));		//Set SPI to 1MHz, MSBFIRST and SPI_MODE0
  
  	
//Run a Hardware Reset of the CS5463
	digitalWrite(CS, LOW);
	
	digitalWrite(RESET_PIN, LOW);
		delay (100);
	digitalWrite(RESET_PIN, HIGH);
		delay (100);

//Run a Soft Reset of the CS5463		
	//Sync commands 
   SPI.transfer(SYNC1);    
   SPI.transfer(SYNC1);     
   SPI.transfer(SYNC1);    
   SPI.transfer(SYNC0); 
   
   digitalWrite(CS, HIGH);
	
	delay (100);

Good evening,
I’m trying to create a meter using this IC and am basing myself on dennislwy friend code, but I’m also having the same problem, even without any signal in voltage and current inputs are my readings:

5
250
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
255
255
255
255
255
255
255
255
255
255
255
255
0
63
0
0
0
0
255
255
255
255
255
255
255
255
255
0
255
0
0
0
0
255
255
255
255
255
255
255
255
255
255
255
255
96
0
0
0
0
0
255
255
255
255
255
255
255
255
255
0
15
0
0
0
0
255
255
255
255
255
255
192
255
0
0
0
0
255
255
255
255
255
255
255
255
255
255
255
255
255
255
255
255
255
255
255
63
224
0
0
0
255
255
255
255
255
255
255
255
255
255
255
255
255
255
255
255
255
255
255
255
255
255
255
255
0
124
0
0
0
0
255
255
255
255
255
255
255
255
255
128
7
0
0
0
0
255
255
255
255
255
255
255
255
255
255
255
255
255
255
255
0
0
0
3
0
96
255
255
255
255
255
255
112
0
0
0
0
0
255
255
255
255
255
255
255
255
255
255
255
255
240
7
0
0
0
0
255
255
255
255
255
255
255
255
255
255
255
255
248
0
128
0
0
0
255
255
255
255
255
255
255
255
255
255
255
255
255
255
255
128
255
0
0
0
0
255
255
255
255
255
255
255
255
255
255
255
255
255
255
255
255
255
255
240
255
128
255
255
255
0
0
0
0
0
7
255
255
255
0
255
0
0
0
0
255
255
255
255
255
255
255
255
255
255
127
248
255
0

I’m using a simple code just to start doing the readings.

#include<SPI.h> //declaração da biblioteca de comunicação SPI

enum Registradores_CS5463{ //criando variáreis para os registradores do CS5463 e atribuindo valores fixos para elas

  // Registradores da Página 0
  CONFIGURACAO = 0,
  CORRENTE_DC_OFFSET = 1,
  GANHO_CORRENTE = 2,
  TENSAO_DC_OFFSET = 3,
  GANHO_TENSAO = 4,
  CONTADOR_CICLOS = 5, //número de conversões usado no conversor A/D
  TAXA_PULSOS_E = 6, //define a taxa de pulsos das saídas de energia E1, E2 e E3
  CORRENTE = 7,
  TENSAO = 8,
  POTENCIA_INSTANTANEA = 9, 
  POTENCIA_REAL = 10,
  CORRENTE_RMS = 11,
  TENSAO_RMS = 12,
  EPSILON = 13,
  POTENCIA_OFFSET = 14,
  ESTATUS = 15,
  CORRENTE_AC_OFFSET = 16,//RMS
  TENSAO_AC_OFFSET = 17, //RMS
  MODO = 18, 
  TEMPERATURA = 19,
  POTENCIA_REATIVA_MEDIA = 20,
  POTENCIA_REATIVA_INSTANTANEA = 21,
  PICO_CORRENTE = 22,
  PICO_TENSAO = 23,
  POTENCIA_REATIVA_TRIANGULO = 24,
  FATOR_POTENCIA = 25,
  MASCARA_INTERRUPCAO = 26,
  POTENCIA_APARENTE = 27,
  CONTROLE = 28,
  POTENCIA_ATIVA_HARMONICA = 29,
  POTENCIA_ATIVA_FUNDAMENTAL = 30,
  POTENCIA_REATIVA_FUNDAMENTAL = 31,


  // Registradores da Página 1
  LARG_PULSO_ENERGIA = 0,
  LIMITE_SEM_CARGA = 1,
  GANHO_TEMPERATURA = 2,
  TEMPERATURA_OFFSET = 3,


  // Registradores da Página 3
  INTERVALO_TENSAO_SAG = 6, //tempo em que a tensão deve se manter baixa para ativar a detecção de falha de tensão
  NIVEL_TENSAO_SAG = 7, //valor mínimo de tensão para ativar a detecção de falha de tensão
  INTERVALO_CORRENTE_SAG = 10, //tempo de falta de corrente para ativar a detecção de falha de corrente
  NIVEL_CORRENTE_SAG = 11, //valor mínimo de corrente para ativar a detecção de falha de corrente


  //COMANDOS
  LEITURA = 0,
  ESCRITA = 64,
  SYNC0 = 254,
  SYNC1 = 255,
};

const int PINO_CS = 10; //pino de controle do slave

byte H_VALOR_TENSAO_RMS;
byte M_VALOR_TENSAO_RMS;
byte L_VALOR_TENSAO_RMS;

byte H_VALOR_CORRENTE_RMS;
byte M_VALOR_CORRENTE_RMS;
byte L_VALOR_CORRENTE_RMS;

byte H_VALOR_POTENCIA_REAL;
byte M_VALOR_POTENCIA_REAL;
byte L_VALOR_POTENCIA_REAL;

byte H_VALOR_POTENCIA_APARENTE;
byte M_VALOR_POTENCIA_APARENTE;
byte L_VALOR_POTENCIA_APARENTE;

byte H_VALOR_POTENCIA_REATIVA;
byte M_VALOR_POTENCIA_REATIVA;
byte L_VALOR_POTENCIA_REATIVA;

void setup (){

pinMode(PINO_CS, OUTPUT); //define pino slave como saída
digitalWrite(PINO_CS, HIGH);

Serial.begin(9600);

SPI.begin();

SPI.setBitOrder(MSBFIRST);
SPI.setClockDivider(16);
SPI.setDataMode(SPI_MODE0);

delay(100);

//Configura o registrador CONFIGURACAO
digitalWrite(PINO_CS, LOW); //Seleciona o slave CS5463
SPI.transfer(0x40); //1º byte (comando de escrita e endereço do registrador CONFIGURACAO) 0100 0000
SPI.transfer(0x00); //2º byte (configuração) 0000 0000 - ultimo bit define PGA (ganho do amplificador de corrente) como 10x
SPI.transfer(0x00); //3º byte (configuração) 0000 0000
SPI.transfer(0x01); //4º byte (configuração) 0000 0001 - ultimo bit define o divisor de clock como 1
digitalWrite(PINO_CS, HIGH); //Desativa o slave CS5463

//Configura o registrador MODO
digitalWrite(PINO_CS, LOW); //Seleciona o slave CS5463
SPI.transfer(0x64); //1º byte (comando de escrita e endereço do registrador MODO) 0110 0100
SPI.transfer(0x00); //2º byte (configuração) 0000 0000
SPI.transfer(0x00); //3º byte (configuração) 0000 0000
SPI.transfer(0x01); //4º byte (configuração) 0000 0001 - ultimo bit ativa AFC
digitalWrite(PINO_CS, HIGH); //Desativa o slave CS5463

//Configura o registrador CONTROLE
digitalWrite(PINO_CS, LOW); //Seleciona o slave CS5463
SPI.transfer(0x78); //1º byte (comando de escrita e endereço do registrador CONTROLE) 0111 1000
SPI.transfer(0x00); //2º byte (configuração) 0000 0000
SPI.transfer(0x00); //3º byte (configuração) 0000 0000
SPI.transfer(0x04); //4º byte (configuração) 0000 0100 - bit 1 desativa o pino CPUCLK para economizar energia
digitalWrite(PINO_CS, HIGH); //Desativa o slave CS5463
}

void loop()
{
  digitalWrite(PINO_CS, LOW);
  SPI.transfer(0x18);
  H_VALOR_TENSAO_RMS = SPI.transfer(SYNC1);
  M_VALOR_TENSAO_RMS = SPI.transfer(SYNC1);
  L_VALOR_TENSAO_RMS = SPI.transfer(SYNC1);
  digitalWrite(PINO_CS, HIGH);

Serial.println(H_VALOR_TENSAO_RMS);
Serial.println(M_VALOR_TENSAO_RMS);
Serial.println(L_VALOR_TENSAO_RMS);

}

If you can give help I would greatly appreciate it.

Hey alan_lima

I didn't read your whole code, but I can tell you that you are using the wrong SPI settings. Try exchanging the following part:

alan_lima: SPI.begin();

SPI.setBitOrder(MSBFIRST); SPI.setClockDivider(16); SPI.setDataMode(SPI_MODE0);

delay(100);

with that:

//start the SPI library;
  SPI.begin();
  SPI.beginTransaction(SPISettings(1000000,MSBFIRST,SPI_MODE0)); //Set SPI to 1MHz, MSBFIRST and SPI_MODE0

Thank Blizzart, I tried it with the changes you suggested but not changed.

I understand that SPI.setClockDivider line of code (16); is dividing the clock by 16 like the Arduino clock is 16Mhz, is 1 MHz which is within the acceptable CS5463 value. The other parameters are the same. If you can give any other tips would greatly appreciate it, I need to be able to make this project work as soon as possible.

Can you please post the full code you used after you did the changes? Blizzart

Blizzard, I had read the whole topic, but I will re-read (my English is poor and I have missed something) and try again and put the result.

I tried using your code with as little change as possible. Just let the CS5463 the mode pin on the direct GND and direct reset pin VCC and used the pin 10 as CS (I'm using Arduino UNO). But readings still wrong. I'm using a protobord'll make a plate with welded components to reduce the possibility of poor contact. You could build your project with this IC and the Arduino? If you have any tip or idea to give me thank you very much, I need to be able to make this work as soon as possible is for a final project of my graduation from college.

Can you please provide the latest version of your code? Blizzart

This is the code I used:

enum CS5463_register_t {
  
 //Register Page 0
 CONFIG = 0,   CURRENT_DC_OFFSET = 1,   CURRENT_GAIN = 2,   VOLTRAGE_DC_OFFSET = 3,   VOLTAGE_GAIN = 4,   CYCLE_COUNT = 5,   PULSE_RATE_E = 6,   CURRENT = 7,   VOLTAGE = 8,   POWER = 9,   POWER_ACTIVE = 10, CURRENT_RMS = 11, 
 VOLTAGE_RMS = 12, EPSILON = 13, POWER_OFFSET = 14, 
 STATUS = 15, 
 CURRENT_AC_OFFSET = 16, VOLTAGE_AC_OFFSET = 17, 
 MODE = 18, TEMPERATURE = 19, 
 POWER_REACTIVE_AVERAGE = 20, POWER_REACTIVE = 21, CURRENT_PEAK = 22, 
 VOLTAGE_PEAK = 23, 
 POWER_REACTIVE_TRIANGLE = 24, 
 POWERFACTOR = 25, MASK_INTERUPT = 26, POWER_APPARENT = 27, CONTROL = 28, POWER_ACTIVE_HARMONIC = 29, POWER_ACTIVE_FUNDAMENTAL = 30, POWER_REACTIVE_FUNDAMENTAL = 31, 
    
 //Register Page 1
 PULSE_WIDTH = 0,
 LOAD_MIN = 1,
 TEMPERATURE_GAIN = 2,
 TEMPERATURE_OFFSET = 3,
 
 //Register Page 3
 VOLTAGE_SAG_DURATION = 6,
 VOLTAGE_SAG_LEVEL = 7,
 CURRENT_SAG_DURATION = 10,
 CURRENT_SAG_LEVEL = 11,

 // COMMANDS
 Read = 0,
 Write = 64,
 SYNC0 = 254, //SYNC 0 Command: Last byte of a serial port re-initialization sequence
 SYNC1 = 255, //SYNC 1 Command: Used during reads and serial port initialization.
 SELECT_PAGE = 0x1F,
 START_CONTINOUS = 0xE8,
 
}
;
const int CS = 10; // Assign the Chip Select signal to pin 8
//const int RESET_PIN = 13; // Assign Reset to pin 13
//const int MODE_PIN = 9; // Assign Mode to pin 9


//Bytes after register read
byte H_Byte_CONFIG;          //High Byte 
byte M_Byte_CONFIG;          //Middle Byte 
byte L_Byte_CONFIG;          //Low Byte

byte H_Byte_STATUS;          
byte M_Byte_STATUS;           
byte L_Byte_STATUS;          

byte H_Byte_VOLTAGE_RMS;
byte M_Byte_VOLTAGE_RMS;
byte L_Byte_VOLTAGE_RMS;

byte H_Byte_CURRENT_RMS;
byte M_Byte_CURRENT_RMS;
byte L_Byte_CURRENT_RMS;

byte H_Byte_POWER;
byte M_Byte_POWER;
byte L_Byte_POWER;

byte H_Byte_TEMPERATURE;
byte M_Byte_TEMPERATURE;
byte L_Byte_TEMPERATURE;

void setup() {   

  pinMode(CS, OUTPUT); //initalize the chip select pin;
//  pinMode(RESET_PIN, OUTPUT); //initalize the RESET pin;
//  pinMode(MODE_PIN, OUTPUT); //initialize the MODE pin;

  digitalWrite(CS, HIGH);
//  digitalWrite(RESET_PIN, HIGH);
//  digitalWrite(MODE_PIN, LOW);
  
  delay (100);
  
  
 //Create a serial connection to display the data on the terminal.   
  Serial.begin(9600);
  
//start the SPI library;
  SPI.begin();
  SPI.beginTransaction(SPISettings(1000000,MSBFIRST,SPI_MODE0)); //Set SPI to 1MHz, MSBFIRST and SPI_MODE0
  

 
 
 digitalWrite(CS, LOW);
 
// digitalWrite(RESET_PIN, LOW);
// delay (100);
// digitalWrite(RESET_PIN, HIGH);
// delay (100);
 
 //Sync commands 
   SPI.transfer(SYNC1);    
   SPI.transfer(SYNC1);     
   SPI.transfer(SYNC1);    
   SPI.transfer(SYNC0); 
   
   digitalWrite(CS, HIGH);
 
 delay (100);
 
 //Set Config register
 digitalWrite(CS, LOW); //Chip select to low to initialise comms with CS5463 
 SPI.transfer( Write | (CONFIG<<1) );
 SPI.transfer(0x00);   //3 bytes of data to set 24bits of config register        
   SPI.transfer(0x00);     
   SPI.transfer(0x01); 
    digitalWrite(CS, HIGH);   //Chip select to HIGH to disable comms with CS5463  

 //Set Mask register
 digitalWrite(CS, LOW); 
 SPI.transfer( Write | (MASK_INTERUPT<<1) );
 SPI.transfer(0x00);   //3 bytes of data to set 24bits of mask register (Set for no interrupts) 
 SPI.transfer(0x00);     
 SPI.transfer(0x00); 
 digitalWrite(CS, HIGH);   
 
 //Set Mode register
 digitalWrite(CS, LOW); 
 SPI.transfer( Write | (MODE<<1) );
 SPI.transfer(0x00);   //Sets High pass filters on Voltage and Current lines, sets automatic line frequency measurements 
 SPI.transfer(0x00);     
 SPI.transfer(0x01); 
 digitalWrite(CS, HIGH); 
 
 //Set Control register
 digitalWrite(CS, LOW); 
 SPI.transfer( Write | (CONTROL<<1) );
 SPI.transfer(0x00);   //Disables CPUCLK 
 SPI.transfer(0x00);     
 SPI.transfer(0x4); 
 digitalWrite(CS, HIGH);

 digitalWrite(CS, LOW); 
 SPI.transfer(START_CONTINOUS);
 digitalWrite(CS, HIGH);
 
 
 }


void loop()
{
 digitalWrite(CS, LOW);
 SPI.transfer( Read | (CONFIG << 1 ));     //Read the Config Register                                 
 H_Byte_CONFIG = SPI.transfer(SYNC1);   //Reads high byte and writes sync1                                      
 M_Byte_CONFIG = SPI.transfer(SYNC1);   //Reads middle byte and writes sync1                                    
 L_Byte_CONFIG = SPI.transfer(SYNC1);   //Reads low byte and writes sync1                                   
 //delay (10);
 digitalWrite(CS, HIGH);
 
 //delay (10);
 
 digitalWrite(CS, LOW);
 SPI.transfer( Read | (STATUS << 1 )); //Status //LSB "B0" is always zero
 H_Byte_STATUS = SPI.transfer(SYNC1);   //Reads high byte and writes sync1                                      
 M_Byte_STATUS = SPI.transfer(SYNC1);   //Reads middle byte and writes sync1                                    
 L_Byte_STATUS = SPI.transfer(SYNC1);   //Reads low byte and writes sync1 
 //delay (10);
 digitalWrite(CS, HIGH);
 
 
 digitalWrite(CS, LOW);
 SPI.transfer( Read | (VOLTAGE_RMS << 1 )); 
 H_Byte_VOLTAGE_RMS = SPI.transfer(SYNC1);   //Reads high byte and writes sync1                                      
 M_Byte_VOLTAGE_RMS = SPI.transfer(SYNC1);   //Reads middle byte and writes sync1                                    
 L_Byte_VOLTAGE_RMS = SPI.transfer(SYNC1);   //Reads low byte and writes sync1 
 digitalWrite(CS, HIGH);
 
 digitalWrite(CS, LOW);
 SPI.transfer( Read | (CURRENT_RMS << 1 )); 
 H_Byte_CURRENT_RMS = SPI.transfer(SYNC1);   //Reads high byte and writes sync1                                      
 M_Byte_CURRENT_RMS = SPI.transfer(SYNC1);   //Reads middle byte and writes sync1                                    
 L_Byte_CURRENT_RMS = SPI.transfer(SYNC1);   //Reads low byte and writes sync1 
 digitalWrite(CS, HIGH);
 
 digitalWrite(CS, LOW);
 SPI.transfer( Read | (POWER << 1 )); 
 H_Byte_POWER = SPI.transfer(SYNC1);   //Reads high byte and writes sync1                                      
 M_Byte_POWER = SPI.transfer(SYNC1);   //Reads middle byte and writes sync1                                    
 L_Byte_POWER = SPI.transfer(SYNC1);   //Reads low byte and writes sync1 
 digitalWrite(CS, HIGH);
 
 digitalWrite(CS, LOW);
 SPI.transfer( Read | (TEMPERATURE << 1 )); 
 H_Byte_TEMPERATURE = SPI.transfer(SYNC1);   //Reads high byte and writes sync1                                      
 M_Byte_TEMPERATURE = SPI.transfer(SYNC1);   //Reads middle byte and writes sync1                                    
 L_Byte_TEMPERATURE = SPI.transfer(SYNC1);   //Reads low byte and writes sync1 
 digitalWrite(CS, HIGH);
 
 
 int value_VOLTAGE_RMS = (H_Byte_VOLTAGE_RMS << 16) |(M_Byte_VOLTAGE_RMS << 8) | L_Byte_VOLTAGE_RMS ;
 int value_CURRENT_RMS = (H_Byte_CURRENT_RMS << 16) |(M_Byte_CURRENT_RMS << 8) | L_Byte_CURRENT_RMS ;
 int value_POWER = (H_Byte_POWER << 16) |(M_Byte_POWER << 8) | L_Byte_POWER ;
 int value_TEMPERATURE = (H_Byte_TEMPERATURE << 16) |(M_Byte_TEMPERATURE << 8) | L_Byte_TEMPERATURE ;
 
 
 
 delay (10);

 Serial.print("Config: ");
 Serial.println(H_Byte_CONFIG,BIN);
 Serial.println(M_Byte_CONFIG,BIN);
 Serial.println(L_Byte_CONFIG,BIN);
 delay (10);
 Serial.print("Status: ");
 Serial.println(H_Byte_STATUS,BIN);
 Serial.println(M_Byte_STATUS,BIN);
 Serial.println(L_Byte_STATUS,BIN);
 delay (10);

 Serial.print("VOLTAGE_RMS: ");
 Serial.println(H_Byte_VOLTAGE_RMS,BIN);
 Serial.println(M_Byte_VOLTAGE_RMS,BIN);
 Serial.println(L_Byte_VOLTAGE_RMS,BIN);
 Serial.println(value_VOLTAGE_RMS);
 delay (10);
 
 Serial.print("CURRENT_RMS: ");
 Serial.println(H_Byte_CURRENT_RMS,BIN);
 Serial.println(M_Byte_CURRENT_RMS,BIN);
 Serial.println(L_Byte_CURRENT_RMS,BIN);
 Serial.println(value_CURRENT_RMS);
 delay (10);
 
 Serial.print("POWER: ");
 Serial.println(H_Byte_POWER,BIN);
 Serial.println(M_Byte_POWER,BIN);
 Serial.println(L_Byte_POWER,BIN);
 Serial.println(value_POWER);
 delay (10);
 
 Serial.print("TEMPERATURE: ");
 Serial.println(H_Byte_TEMPERATURE,BIN);
 Serial.println(M_Byte_TEMPERATURE,BIN);
 Serial.println(L_Byte_TEMPERATURE,BIN);
 Serial.println(value_TEMPERATURE);
 delay (10);
 
}