Author Topic: Histeresis  (Read 2534 times)


« on: September 23, 2008, 11:19:32 PM »
Im making a project and find a problem.
Im ussing a PIC16f870. Im using Flowcode for simulation and for the programing.
The problem is that im using two (A and B) analog input, but i need some kind of histeresis.
What i mean is that say A an analog reference, so:
If B is a little higher or a little lower from A, nothing happens. If dont, then process ohter actions.

I tried to resolve it by:
read A : Ref
Sum : Ref + (1,2,3,4,..., n (i tried all numbers up to 255 and nothing happend))
Rest . Ref - (1,2,3,4...n)
Read B

If  Rest < B < Sum dont do anithing.

But it doesnt seems to work. Is there any other way to achieve this?
--Is there any body out there??--


Re: Histeresis
« Reply #1 on: September 24, 2008, 07:34:59 PM »
I don't really know much about programming, but I would think you could subtract B from A and use an If or While loop on the absolute value kinda like:

C = abs(B - A);
While C <= [some number]
     do stuff

It could also be causing you problems because signals will not always be in phase with each other so you would probably have to do some FFT first.