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 / 233
232  |  234
Subject: 
Re: Blocking IR
Newsgroups: 
lugnet.robotics.rcx.legos
Date: 
Tue, 15 Jun 1999 22:43:03 GMT
Viewed: 
1346 times
  
Here is some code for IR detection, with the help from Kekoa. However it
doesn't work. I know the hardware is all working because if I run minicom
and then run this programme and point the RCX at the lego tower junk appears on
the screen. If I take my TV remote and point it at the light sensor I get a
reading of about 235-250. However if I point the light sensor at the RCX I
don't get a higher reading and the sensor stays at about the value of 225.


Here's the send IR send and light sensor part.

int send_ir_data(void)
{
int result;

char *buffer="xxxxxxxxxx";

while (1) {
     result = dir_write_nb(buffer,5);
  msleep(100);
   }
return 0;
}

int get_light_sensor(void)
{
ds_passive(&SENSOR_2);

while(1)
  {
   lcd_int(LIGHT_2);
   lcd_refresh();
   msleep(150);
  }
return 0;
}


I've added this function (Non blocking IR send) into direct-ir.c (with the
help from Kekoa)

size_t dir_write_nb(void* const buf,size_t len) {
        if(buf==NULL || len==0)                 // catch empty cases
                return 0;

        if(dir_tx_state != TX_OK)               // Still sending
                return 0;

        dir_tx_read=buf;                        // what to transmit
        dir_tx_end=buf+len;

        dir_tx_verify=buf;                      // checks and balances
        dir_tx_state=TX_ACTIVE;

        T1_CR  =0x09;                           // set up IR carrier
        T1_CSR =0x13;                           // for transmission
        T1_CORA=0x1a;

        S_SR&=~(SSR_TRANS_EMPTY | SSR_TRANS_END);       // clear flags
        S_CR|=SCR_TRANSMIT | SCR_TX_IRQ | SCR_TE_IRQ;   // enable

        return len;                     // successful xmit
}


Any ideas anyone?

Phil









In lugnet.robotics.rcx.legos, Kekoa Proudfoot writes:
Kekoa Proudfoot <kekoa@pixel.Stanford.EDU> wrote:

Do you mean dir_write?  This is a problem with LegOS only.  If you want
non-blocking writes, comment out (in version 0.1.7 at least):

    while(dir_tx_state==TX_ACTIVE)
        ;                               // FIXME: scheduler integration
    if(dir_tx_state==TX_OK)
        return len;                     // successful xmit
    return -1;                          // default is error

And replace with:

    return len;

I forgot to mention.  At the top of dir_write, you probably want to add:

   if (dir_tx_state == TX_ACTIVE)
       return -1;

Or something to that effect, so you don't transmit a second message while
a first is still transmitting, and so you have a way of querying the
whether or not the last transmission is still in flight (by sending a NULL
message).

Mind you, I haven't implemented any of this specifically, I am just drawing
parallels between what LegOS implements and what I have implemented in an
as-yet-unreleased future version of Librcx.

-Kekoa



Message has 1 Reply:
  Re: Blocking IR
 
Regarding your program. Try sending 0s, not xs, i.e.: char *buffer = "\0\0\0\0\0"; Zeros are coded with the IR on 91% of the time, while xs are coded with the IR on only 45% of the time, neglecting the modulation, which cuts that all down by half. (...) (25 years ago, 16-Jun-99, to lugnet.robotics.rcx.legos)

Message is in Reply To:
  Re: Blocking IR
 
(...) I forgot to mention. At the top of dir_write, you probably want to add: if (dir_tx_state == TX_ACTIVE) return -1; Or something to that effect, so you don't transmit a second message while a first is still transmitting, and so you have a way of (...) (25 years ago, 10-Jun-99, to lugnet.robotics.rcx.legos)

12 Messages in This Thread:


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

This Message and its Replies on One Page:
Nested:  All | Brief | Compact | Dots
Linear:  All | Brief | Compact
    

Custom Search

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