Simultaneous counting
[font=arial,helvetica]i need to count two separate inputs at the same time using a bs2. I cannot
count one input then the other. Can anyone think of a way to do this. I keep
thinking that there is some way to do it in a for..next loop using button, or
toggle or something. ·if any one has any ideas please help.
Thanks[/font]
count one input then the other. Can anyone think of a way to do this. I keep
thinking that there is some way to do it in a for..next loop using button, or
toggle or something. ·if any one has any ideas please help.
Thanks[/font]
Comments
If the pulses are slow enough, you could do it with a couple of bit
variables:
i1edge var bit
i2edge var bit
i1count var word
i2count var word
i1count=0
i2count=0
i1edge=0
i2edge=0
loop:
if i1edge=1 or in1=0 then no1
' rising edge
i1edge=1
i1count=i1count+1
no1:
if in1=1 then no1a
i1edge=0
no1a:
if i2edge=1 or in2=0 then no2
i2edge=1
i2count=i2count+1
no2:
if in2=1 then no2a
i2edge=0
no2a:
' count value is ok here
goto loop
This is untested, but even if it works, it will be slow at detecting the
edges. If they are at all fast, you'll have problems catching them with
this.
Regards,
Al Williams
AWC
* Basic Stamp FAQ: http://www.al-williams.com/wd5gnr/stampfaq.htm
Original Message
From: moretraction@a... [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=1KfkAfeVu8q7-CoPKUCnEGuRSIJ2fgNlrxMVD8F2KpSc8NBSV3vDNptm1ofbYZ5xlEtNt0z61g9dLA]moretraction@a...[/url
Sent: Monday, February 12, 2001 8:42 PM
To: BASICSTAMPS@yahoogroups.com
Subject: [noparse][[/noparse]basicstamps] SIMULTANEOUS COUNTING
I NEED TO COUNT TWO SEPARATE INPUTS AT THE SAME TIME USING A BS2. I CANNOT
COUNT ONE INPUT THEN THE OTHER. CAN ANYONE THINK OF A WAY TO DO THIS. I KEEP
THINKING THAT THERE IS SOME WAY TO DO IT IN A FOR..NEXT LOOP USING BUTTON,
OR
TOGGLE OR SOMETHING. IF ANY ONE HAS ANY IDEAS PLEASE HELP.
THANKS