Robust edge/flank detection - HELP!!

Hey guys,
i have an measurement and read in three rect. signals.
I need to detect the pos. and neg. edges/flanks of the three signals.
Sometimes I have the problem that my code doesnt detect all flanks/edges and i dont know why.
In the attachment u find a pictures with with all three signals and the detected signals but not all are right.
I counted them by hand:
left Signal -> 28 pos. and 27 neg.
middle Signal -> 27 pos and 27 neg (this signal is ok)
right signal -> 27 pos and 27 neg
So if u compare it only the middle one is correct.
My Code for that detection is:
posFlankHall_1 = find(diff(V_Hall_1)>1.6)+1;
negFlankHall_1 = find(diff(V_Hall_1)<-1)+1;
posFlankHall_1OrigLength = length(posFlankHall_1);
negFlankHall_1OrigLength = length(negFlankHall_1);
posFlankHall_2 = find(diff(V_Hall_2)>1.6)+1;
negFlankHall_2 = find(diff(V_Hall_2)<-1)+1;
posFlankHall_2OrigLength = length(posFlankHall_2);
negFlankHall_2OrigLength = length(negFlankHall_2);
posFlankHall_3 = find(diff(V_Hall_3)>1.6)+1;
negFlankHall_3 = find(diff(V_Hall_3)<-1)+1;
posFlankHall_3OrigLength = length(posFlankHall_3);
negFlankHall_3OrigLength = length(negFlankHall_3);
I have three question to that:
1) Is there maby a easier and more robust way to detect the flanks/edges?
2) How can I automatically find out the values (like in this case 1.6 and -1) so i can use it on every signal i read in
3) If there is no easier way is there a way to improve this one?
Thank you very much in advance.

Réponses (1)

Star Strider
Star Strider le 27 Jan 2019

0 votes

See if the midcross (link) function will do what you want.
I would have suggested this earlier, however even though it has been part of the Signal Processing Toolbox since R2012a, I just now discovered it.

2 commentaires

youjarr
youjarr le 28 Jan 2019
Hey Star Strider,
i cannot use this command.
i get this error:
Error using midcross (line 65)
Expected X to be one of these types:
double
Instead its type was single.
That is not mentioned in the documentation.
Try this:
C = midcross(double(X))
If you pass any other arguments to it, double() them as well.
Also, note the related functions at the end of that documentation page.

Connectez-vous pour commenter.

Catégories

En savoir plus sur MATLAB dans Centre d'aide et File Exchange

Produits

Version

R2018b

Question posée :

le 26 Jan 2019

Commenté :

le 28 Jan 2019

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by