To LUGNET HomepageTo LUGNET News HomepageTo LUGNET Guide Homepage
 Help on Searching
 
Post new message to lugnet.robotics.rcx.nqcOpen lugnet.robotics.rcx.nqc in your NNTP NewsreaderTo LUGNET News Traffic PageSign In (Members)
 Robotics / RCX / NQC / 1867
1866  |  1868
Subject: 
Re: IR-based proximity measurement
Newsgroups: 
lugnet.robotics.rcx.nqc
Date: 
Sun, 11 Jun 2006 18:31:49 GMT
Viewed: 
10360 times
  
Brian, thanks for your advice. it has told me what is happening physically.

i build a one shot measurement program to answer your questions.

here is the measurement result:

Distance to wall: 26 cm (at night)
7740 7696 7666 7641 7639 7613 7613 7593 7585  Battery millivolt
24   24   24   23   23   23   23   23  23    Ambient baseline
58   53   57   56   58   57   51   51  49    1 Start of burst
52   50   49   53   52   55   57   57  54    2
57   50   49   49   57   54   23   52  49    3
50   51   55   26   26   29   24   50  26    4
52   57   25   55   28   55   52   52  53    5
24   50   49   54   52   49   57   56  49    6 End of burst
24   24   23   23   23   23   23   23  23
24   24   23   23   23   23   23   23  23
24   24   24   23   23   23   23   23  23
24   24   24   23   23   23   23   23  23

24   24   24   23   23   23   23   23  23    Ambient baseline, night
58   57   57   56   58   57   57   57   54    Maximum bright


Distance to wall: 52 cm (at day)
9000 7838 7810 7782 7771 7754 7750 7704 7725  Battery millivolt
37   37   37   37   37   37   37   37  37    Ambient baseline
47   48   48   47   45   45   46   47  45    1 Start of burst
37   45   38   46   45   47   38   37  37    2
47   45   45   45   47   46   44   44  46    3
47   45   45   44   41   44   46   47  46    4
38   47   45   37   44   37   44   38  46    5
47   37   45   44   47   46   46   44  46    6 End of burst
37   37   37   37   37   37   37   37  37
37   37   37   37   37   37   37   37  37
38   37   37   37   37   37   37   37  37
37   37   37   37   37   37   37   37  37

37   37   37   37   37   37   37   37  37    Ambient baseline, day
47   48   48   47   47   47   46   47   46    Maximum bright

As you see, after measuring the ambient baseline, we only need six samples to
hunt the burst bright maximum.

Could imagine an algoritm as an IR-based proximity measurement device
taking only six samples during IR burst.

--------------------------------------------------------------------
And here is the code:
--------------------------------------------------------------------
/*
mea1pulse.nqc /cr 2006 June 9 /lm 2006 June 11 / Ralph Toepper

proximity sensor development / measure one pulse

derivied from SerialPing.nqc by Matt Jones, Sept 2005, regarding advice from
Brian Davis June 2006

note: start and stopbit are vice versa, giving serial data electronic
opportunity to syncronise.

estimation of burst duration: assuming 1 startbit and 1 stopbit (didnt find the
real settings, but only 2 stopbits are possible otherwise) we get 10 bit per
byte:

t=1/f      1/2400Hz=416.67us (microseconds) per bit

416.67us per bit * 10 bit per byte * 16 bytes = 66.67 ms burst duration

furthermore i guess, burst brightness depends on battery power. because any
regulation unit would burn and thus waste power. but i dont know what is
implemented in the RCX.
*/

int eyeoff; // passive light sensor reading
int eyeon; // active light sensor reading
int cnt;

task main()
{

CreateDatalog(12);

// Set up sensors & IR Tx
SetSensorType(SENSOR_1, SENSOR_TYPE_LIGHT);
SetSensorMode(SENSOR_1, SENSOR_MODE_PERCENT);

SetTxPower(TX_POWER_HI);
SetSerialComm( (SERIAL_COMM_DEFAULT) ); // 2400 Baud, 50% duty cycle
SetSerialPacket(SERIAL_PACKET_DEFAULT); // plain data bytes

// initialize the 16 byte serial data buffer with all 0's. Sending all 16 bytes
in a row should give a long IR blast
SetSerialData(0, 0x00);  // compiler (version 2.2 r1) says, buffer index
argument must be a constant
SetSerialData(1, 0x00);
SetSerialData(2, 0x00);
SetSerialData(3, 0x00);
SetSerialData(4, 0x00);
SetSerialData(5, 0x00);
SetSerialData(6, 0x00);
SetSerialData(7, 0x00);
SetSerialData(8, 0x00);
SetSerialData(9, 0x00);
SetSerialData(10, 0x00);
SetSerialData(11, 0x00);
SetSerialData(12, 0x00);
SetSerialData(13, 0x00);
SetSerialData(14, 0x00);
SetSerialData(15, 0x00);

AddToDatalog(  BatteryLevel()  );
eyeoff = SENSOR_1;
AddToDatalog(  eyeoff  );

cnt = 0;
SendSerial(0,15);
while( cnt<10 )
{
eyeon = SENSOR_1;
AddToDatalog(  eyeon  );
cnt = cnt + 1;
        }
}



Message has 1 Reply:
  Re: IR-based proximity measurement
 
(...) You're welcome - it's a fun problem. At least partially because it's one of the few times I've had to worry about the speed of bytecode execution under the standard firmware (see below). (...) Given what you are transmitting and how you are (...) (18 years ago, 11-Jun-06, to lugnet.robotics.rcx.nqc)

Message is in Reply To:
  Re: IR-based proximity measurement
 
(...) Well, there were a couple of typos, but only one I found that was critical. If you are using a "max-picking LIDAR" method, you do *not* want to divide by the number of samples. The variable "eyeon" in your code should end up with the brightest (...) (18 years ago, 9-Jun-06, to lugnet.robotics.rcx.nqc)

13 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