0 to 1 detection
Archiver
Posts: 46,084
Hello group,
How can 0 to 1 or 1 to 0 transition of input signal be detected?
Thank You
Mohamed Refky
_________________________________________________________________________
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com.
How can 0 to 1 or 1 to 0 transition of input signal be detected?
Thank You
Mohamed Refky
_________________________________________________________________________
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com.
Comments
"Stamp Applications no. 8 (October ’95):
Rotary Encoders Help You Program
a Friendly Spin-and-Grin Interface
A Digital Dial plus Header-Post Jumpers, by Scott Edwards"
that I have modified.
I have not tested yet but it should work:
===================
old var bit
start:
old = inX 'old is the initial state
loop:
if inX = old then loop: 'if state do not change go looping
if inX then risetransition: 'if the last state is 1 then are
a 'rising edge
falltransition: 'if the last state is 0 then are falling
edge
...dosomething
goto start: 'repeat
risetransition:
...dosomething
goto start: 'repeat
=====================
ACJacques
Mohamed REFKY wrote:
>
> Hello group,
> How can 0 to 1 or 1 to 0 transition of input signal be detected?
>
> Thank You
> Mohamed Refky
> _________________________________________________________________________
> Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com.
Sid
if pin 1 = 0 then dosomething
Mohamed REFKY wrote:
>
> Hello group,
> How can 0 to 1 or 1 to 0 transition of input signal be detected?
>
> Thank You
> Mohamed Refky
> _________________________________________________________________________
> Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com.
>How can 0 to 1 or 1 to 0 transition of input signal be detected?
Hi Mohamed,
How about the bitwise XOR logic operator, ^ on the Stamp:
old var bit ' old state
new var bit ' new state
xxx var bit ' transition state
xxx = old ^ new & new ' xxx = 1 at 0-->1 transition
if xxx then goDo01thing
xxx = old ^ new & old ' xxx = 1 at 1-->0 transition
if xxx then goDo10thing
The operator (old ^ new) returns 1 if the two values are different,
or 0 if they are the same. Then the & (bitwise AND) selects
whichever "edge" you want to see.
hope that helps...
-- Tracy Allen
http://www.emesystems.com