Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronic Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Register Log in

Reading values from Energy IC Chip

Status
Not open for further replies.

Paradigm

Member level 1
Joined
Oct 13, 2011
Messages
36
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Activity points
1,648
Dear All Expert,

I am using a Arduino Uno board to capture some data of the energy IC chip connected using SPI. Following is the link to the datasheet of the ICs http://www.cirrus.com/en/pubs/proDatasheet/CS5464_F3.pdf

I had written the program and tested on the chip but it is not showing any different when I turn on my hair dryer which is connected to the energy IC. It shows the max value of 0xFFFFFF however, the max value on the datasheet is
7FFFFF. I suspect I didnt access the IC at all or didnt even communicate with the IC. Below is my code

Code:
#include <SPI.h>

int CS=9;
byte Data, Data1, Data2;
int MSB, LSB;
long Power;

void setup() {
  pinMode(CS, OUTPUT);
  Serial.begin(9600);
  SPI.setBitOrder(MSBFIRST);
  SPI.begin();
}

void CS5464_init() {
  digitalWrite(CS, LOW);
  //Initalise SYNC0 and SYNC1 with CS5464
  SPI.transfer(0xFF);
  SPI.transfer(0xFF);
  SPI.transfer(0xFF);
  SPI.transfer(0xFE);
  digitalWrite(CS,HIGH);
  delay(10);
  //Set to continous Conversion Mode
  digitalWrite(CS, LOW);
  SPI.transfer(0xE8);
  SPI.transfer(0xFF);
  SPI.transfer(0xFF);
  SPI.transfer(0xFE);
  digitalWrite(CS, HIGH);
  delay(10);  
}

void loop()
{
  CS5464_init();
  
  while(1) {
    Data = Data1 = Data2 = 0;
    
    digitalWrite(CS, LOW);
    SPI.transfer(0x08); //Read register 4 
    Data2 = SPI.transfer(0xFF); // SYNC1
    Data1 = SPI.transfer(0xFF); // SYNC1
    Data = SPI.transfer(0xFE); // SYNC0
    digitalWrite(CS, HIGH);
    
    MSB = 0x00FF & Data2;
    LSB = Data1 << 8;
    LSB = LSB | Data;
    Power = MSB << 16;
    Power = Power | LSB;
    
    Serial.print("Power of line =");
    Serial.print(Power, DEC);
    Serial.println('W');
    delay(1000);
  }
}
Can any expert here help me with my problem. Thanks a lot for your help :p
 

Paradigm

Member level 1
Joined
Oct 13, 2011
Messages
36
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Activity points
1,648
Hi Internetuser2k12,

The hardware is working properly as I got it from some vendor that do energy IC chip. I do not have the circuit diagram. But the IC breakout board do have a Vin+ and Vin-, Vout+ and Vout- to be connected to my AC supply and output of my Load. Then it have a breakout of SDO, SDI, CS and SCLK which I connect to my Arduino Uno like this (CS to pin10 SS, SDO to pin 12 MISO, SDI to pin 11 MOSI, SCLK to pin 13 SCK). Does that help? Thanks a lot for your help.
 

Paradigm

Member level 1
Joined
Oct 13, 2011
Messages
36
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Activity points
1,648
power circuit.jpg

Hi Internetuser2k12,

I sort of trace the PCB breakout board for my IC and the hardware looks something like the one attached. Pls advise. Thanks alot
 

Joined
Jul 25, 2012
Messages
1,192
Helped
170
Reputation
340
Reaction score
161
Trophy points
1,343
Activity points
0
Your connections are right. post your code. Are you sure that you are enabling CS/SS?
 

Paradigm

Member level 1
Joined
Oct 13, 2011
Messages
36
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Activity points
1,648
Hi Internetuser2k12, my code is on the first post. I didnt change my code after that. Still cannot get my IC to work. I connect the CS to pin 9 now. I didnt use pin 10 SS anymore as i will have more IC connected together. Sorry about the confusion. But still cannot get my code working.
 

Status
Not open for further replies.
Toggle Sidebar

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top