To LUGNET HomepageTo LUGNET News HomepageTo LUGNET Guide Homepage
 Help on Searching
 
Post new message to lugnet.robotics.rcx.pbforthOpen lugnet.robotics.rcx.pbforth in your NNTP NewsreaderTo LUGNET News Traffic PageSign In (Members)
 Robotics / RCX / pbFORTH / 87
86  |  88
Subject: 
RE: Multitasker test script
Newsgroups: 
lugnet.robotics.rcx.pbforth
Date: 
Thu, 13 May 1999 02:43:07 GMT
Viewed: 
1501 times
  
John,

I've been looking at your ping routine and note the following...

Even if FF EMIT did not block, the wait makes things irrelevant. At 2400
baud, the FF is out the port within 4 msec. In fact, if EMIT did not block,
you could probably wait jsut a bit and then sample right away, or take two
quick samples, since they are 3 msec apart anyways.

You might try to simplify this a bit as well. One task could be grabbing
samples and doing the first order math on them, and then a background task could
do the heavier calculations.

: ping
\ Algorithm due to Mark R. David  markdavid@mediaone.net
  RawLight SENSOR_READ
  IF
    RawLight SENSOR_VALUE
    AvgAmbient @ 4 * + 5 /
    DUP AvgAmbient !
    [ DECIMAL ] 615 - 6 / 6 MAX                  ( DiffRaw )

    [ HEX ] FF EMIT       \ blocks unfortunatly - need SendMessage
    FlashDelay msWait
    RawLight LIGHT? SWAP    ( tr dr )
    OVER MinRaw @ <                              ( ThisRaw DiffRaw ThisRaw<MinRaw -- )
    IF
      OVER MinRaw !
      FALSE RisingMins !
      TRUE DescendingRaw !
      OVER    ( tr dr tr )
      DEFCON! ( tr dr )
    ELSE
      OVER LastRaw @ >                           ( ThisRaw DiffRaw ThisRaw>LastRaw -- )
      IF
        DescendingRaw @
        IF
          RisingMins @
          IF
            LastRaw @ DUP MinRaw !    ( tr dr lr )
            DEFCON! ( tr dr )
          ELSE
            TRUE RisingMins !
          THEN
        THEN
        FALSE DescendingRaw !
      ELSE
        TRUE DescendingRaw !
      THEN
    THEN                                         ( ThisRaw DiffRaw -- )
    DROP LastRaw !
    FlashRemain msWait
  THEN
;


Cheers,

Ralph Hempel - P.Eng

--------------------------------------------------------
Check out pbFORTH for LEGO Mindstorms at:
<http://www.bmts.com/~rhempel/lego/pbFORTH/default.html>
--------------------------------------------------------
Reply to:      rhempel at bmts dot com
------------------------------------------------------



Message has 1 Reply:
  Re: Multitasker test script
 
Perhaps I should not have stripped all the comments for speed :) \ The rationale for the delay above and the delay after the IR flash is \ that the message is 77 bits of 417 microseconds each, a total \ transmission time of 32 milliseconds, the (...) (26 years ago, 13-May-99, to lugnet.robotics.rcx.pbforth)

Message is in Reply To:
  Re: Multitasker test script
 
Here it is, it is working, but is waiting for IR_MODE_HI, STOP and a non-blocking EMIT. There is a light sensor on the centre connector pad. .dp displays proximity in the LCD as DEFCON.RawLight alternating with the average ambient raw light sensor (...) (26 years ago, 12-May-99, to lugnet.robotics.rcx.pbforth)

9 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