I'd Rather Be Building Robots

July 27, 2008

IR Distance Gauging with the MAX127

Filed under: Experiments, Sensors — Xander @ 21:45

max127BB-IR-Gate Using a pot meter to test the MAX127 is not a hugely useful way to exploit the power of this ADC.  Instead, this time I have replaced the pot meter with an IR receiver. The main part of this circuit is still exactly the same as in the previous MAX127 post.  The only difference this time is the IR receiver, IR LED and the astable oscillator circuit with the 555 IC.  The oscillator has been configured at 36KHz, which just so happens to be the frequency at which the TSOP2236 is most sensitive.  Coincidence?  I think not!

max127circuit-IR-Gate I took the basic 555 circuit from here. I modified a little to make it work with my IR LED and oscillate at 36KHz with as close to a 50% duty cycle as I could get it.  After running some calculations I picked a 1K and a 1.5K Ohm resistor in combination with a 0.01uF capacitor to give me the right frequency with a duty cycle of roughly 38%, close enough for me.  The mathematical details can be found on the page with the original 555 circuit. Below you will find a table of components.

R1, R2 82 KOhm
R3, R4, R5, R7 1 KOhm
R6 1.5 KOhm
C1 4.7 uF
C2, C6, C7 0.01 uF
C3, C4, C5 0.1 uF
D1 Red LED 10mA
D2 IR LED
555 555 IC
TSOP2236 TSOP2236 IR Receiver 36KHz

I used the same program as in my previous article about the MAX127.  However, now it was pretty clear what kind of readings I could expect from such a sensor.  With no obstacle between the sensor and the LED, I would get a reading of 0 or 1.   With no IR light hitting the sensor, the MAX127 would return a reading of around 1620.  Due to the nature of my setup, I could only configure the LED and sensor to be facing each other head on. I leave it as an exercise for the reader to configure the breadboard in a slightly better way so it can be used as a proper distance measuring circuit.

You will need to calibrate the sensors of course, the values 978 or 1300 are pretty meaningless if you don’t know what distances they represent.  Also keep in mind that IR distance gauging is very dependant on the amount of light reflected by the surface you’re measuring against.  That means that if you’re measuring against a nice smooth white surface you will get a different reading from measurements at the same distance against a black velvety surface (for example).  The white surface is nice and reflective, whereas the black velvet surface will absorb a great deal of the light.

Happy distance gauging!

July 23, 2008

A little overkill on the packaging

Filed under: Ramblings — Xander @ 12:02

HiTechnics IR Link Sensor The Lego online webshop might not be the cheapest way to get your complete sets but they do carry the full range of HiTechnic NXT sensors, many of which are not sold in Europe through toy stores or other online retailers.  I ordered my HiTechnic IR Link Sensor on Saturday evening and received it just this morning.  That might seem a little slow to some people but I didn’t use the Express service, so all in all, it got here pretty quickly.  They say up 5-7 work days, but I’ve never had anything take more than about 3 or 4.  So no complaints there.

Packaging for my IR Link SensorUpon delivery of the package I was somewhat surprised by the size of the cardboard box.  The box measured 32×21x8 cm, doesn’t sound like a lot, does it?  However, I had a good idea of what was in there and to be honest, it didn’t warrant the amount of cardboard that it had.  The small thing in the middle of the picture is the actual sensor, it measures approximately 4×1.5×1.5 cm and doesn’t really weigh a whole lot.  When my replacement NXT brick came a few weeks ago, the packaging was nice and snug and not all that much bigger than the brick itself.  Granted, we can’t be sending packages the size of matchboxes through the post, but even something the size of the label on this box would’ve been a whole lot better.  Please start using smaller boxes for things that don’t take up all that much space.  I know you have the smaller boxes, the NXT brick was proof of that.  You don’t want to end up on a site like this: LINK.

Thanks.

July 19, 2008

MAXimum conversion

Filed under: Experiments, Robots, Sensors — Xander @ 20:56

It’s been a little while since my last article about adding peripherals to the NXT, but not due to the lack of experimenting and programming, let me tell you.  In my quest to tame the Maxim MAX127, I ran into a few annoying bugs in RobotC.  The first one involved not being able to use structs of bytes to send I2C commands to the sensor and the other involving automatic conversion of unsigned bytes to signed integers.  RobotC does not really support unsigned variables, with the exception of bytes and chars.  When you use an unsigned variable inadvertently you’re greeted with a nice warning:

Warning*:ROBOTC only supports ‘unsigned’ qualifier on ‘byte’ / ‘char’ sized variables. Ignored for other type.

I figured out a work-around for both bugs, so all is well now. 

Breadboard with MAX127 (click to enlarge) To the right you can see the fruits of my labour; a breadboard with a MAX127, a pot meter and a bunch of other components, as described in the table below.

R1, R2 82 KOhm
R3, R4 1 KOhm
R5 1 KOhm pot
C1 4.7 uF
C2 0.01 uF
C3, C4, C5 0.1 uF
D1 Red LED 10mA

The LED is there merely as a status LED so you can see when power has been applied to the board.  The connector is a home made one, as described in this article.

MAX127 schematic (click to enlarge) The schematic for this can be seen on the left.  It would be very trivial to add more pot meters to this and tweak the program to make use of them.  Of course, pot meters are not the only thing that can be read by an ADC such as the MAX127.  You could connect IR photo-transistors, thermistors, LDRs, you name it!  In a future article I will be hooking up various other sensors and use them as inputs for a robot.  Stay tuned for more information.

The source code for this article can be found here: LINK.

July 5, 2008

Attack of the Clones

Filed under: Experiments, Sensors — Xander @ 20:40

Click to enlarge If you’ve been reading my articles (1, 2) on the Mindsensors PCF8574A board but are unable to purchase one for any number of reasons, here’s a blatant clone made on a breadboard.  It will function pretty much the same way as the Real Thing but doesn’t look nearly as nice.  Below you will find the schematic and the values of the components. The +5V’s in the circuit are all hooked up to pin 4 on the NXT connector.  Pin 1 on the connector is not connected to anything, it’s the analogue input for the NXT and we’re using I2C.  On the Mindsensors board C1 is a 22uF capacitor, however, I only had a 47uF.  I guess either will be fine.  Here is some source code to check if you’ve hooked it up properly: LINK.  It should blink the LED a few times a second.  The breadboard adapter is a home made one.  For instructions and more photos of that, click here.

Click to enlarge

R1, R2 82KOhm
R3 1KOhm
D1 10mA red LED
C1 47uF
C2 0.1uF

   

July 1, 2008

NXT Connector Breadboard Hack

Filed under: Experiments — Xander @ 17:26

NXT Connector Breadboard Hack To the left are the fruits of about an hour’s worth of hack-sawing, soldering and hot gluing.  If you can’t see from the pictures what it is, let me explain.  It’s one of the Mindsensors NXT connectors attached to a cut-to-size prototype copper strip board.  It’s not the prettiest thing in the world but it works.  I hot glued a smooth 1×2 Lego piece to the bottom to make it more stable when inserted on a breadboard.  I wish Mindsensors would sell these pre-made or at least with a nicer looking circuit board.  The pins don’t fit in a standard copper strip board, although I did see a picture somewhere online (I forget which site, sorry) where someone had cut off the little plastic legs and bent the copper pins a bit to make them fit.  I didn’t see this site until it was already made, of course.  My next version will be made that way and I’ll be sure to post pictures of it.  For now this will have to do the trick.

Blog at WordPress.com.