Help making my first sensor

Discussion specific to the intelligent brick, sensors, motors, and more.
inxt-generation
Posts: 290
Joined: 03 Oct 2011, 00:06
Location: Gallifrey
Contact:

Help making my first sensor

Post by inxt-generation »

Hey guys, how's it going?

So, back from my "break" (aka Minecraft addiction :oops: ) and I'm making robots again. Gonna make a sensor for the NXT! Well, not really make a sensor. Use a generally available sensor board with the NXT. ;)

To the point, I don't have much of an idea of where to start. I'm great at programming, but my hardware knowledge doesn't go much past resistors, turning heavier loads on and off with transistors, and blinking LEDs. I've heard before about pullup resistors, what values do I need? What's the pinout of the NXT cable? How easy is it to use one of these with a breadboard? Would I be better off cutting a cable in half? I don't have the $15 for their adapter. :lol:

Oh, and this is the sensor I'm gonna use. I have it already, just needa figure out the connections, then get programming. http://www.pololu.com/catalog/product/1268

Of course, I'd just use the Dexter Industries sensor, but I got this on sale for like $30. I do have the HiTechnic gyro and accelerometer (though I didn't ask for them :| my rellies don't know much about this stuff) and in my experience, they are... not that good. So I want to use this.
A.K.A. NeXT-Generation.
"A kingdom of heaven for RobotC now has recursion!"
mattallen37
Posts: 1818
Joined: 02 Oct 2010, 02:19
Location: Michigan USA
Contact:

Re: Help making my first sensor

Post by mattallen37 »

First the pinout:

Pin 1 (white wire in the cable): Analog input, tied to sensor Vcc (4.3-4.7v) with a 10k pullup. Can also be pulled to 9v (battery voltage) and supply 13ma (pretty much only used for the NXT Ultrasonic sensor, and the RCX Light and Rotation sensors). You can connect a passive (resister) sensor between this pin and Gnd, and access the values by reading the RAW analog input. The 10k pullup acts as one half of a voltage divider between sensor Vcc and the ADC line, and the sensor acts as the resistor between the ADC line and Gnd. The higher the resistance of the sensor, the higher the voltage to the ADC. The ADC is 10-bit, so the value ranges from 0 to 1023.

Pin 2 (black wire) and pin 3 (red wire) are both Gnd, but I highly recommend you do not connect to pin 2 (black wire). If you connect pin 2 and 3 together, then you could burn out a motor driver (if you accidentally connect it to a motor port instead of a sensor port). If you only connect Gnd to pin 2, then if you connect it to a motor port, you run the risk of burning out the sensor. I only use pin 3 for Gnd.

Pin 4 (green wire): Sensor Vcc (about 4.3 - 4.7v). Sensor Vcc can source about 180ma max, but that is shared between all sensors, and all the motor encoders.

Pin 5 (yellow wire): DIGI0. Typically used as I2C SCL line, but also used as a GPIO (e.g. to control the LED of the light sensor). When using RS485 (exclusively available on sensor port 4), this is the RS485 "B" line.

Pin 6 (blue wire): DIGI1. Typically used as I2C SDA line, but also used as a GPIO. When using RS485 (exclusively available on sensor port 4), this is the RS485 "A" line.
Matt
http://mattallen37.wordpress.com/

I'm all for gun control... that's why I use both hands when shooting ;)
mattallen37
Posts: 1818
Joined: 02 Oct 2010, 02:19
Location: Michigan USA
Contact:

Re: Help making my first sensor

Post by mattallen37 »

A "Pullup" is a resistor that typically connects between a signal and a constant voltage source (such as sensor Vcc). It's a very generic term, and not specific to I2C or analog input lines.

The I2C bus (when idle) rides at the bus voltage (with the NXT, that's usually sensor Vcc), because of the pullups. When a device wants to talk on the I2C bus, it forces the line(s) low (to Gnd). When the device wants to send a high signal, it simply "lets go" of the line, and the pullup pulls the voltage up. I2C devices can never force a line high, only low, and that's why the pullups are necessary on an I2C bus. If you want to know about the specifics of the I2C bus (bit order etc.), I'll let you look that up (there are plenty of examples/explanations online).

With the NXT, the I2C pullups are recommended to be 82k. By standard I2C practice, this is extremely weak, but it is necessary for them to be this weak because of the NXT HW design (there are 4k7 resistors inline with the I2C lines of the NXT, between the CPU and the ports). I've had success using pullup from 10k to 470k (IIRC), but both of those are the very limits, and most of the time those won't work, so I suggest you go with the recommended 82k.

That Pololu board has 4k7 pullups on-board, so you're going to have to do some brain surgery with your soldering iron, and replace them with something like 82k. The alternative to that, would be to use an I2C bus repeater between the NXT and the board.

Instead of cutting an NXT cable, I suggest you use a breadboard breakout board and an NXT socket. mindsensors sells theirs for $3.25.
Matt
http://mattallen37.wordpress.com/

I'm all for gun control... that's why I use both hands when shooting ;)
mattallen37
Posts: 1818
Joined: 02 Oct 2010, 02:19
Location: Michigan USA
Contact:

Re: Help making my first sensor

Post by mattallen37 »

BTW, if you don't like the HiTechnic Gyro and Accelerometer, what makes you think you will like any other gyro or accel sensors?
Matt
http://mattallen37.wordpress.com/

I'm all for gun control... that's why I use both hands when shooting ;)
inxt-generation
Posts: 290
Joined: 03 Oct 2011, 00:06
Location: Gallifrey
Contact:

Re: Help making my first sensor

Post by inxt-generation »

Thanks for all that. I don't like them because I've seen people say, and in my experience, that they aren't the highest quality and don't perform that well. Maybe I'm wrong, but they're just not working for me.
A.K.A. NeXT-Generation.
"A kingdom of heaven for RobotC now has recursion!"
mattallen37
Posts: 1818
Joined: 02 Oct 2010, 02:19
Location: Michigan USA
Contact:

Re: Help making my first sensor

Post by mattallen37 »

The HT Gyro is very limited in range and precision (each 1023rd of the voltage range represents one DPS of rotation, and it clips at less than the full range), but still quite adequate for things like segways.

The HT Accelerometer is limited in range to +-2G, but it has 10-bit resolution for each of the 3 axes. Compared to the dIMU accel, it has 1/4 the range, but 4 times the resolution (IIRC). If you are speaking strictly of these two characteristics, then the "ideal" accelerometer depends on the application.

All HT products are of very high quality (as far as repeat-ability and reliability). However, some of them do suffer when it comes to versatility.
Matt
http://mattallen37.wordpress.com/

I'm all for gun control... that's why I use both hands when shooting ;)
circuitmage
Posts: 68
Joined: 14 Dec 2012, 17:56
Location: Austin, TX

Re: Help making my first sensor

Post by circuitmage »

Matt,

Does the wiring you indicated also apply to legacy (RCX) sensors?

According to philo's page he indicates using the first 2 wires;http://www.philohome.com/nxtcables/nxtcable.htm

Sometimes 2 grounds are not the same....:)
mattallen37
Posts: 1818
Joined: 02 Oct 2010, 02:19
Location: Michigan USA
Contact:

Re: Help making my first sensor

Post by mattallen37 »

In the NXT, the sensor port pins 2 and 3 are connected together, and to Gnd. The NXT Touch, Light, Sound, and Ultrasonic sensors all connect 2 and 3 together as well (which could be dangerous IMO). For the sensor ports, pins 2 and 3 are totally the same.

The motor ports use pins 1 and 2 for motor control pins, and only pin 3 as Gnd. If you have pins 2 and 3 tied together, and you accidentally connect the sensor to a motor port, you are tying one of the motor control lines to Gnd, which could burn out the motor driver. By avoiding tying pins 2 and 3 together, you remove this potential problem.

Connecting a sensor to pin 2 as Gnd should be fine as well as using pin 3, but I don't design my sensors to connect to both 2 and 3. As far as the NXT is concerned, it should be perfectly safe to connect a sensor to pins 1 and 2 (such as an RCX sensor).
Matt
http://mattallen37.wordpress.com/

I'm all for gun control... that's why I use both hands when shooting ;)
aswin0
Posts: 201
Joined: 29 Sep 2010, 06:58

Re: Help making my first sensor

Post by aswin0 »

The NXT requirement regarding pull ups is a pain. I couldn't get my Custom IMU to work until I disabled the inline resistors in the NXT. See this thread.
Disabling the inline resistor is by far the simplest solution to the pull up problem. But it is also the most risky solution. So I do not advise this solution.

Good luck. Maybe in the near future you can be a proud member of the CSBC, but you need to publish a proof of a working sensor for this :-)
My blog: nxttime.wordpress.com
inxt-generation
Posts: 290
Joined: 03 Oct 2011, 00:06
Location: Gallifrey
Contact:

Re: Help making my first sensor

Post by inxt-generation »

mattallen37 wrote:...That Pololu board has 4k7 pullups on-board, so you're going to have to do some brain surgery with your soldering iron, and replace them with something like 82k. The alternative to that, would be to use an I2C bus repeater between the NXT and the board...
Would these be suitable? http://www.ebay.com/itm/82-K-Resistor-S ... 5ae5ffb631
Also, I only need to replace the two in between SDA/SCL and VIN, correct?
aswin0 wrote:The NXT requirement regarding pull ups is a pain. I couldn't get my Custom IMU to work until I disabled the inline resistors in the NXT. See this thread.
Disabling the inline resistor is by far the simplest solution to the pull up problem. But it is also the most risky solution. So I do not advise this solution.

Good luck. Maybe in the near future you can be a proud member of the CSBC, but you need to publish a proof of a working sensor for this :-)
Well, I am definetely not comfortable with actually modifiying the NXT hardware. What is the CSBC? Custom Sensor Brewing Club?
A.K.A. NeXT-Generation.
"A kingdom of heaven for RobotC now has recursion!"
Post Reply

Who is online

Users browsing this forum: No registered users and 18 guests