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?
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.
-Joe