|
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
|
|
|
|