Hey Guys,
I'm pretty new to the arduino world and I'm currently facing a communication Problem between the Arduino Yun and the CS5463 Measuring IC (Datasheet)
For testing and debugging purposes I am NOT connecting anything to line Voltage and only working with "save low voltage"!
The Arduino Power Outputs (5V VCC and GND) are powering the CS5463 and I connected the pins of the ICSP header to the corresponding SPI pins on the CS5463. (--> schematic below)
Right now I have nothing connected to the VIN and IIN pins, but I am planning on using a 50Hz sinus wave signal with Vrms=700mV coming from a function generator after reducing the the Voltage with two simple resistors. (the CS5463 can measure up to 250mV peak which should be about 170mV RMS).
I do have an Oscilloscope, stable power supply, function generator but I don't have a logic analyzer (but I want to buying on).
I was planning on using the signal provided by the function generator for both Voltage and Current Measuring for the first testing. Later I will carry on to a shunt Resistor for the Current.
I'm having trouble to read and write the registers in order to get the Voltage and Current measurements, that's why i went back to simply write some configurations in the config register and trying to read the data to verify the operation.
I would really appreciate your help and am very grateful for any advice.
If I missed any crucial information about my test setup just let my know and I will try to provide them as quickly as possible.
Thanks a lot!
Felix
Here is my shematic:
Here is my Code:
/*
CS5463 Single Phase Power Measuring IC
Circuit:
CS5463 attached to pins 8, 9, 12, 13:
/*
// CS5463 Register Addresses
// B7 B6 B5 B4 B3 B2 B1 B0
// 0 W/R RA4 RA3 RA2 RA1 RA0 0
// W=1 R=0
Read Write Address
Config = 0x0 0x40 0b00000 ; // Configuration
IDCoff = 0x2 0x42 0b00001 ; // Current DC Offset
Ign = 0x4 0x44 0b00010 ; // Current Gain
VDCoff = 0x6 0x46 0b00011 ; // Voltage DC Offset
Vgn = 0x8 0x48 0b00100 ; // Voltage Gain
CycleCount = 0xA 0x4A 0b00101 ; // Number of A/D conversions used in one computation cycle (N)).
PulseRateE = 0xC 0x4C 0b00110 ; // Sets the E1, E2 and E3 energy-to-frequency output pulse rate.
I = 0xE 0x4E 0b00111 ; // Instantaneous Current
V = 0x10 0x50 0b01000 ; // Instantaneous Voltage
P = 0x12 0x52 0b01001 ; // Instantaneous Power
PActive = 0x14 0x54 0b01010 ; // Active (Real) Power
IRMS = 0x16 0x56 0b01011 ; // RMS Current
VRMS = 0x18 0x58 0b01100 ; // RMS Voltage
Epsilon = 0x1A 0x5A 0b01101 ; // Ratio of line frequency to output word rate (OWR)
Poff = 0x1C 0x5C 0b01110 ; // Power Offset
Status = 0x1E 0x5E 0b01111 ; // Status
IACoff = 0x20 0x60 0b10000 ; // Current AC (RMS) Offset
VACoff = 0x22 0x62 0b10001 ; // Voltage AC (RMS) Offset
Mode = 0x24 0x64 0b10010 ; // Operation Mode
T = 0x26 0x66 0b10011 ; // Temperature
QAVG = 0x28 0x68 0b10100 ; // Average Reactive Power
Q = 0x2A 0x6A 0b10101 ; // Instantaneous Reactive Power
IPeak = 0x2C 0x6C 0b10110 ; // Peak Current
VPeak = 0x2E 0x6E 0b10111 ; // Peak Voltage
QTrig = 0x30 0x70 0b11000 ; // Reactive Power calculated from Power Triangle
PF = 0x32 0x72 0b11001 ; // Power Factor
Mask = 0x34 0x74 0b11010 ; // Interrupt Mask
S = 0x36 0x76 0b11011 ; // Apparent Power
Ctrl = 0x38 0x78 0b11100 ; // Control
PH = 0x3A 0x7A 0b11101 ; // Harmonic Active Power
PFA = 0x3C 0x7C 0b11110 ; // Fundamental Active Power
QF = 0x3E 0x7E 0b11111 ; // Fundamental Reactive Power / Page
created 15. September 2015
*/
// the CS5463 communicates using SPI, so include the library:
#include <SPI.h>
const int CS = 8; // Assign the Chip Select signal to pin 8
const int RESET = 13; // Assign Reset to pin 13
byte H_ByteC; //High Byte
byte M_ByteC; //Middle Byte
byte L_ByteC; //Low Byte
byte Read = 0B0000000;
byte Write = 0B0100000;
int junk;
void setup() {
pinMode(CS, OUTPUT); //initalize the chip select pin;
pinMode(RESET, OUTPUT); //initalize the RESET pin;
digitalWrite(CS, HIGH);
digitalWrite(RESET, HIGH);
delay (100);
//Create a serial connection to display the data on the terminal.
Serial.begin(9600);
//start the SPI library;
SPI.begin();
SPI.setBitOrder(MSBFIRST);
SPI.setClockDivider(8);
digitalWrite(RESET, LOW);
delay (100);
digitalWrite(RESET, HIGH);
delay (100);
digitalWrite(CS, LOW); //Chip select to low to initialise comms with CS5463
//Set Config register
SPI.transfer(0x40);
SPI.transfer(0x34); //3 bytes of data to set 24bits of config register
SPI.transfer(0xC);
SPI.transfer(0x34);
digitalWrite(CS, HIGH); //Chip select to low to disable comms with CS5463
}
void loop()
{
digitalWrite(CS, LOW);
SPI.transfer(Read);
SPI.transfer(0x0); //Read the Instantaneous Power Register
H_ByteC = SPI.transfer(0xFF); //Reads high byte and writes sync1
M_ByteC = SPI.transfer(0xFF); //Reads middle byte and writes sync1
L_ByteC = SPI.transfer(0xFF); //Reads low byte and writes sync1
digitalWrite(CS, HIGH);
delay (100);
Serial.print("Config: ");
Serial.println(H_ByteC,BIN);
Serial.println(M_ByteC,BIN);
Serial.println(L_ByteC),BIN ;
delay (100);
}