BasicStampClockInput

Thread Starter

mpuvdd

Joined Feb 11, 2007
50
Hello all,
I've looked extensively hard into figuring out how to make a BS2 sense a clock signal (1 to 0 or 0 to 1)on one of its I/O pins rather than the pin's individual logic state. I can't figure it out, so could anyone help?
Thanks a lot,
mpuvdd
 

Dave

Joined Nov 17, 2003
6,969
Is this the same question as the one asked here.

If so please refrain from posting multiple threads asking the same question for reasons of manageability. If need be, give your existing thread a bump.

If this is a repeat question please let me know and I can lock one of them (tell me which one to lock).

Thanks.

Dave
 

Thread Starter

mpuvdd

Joined Feb 11, 2007
50
Well, I know how to monitor a I/O pin's state (IN# or by using VAR), I just don't know what kind of code to write in order to make the stamp add 1 to a VAR (Value) when the I/O pins changes states.
 

BladeSabre

Joined Aug 11, 2005
105
(I've never used Basic Stamp so I'm kind of guessing here.)

It sounds like you're trying to detect rising and falling edge on a pin. On some microcontrollers, you can set up an interrupt that automatically calls your function when the level on the pin changes - I have no idea whether this is possible on the Basic Stamp.

To detect if a pin has changed using a simple polling-loop, you can keep a record of its level, and each time round, compare its current level with what it was last time.

psuedocode:
Rich (BB code):
begin loop
    if pinvalue != previous then dostuff
    previous = pinvalue
    dootherstuff
end loop
EDIT: Just thinking that might be a problem if the input changes at the wrong moment.

Rich (BB code):
previous = pinvalue
begin loop
    temp = pinvalue
    if temp != previous then dostuff
    previous = temp
    dootherstuff
end loop
However you're doing it, even with interrupts, note that if two changes occur too close together you're going to miss something.
 
Thread starter Similar threads Forum Replies Date
mpuvdd General Electronics Chat 0
Similar threads
BasicStampClockInput
Top