Re: Ultrasonic sensor interactions
"John Hansen" <[email protected]> Mon, 22 May 2006 21:31:17 GMT
| Newsgroups | gmane.comp.hardware.lego.robotics |
|---|---|
| Organization | None |
| Message-ID | <[email protected]> |
In lugnet.robotics, Philippe Hurbain wrote:
> Hello Brian,
>
>> Specificly, I can not find a way to turn off the US sensor from the
>> LEGO-provided SW environment. There may very well be some functionality at a
>> lower level I don't have access to (at the moment), or LEGO themselves may do
>> something about this (after all, for FLL it will be an issue).
>
> That's easy to do in NBC
; us_off.nbc
; -------------- variable declarations --------------
dseg segment
;------- definitions -------
TCommLSWrite struct
Result sbyte
Port byte
Buffer byte[]
ReturnLen byte
TCommLSWrite ends
;------- declarations -------
thePort byte 0 // port 1
bufLSOff byte[] 0x2, 0x41, 0x0 // this sequence turns off the US sensor
lswArgs TCommLSWrite
dseg ends
; -------------- program code --------------
thread main
// configure the sensor type
setin IN_TYPE_LOWSPEED_9V, thePort, Type
setin IN_MODE_RAW, thePort, InputMode
// turn off the UltraSonic sensor
mov lswArgs.Port, thePort
mov lswArgs.Buffer, bufLSOff
set lswArgs.ReturnLen, 0
syscall CommLSWrite, lswArgs
exit
endt
Every time you turn on the NXT the Ultrasonic sensor is turned back on.
Executing this little 168 byte program turns it off.
You can also use one-shot mode (0x2, 0x41, 0x1) which will store 8 different
distances into measurement bytes 0-7. In this mode the measurements are taken
when the command is received and then the pinging is turned back off again.
There is also the event capture mode (0x2, 0x41, 0x3) where the US sensor
measures whether other US sensors are in the area and using that measurement it
tries to calculate when to make its own measurement so it can avoid conflict
with the other US sensors. I have no idea whether that works or not.
This functionality is not currently available in NXT-G.
John Hansen