Interesting... I wonder why this wasn't as well documented as most other pin features. Would the "high" value be 5V? I mean, would the top end of the analogue value be at 5V? I imagine I could use the color sensor block to read this, right? Sorry, OT.gloomyandy wrote:Pin 6 as well as being a digital output pin can also be used as an analogue input pin (but this is read by the NXT Arm chip rather than the ATmega which reads pin 1). This pin can be sampled by the firmware at a much higher sample rate, and is currently used to read data from the Lego color sensor
Using the ultrasonic sensor with other controllers
Re: Using the ultrasonic sensor with other controllers
One King to rule them all, One King to find them,
One King to bring them all and in the darkness bind them
On Earth where Shadows lie.
One King to bring them all and in the darkness bind them
On Earth where Shadows lie.
-
- Posts: 323
- Joined: 29 Sep 2010, 05:03
Re: Using the ultrasonic sensor with other controllers
I'm pretty sure that it is 3V max reading not 5V certainly the ADVREF line on the AT91 seems to be connected to 3V on the Lego schematic... I don't think you will be able to access readings from this line via the color block. The color sensor code in the firmware does a whole bunch of stuff to talk to the sensor and I suspect that will fail if you don't have a color sensor connected. I'm not sure if there is any other way to access these lines via the standard (or enhanced) firmware. I know that you can access them using leJOS...
Andy
Andy
Re: Using the ultrasonic sensor with other controllers
Thanks gloomyandy! Nice to know that. Now, back on topic .
-EDIT- Oh and I forgot to mention that I found some code in my Picaxe PE folder* that was for the Lego US sensor. Supposedly the Picaxe can't work at the low speed of 9600 baud but I did find code on the Picaxe forum for lower speed I2C. Anyways, just though I'd post it here.
Found in "C:\Program Files\Programming Editor\samples". Directory may change on other computers.
*PE version 5.3.1
-EDIT- Oh and I forgot to mention that I found some code in my Picaxe PE folder* that was for the Lego US sensor. Supposedly the Picaxe can't work at the low speed of 9600 baud but I did find code on the Picaxe forum for lower speed I2C. Anyways, just though I'd post it here.
Code: Select all
#picaxe 20x2
#no_table
' PICAXE-20X2 sample program for Lego NXT Sensors
' Lego Ultrasonic Sensor (part 9846)
' NOT FUNCTIONING!
' Note this sensor is much more difficult than the other
' Lego sensors to use. Consider using the SRF005 instead!
' You must provide both 9V and 5V supplies (4.5V will not work).
' Also i2c needs to be slower than PICAXE can actually do, just 9600 baud
' The below should work, but doesn't as the sensor can't keep up.
' We give up,the SRF005 is cheaper anyway!
symbol distance = b0 'distance in cm
' Wires on NXT jack plug.
' Wire colours may vary. Pin 1 is always end nearest latch.
' 1 White +9V
' 2 Black 0V
' 3 Red 0V
' 4 Green +5V
' 5 Yellow SCL
' 6 Blue SDA
' Do not use i2c pullup resistor - already provided within sensor.
init:
'Slave address is $02
hi2csetup i2cmaster, $02, 127, i2cbyte
hi2cout $41,($02) 'continuous mode
pause 100
main:
; read values
hi2cin $42, (distance)
; debug display
debug
; wait 1 second then loop
pause 1000
goto main
*PE version 5.3.1
Last edited by nxtreme on 22 Nov 2010, 21:43, edited 1 time in total.
One King to rule them all, One King to find them,
One King to bring them all and in the darkness bind them
On Earth where Shadows lie.
One King to bring them all and in the darkness bind them
On Earth where Shadows lie.
Re: Using the ultrasonic sensor with other controllers
mattallen37 wrote:Also, you noted that you used 2k2 pullups. Why such low values? The NXT uses 82k, and unless you are going into insane speeds, 10k should be the lowest value you will ever need (for non NXT stuff). If you really did mess up (or "burn out") the sensor, it is likely because the pullups are way too "strong".
Presumably that means that the pullup resistors can't be the cause of the problem?nxtreme wrote:Code: Select all
' Do not use i2c pullup resistor - already provided within sensor.
Re: Using the ultrasonic sensor with other controllers
Or, they maybe they are... you said you used 2.2K pull-ups. What if you try it without them? Since the US sensor already has some built in you should be fine. 82K might not be the best in noisy situations but just so long as your cables aren't over 50 cm long, it should work. With the external and internal pull-ups both installed it'd be the same as having a ~2.1K resistor pull-up, probably too much for the NXT to handle.
Last edited by nxtreme on 22 Nov 2010, 21:39, edited 1 time in total.
One King to rule them all, One King to find them,
One King to bring them all and in the darkness bind them
On Earth where Shadows lie.
One King to bring them all and in the darkness bind them
On Earth where Shadows lie.
-
- Posts: 1818
- Joined: 02 Oct 2010, 02:19
- Location: Michigan USA
- Contact:
Re: Using the ultrasonic sensor with other controllers
Actually, it means that it is all the more likely to be the cause of your sensor fate, because the resistors were in parallel, so the values combined would be less than 2.2k, which is yet even lower.nxtboy wrote:Presumably that means that the pullup resistors can't be the cause of the problem?
Matt
http://mattallen37.wordpress.com/
I'm all for gun control... that's why I use both hands when shooting
http://mattallen37.wordpress.com/
I'm all for gun control... that's why I use both hands when shooting
Re: Using the ultrasonic sensor with other controllers
Oh yeah, good point. Not paying attention at all there. Do all the NXT sensors have internal pullup resistors?mattallen37 wrote:Actually, it means that it is all the more likely to be the cause of your sensor fate, because the resistors were in parallel, so the values combined would be less than 2.2k, which is yet even lower.nxtboy wrote:Presumably that means that the pullup resistors can't be the cause of the problem?
Re: Using the ultrasonic sensor with other controllers
If they are I2C sensors, yes. Otherwise there's not much point... If you download the Hardware Developer Kit from the Mindstorms website you can find schematics of the four sensors that come with the 1.0 NXT kit. I'm sure it'd help you design your circuit better.nxtboy wrote:Oh yeah, good point. Not paying attention at all there. Do all the NXT sensors have internal pullup resistors?
One King to rule them all, One King to find them,
One King to bring them all and in the darkness bind them
On Earth where Shadows lie.
One King to bring them all and in the darkness bind them
On Earth where Shadows lie.
Re: Using the ultrasonic sensor with other controllers
yes, all NXT compatible IIC sensors have built-in pullups, but IIRC there are some 3rd party sensors for NXT which's pullups you can disable/shut out (Mindsensors? Hitechnic?).
With original Lego sensors you can't do this.
That's also one of the reasons why you usually can't concatenate 2 or more IIC sensors to 1 NXT port (usually up to 127 IIC devices can be concatenated to each port, but you may have only 1 pullup on SDA and 1 at SCL line at all)
With original Lego sensors you can't do this.
That's also one of the reasons why you usually can't concatenate 2 or more IIC sensors to 1 NXT port (usually up to 127 IIC devices can be concatenated to each port, but you may have only 1 pullup on SDA and 1 at SCL line at all)
-
- Posts: 1818
- Joined: 02 Oct 2010, 02:19
- Location: Michigan USA
- Contact:
Re: Using the ultrasonic sensor with other controllers
I don't think there are any that you an disable the pullups, as I believe that all of them have "hard wired" resistors. You are probably thinking of the PICAXE system, as I think you can enable/disable the pullups in those Ucontrollers.
Actually, I think nxtreme said he has used pullups that are only 10k with the NXT, and it worked fine. That means, that if mindsensors... used 82k's, then you should be able to use up to about 8 on one port without pullup problems.
Actually, I think nxtreme said he has used pullups that are only 10k with the NXT, and it worked fine. That means, that if mindsensors... used 82k's, then you should be able to use up to about 8 on one port without pullup problems.
Matt
http://mattallen37.wordpress.com/
I'm all for gun control... that's why I use both hands when shooting
http://mattallen37.wordpress.com/
I'm all for gun control... that's why I use both hands when shooting
Who is online
Users browsing this forum: Bing [Bot] and 2 guests