CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

ADE7758 Library?

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
theasus



Joined: 31 May 2009
Posts: 79

View user's profile Send private message

ADE7758 Library?
PostPosted: Sun May 31, 2009 1:04 pm     Reply with quote

Hi,
Do you have the library of ADE7758? (Poly Phase Multifunction Energy Metering IC with Per Phase Information). I couldn't work with ADE7758. Can anyone help me about this problem?
dyeatman



Joined: 06 Sep 2003
Posts: 1934
Location: Norman, OK

View user's profile Send private message

PostPosted: Sun May 31, 2009 1:37 pm     Reply with quote

One other user posted here a while back looking for a driver for this chip and got no answer so I would assume no one here has one. However, the chip appears to have a standard SPI interface so it shouldn't be hard to interface yourself if you have some experience with programming C on the PIC.

Here is some work 8051 on an driver in C that looks like it can be adapted pretty easily
http://www.8051projects.net/forum-t18372-post.html
theasus



Joined: 31 May 2009
Posts: 79

View user's profile Send private message

PostPosted: Mon Jun 01, 2009 11:46 am     Reply with quote

Actually I want to use PIC 16f877A with ADE7758. I don't know anything about 8051. If you have any source code about my problem please help me.
Markdem



Joined: 24 Jun 2005
Posts: 206

View user's profile Send private message Send e-mail

PostPosted: Wed Jun 03, 2009 5:47 am     Reply with quote

I think I asked for the driver awhile back, could not find one, so I made one. Not very complete, but will get the data you probably need. If anyone can improve on it, please do. I would like to know what others think.

Driver
Code:

#define AD7758_CS      PIN_A0
#define ADE_DOUT       PIN_B7 //data to ADE
#define ADE_DIN       PIN_B6 //data from ADE
#define ADE_CLK       PIN_B5

//The following memory locations come from the ADE7758 datasheet
#define _IRMS         0x16
#define _VRMS         0x17
#define _PERIOD      0x27
#define _DIEREV      0x3F

int32 Read_ADE7753(ADE_COMMAND, len)
   {
      int i;
      int data[4];
      int32 RAW_VALUE;
 
      output_low(AD7758_CS);
            
      delay_us(1);

      for(i=1;i<=8;++i)
         {
            output_high(ADE_CLK);
            output_bit(ADE_DOUT, shift_left(&ADE_COMMAND,1,0));
            delay_us(1);
            output_low(ADE_CLK);
            delay_us(1);
         }
      
      output_low(ADE_DOUT);
      delay_us(6);

      for(i=1;i<=8;++i)
         {                      
            output_high(ADE_CLK);
            delay_us(1);
            shift_left(&data[0],1,input(ADE_DIN));
            output_low(ADE_CLK);
            delay_us(1);
         }

      delay_ms(1);   
   
      for(i=1;i<=8;++i)
         {    
            output_high(ADE_CLK);
            delay_us(1);
            shift_left(&data[1],1,input(ADE_DIN));
            output_low(ADE_CLK);
            delay_us(1);
         }

      delay_ms(1);   
   
      if(len > 16)
         {
            for(i=1;i<=8;++i)
               {    
                  output_high(ADE_CLK);
                  delay_us(1);
                  shift_left(&data[2],1,input(ADE_DIN));
                  output_low(ADE_CLK);
                  delay_us(1);
               }
         }

       if(len > 16)
         {
            RAW_VALUE= make32(data[0],data[1],data[2]);
         }
      else
         {
            RAW_VALUE= make32(data[0],data[1]);
         }

      output_high(AD7758_CS);   
   
      return RAW_VALUE;                        
   }


example
Code:

#include <18F4550.h>

#fuses HSPLL,NOWDT,NOPROTECT,NOLVP,NODEBUG,USBDIV,PLL5,CPUDIV1,VREGEN,NOBROWNOUT,NOMCLR
#use delay(clock=48000000)

#define VRMS_DIV      8718.50                     //number to divide VRMS raw data to get volts  (LSB\v)
#define IRMS_DIV      1550                        //number to divide IRMS raw data to get mA
#define IRMS_OFFSET   2200                        //PHY_I input offset to get 0 when no current flowing

#include "ADE7753.c"
#include "LCD420.c"

int i;

float VRMS_AVG, VRMS[10], VA;

int32 IRMS;
int32 value;

void main()
   {
      lcd_init();
      printf(lcd_putc,"Ready");
      output_high(AD7758_CS);
      
      delay_ms(1000);

      while(1)
         {   
            for(i=0;i<=8;i++)
               {      
                  VRMS[i] = read_ADE7753(_VRMS) / VRMS_DIV;
                  delay_ms(100);
               }
            VRMS_AVG = (VRMS[0] + VRMS[1] + VRMS[2] + VRMS[3] + VRMS[4] + VRMS[5] + VRMS[6] + VRMS[7]) / 8;

            value = read_ADE7753(_IRMS);
            IRMS = (value - IRMS_OFFSET) / IRMS_DIV;

            VA = VRMS_AVG * IRMS /100;

            lcd_gotoxy(1,1);                                 
            printf(lcd_putc,"VRMS = %5.2g",VRMS_AVG);
            lcd_gotoxy(1,2);                                 
            printf(lcd_putc,"IRMS = %04.2w",IRMS);
            lcd_gotoxy(1,3);                     
            printf(lcd_putc,"WATTS = %6.2g",VA);
      
            delay_ms(2000);

         }
   }


Tell me how you go.

Mark
aaronik19



Joined: 25 Apr 2011
Posts: 297

View user's profile Send private message

ade7758 220VAC connections
PostPosted: Mon Jun 06, 2011 2:26 pm     Reply with quote

Dear All,

Can someone explain how I can interface the 220VAC to the ADE7758? On the datasheet there is 220VAC through 1Mohm resistor. That's it? The arrow of the other side is the neutral?

Really thanks for your kind help.
dyeatman



Joined: 06 Sep 2003
Posts: 1934
Location: Norman, OK

View user's profile Send private message

PostPosted: Mon Jun 06, 2011 3:00 pm     Reply with quote

Essentially yes. Read page 3 of the below PDF, it will explain a lot...

datasheet.elcodis.com/pdf/13/3/130304/eval-ade7758eb.pdf
_________________
Google and Forum Search are some of your best tools!!!!
aaronik19



Joined: 25 Apr 2011
Posts: 297

View user's profile Send private message

AGND and DGND
PostPosted: Thu Jun 09, 2011 2:43 pm     Reply with quote

can I consider AGND and DGND the same?
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group