To LUGNET HomepageTo LUGNET News HomepageTo LUGNET Guide Homepage
 Help on Searching
 
Post new message to lugnet.roboticsOpen lugnet.robotics in your NNTP NewsreaderTo LUGNET News Traffic PageSign In (Members)
 Robotics / 20351
20350  |  20352
Subject: 
Re: Help with events
Newsgroups: 
lugnet.robotics
Date: 
Thu, 27 Feb 2003 23:48:23 GMT
Original-From: 
Steve Baker <sjbaker1@airmail.net%IHateSpam%>
Viewed: 
972 times
  
Camp0s wrote:
Hy to all,

i was just trying to do a robot which can help me and my friends in the lab
school. We are doing measures on a pendulum (if the word is right), the
teacher said that we have to do about 450 readings of the time which the
pendulum makes 20 go and back from right to left (you know what a mean). Now
it's a repetitive, precision and boring task. So a thought why not telling
my favourite Lego brick to do the job right for me ?

Yes - an excellent job for automation.

I put a light back to the pendulum and the brick with the light sensor in
front of it.

I setted and up Event to react when the pendulum cover the light beam and
the light sensor read a darker value.

SetSensor (SENSOR_2, SENSOR_LIGHT);
SetEvent (1,SENSOR_2,EVENT_TYPE_LOW);
SetLowerLimit(1,50);
SetUpperLimit(1,80);

This is what a first written in BricxCC, BUT, i'm getting a:

"Undefined variable EVENT_TYPE_LOW"

What does this mean ?

I thought it was 'EVENT_TYPE_PRESSED' - but then I didn't think it worked
with light sensors.  Did you tell the compiler to make the code for RCX 2?
I don't think there is event support in RCX 1.

And do you have any other suggestion on how to have better readings of the
pendulum oscillations ? Maybe not using events ?

I would have used two tasks.  Have one detect the pendulum:

int ticked ;

task Pendulum ()
{
  while ( 1 )
  {
    while ( SENSOR_2 > whatever )
    {
      /* DO NOTHING */
    }

    ticked = TRUE ;

    while ( SENSOR_2 < whatever_plus_a_bit )
    {
      /* DO NOTHING */
    }
  }

Have the other tell the time whenever the pendulum task sets 'ticked'
to TRUE:

task Timer ()
{
   int time = 0 ;
   ticked = FALSE ;

   start Pendulum ;

   while ( 1 )
   {
     wait ( 1 ) ;
     time++ ;
     if ( ticked )
     {
       ...do something with the time...
       ticked = FALSE ;
       time = 0 ;
     }
   }
}

Set 'whatever' and 'whatever_plus_a_bit' appropriately for the light
levels you are seeing (or better still, make it auto-calibrate).
---------------------------- Steve Baker -------------------------
HomeEmail: <sjbaker1@airmail.net>    WorkEmail: <sjbaker@link.com>
HomePage : http://www.sjbaker.org
Projects : http://plib.sf.net    http://tuxaqfh.sf.net
            http://tuxkart.sf.net http://prettypoly.sf.net
-----BEGIN GEEK CODE BLOCK-----
GCS d-- s:+ a+ C++++$ UL+++$ P--- L++++$ E--- W+++ N o+ K? w--- !O M- V-- PS++ PE- Y-- PGP-- t+ 5 X R+++ tv b++ DI++ D G+ e++ h--(-) r+++ y++++
-----END GEEK CODE BLOCK-----



Message is in Reply To:
  Help with events
 
Hy to all, i was just trying to do a robot which can help me and my friends in the lab school. We are doing measures on a pendulum (if the word is right), the teacher said that we have to do about 450 readings of the time which the pendulum makes 20 (...) (22 years ago, 27-Feb-03, to lugnet.robotics)

2 Messages in This Thread:

Entire Thread on One Page:
Nested:  All | Brief | Compact | Dots
Linear:  All | Brief | Compact
    
Active threads in Robotics

 
Verified and Trusted Team of Hackers
7 hours ago
Custom Search

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