help correction programme

Hello Evry Body
i'm asking for help please :)
i'm working in an project, and my programm does not work yet .
my issue is to do some traitment to the signals i have, more clearly i have a periodic square signal , and i have to take out the standard deviation, the mean, the max and mean of every square( in the attatchment a pic thas explains all) without passing through null values.
my methode to do that , is to make a a differential of my signal , and after that i can identify the rising edge and the falling edge, and finaly identifying the square by placing cursors A,B and making the statistics.
program code

#pragma rtGlobals=1 // Use modern global access method.

Macro Ttmt()
statistiques()
END


Proc statistiques()
variable/G XL1,XL2
variable/G ii=0



// debut de boucle sur le nombre de passage (cordons)
do

FindLevel/EDGE=1/R=(XL1,XL2) LL_DIF,2 // first rising edge

XL2=XL1+13800 //

FindLevel/EDGE=2/R=(XL1,XL2) LL_DIF,-2 // first filling edge
XL2=V_LevelX


// take out statistic data LL
WaveStats/Q/R=(XL1,XL2) LL
LL_rms[ii]=V_rms
LL_max[ii]=V_max
LL_min[ii]=V_min
LL_sdev[ii]=V_sdev

ii=ii+1
while (ii<50) // as long as expression is TRUE // taken into account all the signal

End

Thank you for your help
First, I recommend you to use the "preview" button to preview the post when writing an entry in the forum. Use this button and read your post again carefully to spot errors. Ambiguous text or function code only makes it harder to understand the problem. Also, if you find something after you have posted your entry you can use the "Edit" button to correct something.

Now, generally it would be better to write "functions" instead of macros. You are not writing what exactly does not work, so I take some guesses. There seem to be some issues with the assignment of "XL1" and "XL2". Are you using the output of the first Findlevel function somewhere? Also, there is no initialization or update of the variable "XL1". Do you use some other function for that? You might want to check the values of "XL1" and "XL2" during the run using the debugger to make sure it does everything as intended. Hope that helps a bit.
souhail wrote:
Hello Evry Body
i'm asking for help please :)
i'm working in an project, and my programm does not work yet .
my issue is to do some traitment to the signals i have, more clearly i have a periodic square signal , and i have to take out the standard deviation, the mean, the max and mean of every square( in the attatchment a pic thas explains all) without passing through null values.
my methode to do that , is to make a a differential of my signal , and after that i can identify the rising edge and the falling edge, and finaly identifying the square by placing cursors A,B and making the statistics.
program code
#pragma rtGlobals=1     // Use modern global access method.

Macro Ttmt()
    statistiques()
END


Proc statistiques()
    variable/G XL1,XL2 
    variable/G ii=0
   
       
   
// debut de boucle sur le nombre de passage (cordons)
    do

    FindLevel/EDGE=1/R=(XL1,XL2) LL_DIF,2   // first rising edge
   
    XL2=XL1+13800   //
   
    FindLevel/EDGE=2/R=(XL1,XL2) LL_DIF,-2  // first filling edge
    XL2=V_LevelX

       
// take out statistic data LL  
    WaveStats/Q/R=(XL1,XL2) LL
    LL_rms[ii]=V_rms   
    LL_max[ii]=V_max
    LL_min[ii]=V_min
    LL_sdev[ii]=V_sdev
   
    ii=ii+1
    while (ii<50)               // as long as expression is TRUE    // taken into account all the signal
   
End        

Thank you for your help