Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics 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.

STPM10 Data active energy calculation problem

Status
Not open for further replies.

e.karimi.elc

Newbie level 4
Joined
May 24, 2018
Messages
5
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
67
Dear Sirs ,
I working on single phase energy meter project , we setup a simple board for STPM10 metering IC ,
we success on reading voltage and current but when we read active energy register we have transiant overshoot in our data , we get sample every 25 msec
for example these data collected from active energy register (decimal value) :
72766
73339
73659
72952
73013
73075
73138
73711
73517
73324
73388
73451
2039592
2039654
2039716
2039777

73760
73822
73885
74201
i dont know from where red items appear ? i check reading routine and parity and seems all okay .
Please help me to solve this problems
Thanks
 
Last edited by a moderator:

Hi,

You don't give informations that we can verify. Do you want us to guess:
* how your schematic looks like
* how your code looks like
* what input signal you use
?

Only you know the signal flow fom "analog signals input" to the "values sown in your post".
If you want us to help, you need to give us all informations about your application.
(A schematic from a datasheet is not useful to find an issue in your circuit)

Klaus
 

SPM10 active energy register holds only 20 bit data, 2039592 is an 21 bit value (0x1F1F28), so something's wrong with your software.
 

Thank you for your reply
The following code is a part of my software that read DAP register.
Please see my code and help me if any thing is wrong.
forgive me for english.


Code C - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
//---------- Idle State ----------------------------------------------------//
       SCL = 1;
       SDA = 1;
       SCS1 = 1;
       SYN1 = 1;
       delay_us(10);
       //---------- Latching Phase ------------------------------------------------//
       SCS1 = 1;
       SYN1 = 0;
       delay_us(5);
       SYN1 = 1;
       delay_us(1);
       //---------- Shifting Phase ------------------------------------------------//
       SCS1 = 0;
       delay_us(1);
       SYN1 = 0;
       delay_us(1);
       SYN1 = 1;
       delay_us(1);
       for (loop_counter = 0 ; loop_counter < 4 ; loop_counter++)
       {
           for (for_counter = 0 ; for_counter < 8 ; for_counter++)
           {
              DAP1[loop_counter] <<= 1;
              SCL = 0;
              delay_us(1);
              if (SDA == 1)
                 DAP1[loop_counter] = DAP1[loop_counter] | 0x01;
              else
                 DAP1[loop_counter] = DAP1[loop_counter] & 0xFE;
              SCL = 1;
              delay_us(1);
           }
       }
 
       DAP1_Prty = DAP1[0];
       DAP1_Prty = DAP1_Prty ^ DAP1[1];
       DAP1_Prty = DAP1_Prty ^ DAP1[2];
       DAP1_Prty = DAP1_Prty ^ DAP1[3];
       DAP1_Prty = DAP1_Prty ^ (DAP1_Prty << 4);
       DAP1_Prty = DAP1_Prty & 0xF0;
       //-----------------------------------------------------------------------//

 
Last edited by a moderator:

Hi,

We don´t know waht microcontroller and we don´t know what compiler you use.

SDA and SCL need external pullup, we don´t see the circuit, nor the values.

SDA and SCL have two states:
* 0 = low = Ground
* HighImpedance with external pullup. Never driven actively high! (We can´t validate this)

Why the bit bang mode? Doesn´t your microcontroler have a I2C interface?

I´m no C specialist: Can you explain what this line means: "DAP1_Prty = DAP1_Prty ^ DAP1[1];"

Klaus
 

Signals are named SCL and SDA, but it's a SPI interface. Timing of read transaction looks correct at first sight, but I don't know how you are extracting the data field. As said, there must be something wrong because we have only 20 data bits, can't give the numbers printed in red.

Do you check parity, is it correct for the dubious readings?
 

STPM10 has a special SPI port and doesnt have I2C port so pull up resistor is not necessary. any of evaluation board of stpm10 have pull up resistor.
I always check parity and it is strange for me that parity is always correct.


Code C - [expand]
1
2
3
4
5
6
7
8
9
if((DAP1_Prty != 0xF0) || (DRP1_Prty != 0xF0) || (DSP1_Prty != 0xF0) || (DFP1_Prty != 0xF0) || (DEV1_Prty != 0xF0) || (DMV1_Prty != 0xF0) || 
       (CFL1_Prty != 0xF0) || (CFH1_Prty != 0xF0))
       {
            Parity_Status1 = 1;
       }
       else
       {
            Parity_Status1 = 0;
       }



I use the following code for unpacking DAP register:


Code C - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
Active1.old = Active1.new;
 
       Type0_Active_Energy1 = 0 ;
       DAP1[3] = DAP1[3] & 0x0F ;
       Type0_Active_Energy1 = DAP1[3];
       
       Type0_Active_Energy1 = Type0_Active_Energy1 << 8 ;
       Type0_Active_Energy1 = Type0_Active_Energy1 + DAP1[2] ;
 
       Type0_Active_Energy1 = Type0_Active_Energy1 << 8 ;
       Type0_Active_Energy1 = Type0_Active_Energy1 + DAP1[1] ;
 
       Active1.new = Type0_Active_Energy1;
       Active1.quant = Active1.new - Active1.old;
       Active1.frac = Active1.frac + Active1.quant;



please attention to the following number:
72766
73339
73659
72952
73013
73075
73138
73711
73517
73324
73388
73451
2039592
2039654
2039716
2039777
73760
73822
73885
74201

for this power, Reactive1.quant = Reactive1.new - Reactive1.old is about 60 to 63. In abnormal value, for example 2039592 that in hex is 1F1F28, if i dont consider 7 high significant bits, the value convert to 11F28 (dec: 73512) that if minus from previous (73451), the result is 61! This is true for all abnormal value.
Thank you for your time.
 
Last edited by a moderator:

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top