To LUGNET HomepageTo LUGNET News HomepageTo LUGNET Guide Homepage
 Help on Searching
 
Post new message to lugnet.robotics.rcx.legosOpen lugnet.robotics.rcx.legos in your NNTP NewsreaderTo LUGNET News Traffic PageSign In (Members)
 Robotics / RCX / legOS / 608
607  |  609
Subject: 
Re: touch sensors - two at a time ?
Newsgroups: 
lugnet.robotics.rcx.legos
Date: 
Wed, 29 Dec 1999 15:01:52 GMT
Viewed: 
1396 times
  
In lugnet.robotics.rcx.legos, John P. Looney writes:
However, I tried to do something like

if (SENSOR1 < 0xf000 && SENSOR3 < 0xf000) { both }
else if (SENSOR1 < 0xf000) { just one }
else if (SENSOR3 < 0xf000) { just one }
else { All is OK }

However, if I touch both sensors at the same time, it just accepts one, then
the other. I suppose it's a race condition of some sort. Any ideas how to sort
this out ?

It's not a race condition, strictly speaking.  It's more of a data sampling
error.  If you run that it a tight loop you will test the sensors hundreds or
thousands of times a second.  In order to see a simultaneous press you'd have
to hit them at the same time to within 1/nth of a second (so 1-10ms!).  You
need a loop which detects an initial press and then waits a certain amount of
time to see if the other button is also pressed.  Pseudocode would be:

wait forever for either sensor
(at this point you may want to stop your motors)
wait half a second (or some reasonable interval) for the OTHER sensor
if you see it { both }
else { just one }

Also, apart from www.legoworldshop.com, is there anywhere I can buy add on
bricks & RCXs ? They are pretty expensive there!!!

If you're using NQC you can get the Robotics Discovery Kit (?) which comes with
the blue Scout brick.  It's slightly less versatile than an RCX, but around
here Target has them on clearance for $90, which isn't a bad deal!

--Ben



Message is in Reply To:
  touch sensors - two at a time ?
 
I'm trying to build a sensor apparatus at the front of my bot, and it works, mostly. It's made up as a pair of touch sensors. The idea being that if one is activated, it turns around slightly, to avoid the sensor, but if both are activated, we (...) (25 years ago, 29-Dec-99, to lugnet.robotics.rcx.legos)

4 Messages in This Thread:



Entire Thread on One Page:
Nested:  All | Brief | Compact | Dots
Linear:  All | Brief | Compact
    

Custom Search

©2005 LUGNET. All rights reserved. - hosted by steinbruch.info GbR