Subject:
|
Re: Ultrasonic sensor interactions
|
Newsgroups:
|
lugnet.robotics
|
Date:
|
Mon, 22 May 2006 21:50:26 GMT
|
Viewed:
|
3363 times
|
| |
| |
In lugnet.robotics, Philippe Hurbain wrote:
> > > At low level sample rate can be changed - and even a single
> > > shot mode is available - but presently NXT-G doesn't give
> > > access to these features
> >
> > Have you been able to verify this? I know there are FW commands that claim to
> > do this, but I've not seen it provably done as yet. And would *love* to hear
> > it's possible.
>
> Yes, that's theoretical, I have yet to do detailed testing. Perhaps John Barnes
> already did that?
I can confirm that the 0x2, 0x41, 0x0 "off" command does, indeed, turn off the
clicking sound that you can hear coming from the US sensor.
I can also confirm that the 0x2, 0x40, 0xNN "set measurement interval" command
does set the measurement interval to the specified value. Setting it to 0xff
makes the clicking slow to about once every 2.5 seconds.
dseg segment
;------- definitions -------
TCommLSWrite struct
Result sbyte
Port byte
Buffer byte[]
ReturnLen byte
TCommLSWrite ends
;------- declarations -------
thePort byte 0
lswArgs TCommLSWrite
bufUSInterval byte[] 0x2, 0x40, 0xff // set interval to max value (255)
dseg ends
; -------------- program code --------------
thread main
// configure the sensor type
setin IN_TYPE_LOWSPEED_9V, thePort, Type
setin IN_MODE_RAW, thePort, InputMode
// set the UltraSonic sensor measurement interval
mov lswArgs.Port, thePort
mov lswArgs.Buffer, bufUSInterval
set lswArgs.ReturnLen, 0
syscall CommLSWrite, lswArgs
exit
endt
(that's another 168 byte executable)
I can also confirm that setting the one-shot command triggers a single burst of
measurement each time the command is sent.
; -------------- variable declarations --------------
dseg segment
;------- definitions -------
TCommLSWrite struct
Result sbyte
Port byte
Buffer byte[]
ReturnLen byte
TCommLSWrite ends
;------- declarations -------
thePort byte 0
lswArgs TCommLSWrite
bufUS1Shot byte[] 0x2, 0x41, 0x1 // one-shot mode
w15ra sbyte -1
dseg ends
; -------------- program code --------------
thread main
// configure the sensor type
setin IN_TYPE_LOWSPEED_9V, thePort, Type
setin IN_MODE_RAW, thePort, InputMode
Forever:
// do a 1-shot
mov lswArgs.Port, thePort
mov lswArgs.Buffer, bufUS1Shot
set lswArgs.ReturnLen, 0
syscall CommLSWrite, lswArgs
subcall wait1500, w15ra
jmp Forever
exit
endt
thread wait1500
dseg segment
now dword
then dword
dseg ends
gettick now
add then, now, 1500
waiting:
gettick now
brcmp LT, waiting, now, then
subret w15ra
endt
That's a 226 byte executable.
I would predict that the event capture mode (0x2, 0x41, 0x3) would work as
advertised as well and that when multiple sensors are around it would adjust the
measurement interval to avoid conflict. How well that works in practice will
require some testing. Unfortunately, NXT-G is hard-coded to use continuous
measurement mode (0x2, 0x41, 0x2) so running one of these tiny programs to
configure a different mode would be useless because the configuration of the
sensor will be immediately overwritten by the first NXT-G program that uses the
US sensor.
John Hansen
|
|
Message has 1 Reply: | | Re: Ultrasonic sensor interactions
|
| Hello John, (...) I have played with this command, it seems that only the low nibble of paramater is useful. The interval range goes from 12.5ms for 0 to 3s for 0xf. Interval seems to be roughly proportional to the square of the parameter. I have (...) (19 years ago, 24-May-06, to lugnet.robotics)
|
Message is in Reply To:
| | Re: Ultrasonic sensor interactions
|
| (...) Sorry Brian, you are right! my ageing ear was not able to get the much weaker "ping" at first. My interpretation (to be confimed) is that the US sensor goes on working even if not configured, but some sensor modes don't provide the 9V supply (...) (19 years ago, 22-May-06, to lugnet.robotics)
|
27 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
|
|
|
|