Move over LEGO brick!
Here comes Raspberry Pi, and it is going to change the face of robotics forever!
Raspberry Pi is Linux machine the size of a credit card. Plug in your television and a keyboard and you have a fully-functional computer for $25.
YES!!!
TWENTY-FIVE DOLLARS!!!!
Models:
There are two models, Model A and Model B.
Model A has 256MB RAM, 1 USB port and no Ethernet (network connection).
Model B has 256MB RAM, 2 USB ports and an Ethernet port.
Specs:
It relies on a System on a Chip (SoC). The particular SoC used is Broadcom BCM2835. The Broadcom BNC2835 is a High Definition 1080p Embedded Multimedia Applications Processor. It relies on the ARM1176 (ARM1176JZF-S) Processor which has a floating point processor and runs at 700 MHz. Moreover, the SoC has a Videocore 4 GPU, which is capable of BluRay quality playback, using H.264 at 40MBits/s. The Broadcom BNC2835 has a fast 3D core accessed using the supplied OpenGL ES2.0 and OpenVG libraries. The GPU is capable of 1 Gpixel/s, 1.5 Gtexel/s or 24 GFLOPs of general purpose computing.
Size:
The Raspberry Pi is SMALL!
The card is slightly larger than 85.60 mm x 53.98 mm x 17 mm due to the fact that the SD card and connectors project over the edges. It weighs with a mass of 45g. The Raspberry Pi is low power and runs on 4 AA cells.
Programming:
Fedora, Debian and ArchLinux are supported and other distributions will be supported later. Python is the official educational language.
I cant wait to get my hands on one of these and begin interfacing directly with the LEGO motors and sensors!
Jameco.com has an interesting article on how to build your own Arduino microcontroller circuit.
The circuit relies on an ATMega328 microcontroller, and since it requires only component parts it is cheaper and has a potentially smaller footprint than the popular Arduino Boards.
NOTE: WE ARE NOT RESPONSIBLE FOR ANY DAMAGE YOU MAY DO TO YOUR NXT BRICK.
THIS EXERCISE PRESUMES SOME WORKING KNOWLEDGE OF ELECTRONICS.
In this exercise, I will walk you through interfacing a potentiometer (variable resistor) to the NXT brick.
You will need:
– A stripped NXT cable
– A potentiometer with a maximum resistance no more than
– A small piece of wire
– An NXT Brick
This exercise is derived and expanded from a chapter in Extreme NXT by Gasperi, Hurbain and Hurbain.
THEORY
The NXT monitors the potential difference between the black and white wires with an Analog-to-Digital (A/D) converter. The A/D converter converts this potential difference to a RAW value between 0 and 1023 (10 bits accuracy). This RAW value is given by the ratio
(1)
where is the maximum RAW value of 1023, is the voltage used by the NXT A/D Converter, and is the voltage drop between the black and white wires.
The circuit diagram looks like this:
I have a little potentiometer that can turn over a range of about to . Below is a diagram. The resistance between the leftmost and rightmost pins is the maximum resistance of . We will focus on the resistance between the leftmost and center pins, which varies based on the angle through which the potentiometer has been rotated. To keep things safe, we wire the center pin and rightmost pin together. This doesn’t affect the potential difference between the leftmost and center pins.
I will assume that it is a linear potentiometer (a pretty good assumption), which means that the resistance at any given angle is given by
(2)
where is the maximum angle of the potentiometer and is the maximum resistance.
Equation (2) says that if the angle then the resistance of the potentiometer , and if the angle then the resistance of the potentiometer is maximum .
Looking at the circuit diagram for the A/D converter, the potential drop across our potentiometer (represented by resistor ) is given by the typical voltage divider relation
(3)
We can now substitute (2) into (3) so that the voltage between the black and white wires is determined by the angle of the potentiometer rather than its resistance. Then we can substitute the result into (1) to get an equation for the RAW value
(4)
with my particular values, this is
This formula will let us predict the NXT RAW value based on the angle of the potentiometer.
For my potentiometer, I find that a maximum angle of gives me a maximum value of 93. This is less than 7 bits of information, and each RAW value corresponds to . If you want a nice angle detector, you will probably need a potentiometer!
TRY IT
1. Before beginning, you need to cut and strip one of the NXT cables so that you can interface with the wires directly. I have placed a layer of solder on mine, so they can be inserted into a breadboard for easy connecting.
2. Next connect the center and right pins of the potentiometer together with a wire
3. Plug the other end of the NXT cable into the NXT brick.
I wrote a simple NXT-G program to read the sensor and display the RAW value. Notice that the Touch Sensor actually reads the resistance between the wires. So we are just replacing the Touch Sensor with a potentiometer. We will use the raw number output of the Touch Sensor Block, which is represented by the 1010 0101 symbol. We then need to convert it to text so it can be displayed on the NXT LCD panel.
You may download it here, Potentio-01.rbt
or write your own.
When I try my potentiometer, I find that the RAW value goes from 0 to 95, pretty close to my predicted range of 0 to 93. So it works! Not bad considering I guessed that the potentiometer sweeps through and angle of .
Determining the Angle of the Potentiometer
Now, let’s convert this RAW value to an angle.
In Extreme NXT, the authors worry about the fact that the resulting relationship is nonlinear with respect to the RAW value. As far as I can see, this isn’t a problem. We simply solve (4) above for the angle in terms of RAW. We can output the angle if we wish, but here I’ll take it a step further and demonstrate the resulting equation by controlling a motor so that it maintains an angle equal to the angle through which I have rotated the potentiometer.
I will leave out the algebra. Try it yourself. Solve (4) for angle A:
(5)
for my potentiometer, this is simply
which is easy to code in NXT-G.
You can download my code here: Potentio-03.rbt
The motor control is a bit crude, but it works well enough for the demonstration.
Check out the YouTube video to see it in action!
An article at NXTasy.org highlights a three-wheeled robot that moves in one dimension and detects signals from an external beacon that emits ultrasonic bursts. The robot relies on a microcontroller that runs a Kalman filter to perform and maintain spatial localization. The NXT software is implemented using the LabVIEW NXT toolkit
The NXT cable has six wires. Below I list a table with the wires and their colors:
Color
Name
White
Motor 1
Black
Motor 2
Red
GND
Green
4.3 Volts
Yellow
Tach01
Blue
Tach02
The WHITE and BLACK wires (Motor 1 and Motor 2) deliver power to the motor.
If standard batteries are used, the potential difference will be 9 volts, otherwise the NiMH rechargeable batteries provide 7.2 volts. If the white wire is positive and black is negative, the motor will turn one way. If you reverse the polarity, the motor will turn the other way.
The RED wire is connected to the ground (GND). Note that in the sensors, RED and BLACK are connected to one another. This is not the case in the motors.
The GREEN wire is connected to the +4.3 NXT power supply.
As shown in the figure from Wikipedia above, (http://en.wikipedia.org/wiki/Quadrature_encoder) the wires return square wave pulses that are 90 degrees out of phase. If the rising pulse on TACH00 leads the rising pulse of TACH01 by 90 degrees, then the motor is going forward. If it instead lags by 90 degrees, the motor is rotating backwards. One complete square wave cycle corresponds to 2 degrees of rotation. In the diagram above, if TACH00 refers to A and TACH01 refers to B, we can see that the motor is going backwards as TACH00 is lagging TACH 01.
By measuring the frequency of the square wave oscillation, one can compute the rotational velocity. Since one cycle corresponds to 2 degrees of rotation, one cycle per second (1 Hz) corresponds to 2 degrees/sec. If you record a frequency of X Hz, then the rotation rate is 2X cycles/sec.
Note also that by tracking both square waves, you can identify quarter cycles, which gives you a resolution of 1/4 of 2 degrees, which is 0.5 degrees.
The motor speed is controlled by pulse-width modulation (pwm), which works by driving the motor with a variable duty cycle square wave. This effectively turns the motor on and off, fast. The longer it is on, the more torque it will generate and the faster it will go.
These details and more can be found in the excellent book: Extreme: NXT with a sneak peak here.
I am getting interested in more general robotics projects, but will still be relying on LEGOs for their construction. The LEGO brick is a bit too limited with its specialized programming languages and limited sensor and motor ports.
So for those interested in some LEGO electronics hacking, here is a list of supplies that will get you up and running fast for about $275… just a but more than the cost of a single Mindstorms kit. Plus you’ll now get to learn electronics!
This book explains how to wire, program and interconnect various microcontrollers, some of which are very closely related to those used by the NXT Brick.
Note that the light gray items are optional, and not necessary.
Also, this list does not include some sort of power supply. Pulling one out of an old computer is an easy option. Or rechargeable batteries work well too (in which case you will need battery holders).
Last, there are special items in the book Making Things Talk that you may decide to purchase separately, such as flex sensors, or bluetooth boards, etc.
We are working on interfacing the LEGO sensors and motors to a compact lightweight computer for more sophisticated control. Aret Carlsen brings us a video demonstrating how one can hack into the NXT Light Sensor: