Back
Home
9751 LEGO Technic Interface B

Parts

The LEGO Control Lab Interface B consists of the Interface itself along with a Power Supply, and a 9-Pin RS-232 serial cable.


Interface B

Power Supply Serial Cable

The Interface outputs are designed to be used with the LEGO 9V system of accessories, such as motors, lights, sound elements, and wires.

Motors Lights Sound Element Wire, Plate, Switch

In addition the interface inputs use touch, temperature, light, and rotation sensors.

Touch Sensor Temperature Sensor Light Sensor Rotation Sensor

The Interface B was sold to be used with the ROBOLAB software, but ROBOLAB requires some specific configuration to work with the Interface B.

ROBOLAB Configuration



Protocol:

The Interface B communicates with a computer via a standard RS-232 serial port. It will also work through a USB-to-Serial adapter. The communication details are thanks to Charlie Huddleston, found here, with the following clarifications:

"I went back and compared the code I wrote with the paper on the web and to my dismay found differences. A couple of typographical errors in my paper have completely thrown you off course and I'm very sorry. Where it says the rightmost 12 bits are used to determine the temperature, it should say the LEFTmost 10 bits are used. So if you put your two-byte status code in the formula:
T=(760-(twobytes & 0xFFC0))/4.4+32
You should get a fairly accurate Fahrenheit temperature reading. Another typo is in the next bullet about the angle sensor. Where is says the rightmost two bytes specify the amount of change, it should say the rightmost two bits. I'm TERRIBLY SORRY about these errors, I hope they didn't cause you too much trouble. Good luck with your project and if you have any more questions, please ask. Charlie.Huddleston@usa.net."

Additionally, I have discovered two other clarifications:

The Set Power output command should be "10110nnn", not "0110nnn".
The Touch Sensor first byte is 0xFF when not pressed, and anything else when pressed; not 0x2E for pressed.

The requirements to establish and maintain communication between the Interface B and the computer are:

1. The computer sends "p\0###Do you byte, when I knock?$$$".

2. Upon receiving the above message, the Interface B sends "###Just a bit off the block!$$$".

3. The Interface B now sends input data several times a second in the form of a 19 Byte word. The data for the eight inputs is as follows, with the checksum Byte varying in order to make the sum of all 19 Bytes equal to 0xFF:

Bytes Purpose
1-2 Zeros
3-4 Port 4 Input
5-6 Port 8 Input
7-8 Port 3 Input
9-10 Port 7 Input
11-12 Port 2 Input
13-14 Port 6 Input
15-16 Port 1 Input
17-18 Port 6 Input
19 Checksum Byte

The two Byte word must be interpreted for the specific type of sensor that is connected.

Touch Sensor Temperature Sensor Light Sensor Rotation Sensor
first Byte = 0xFF pressed; otherwise not pressed degrees F = (760-x)/4.4+32; where x = leftmost 10 bits value [0-1023 decimal] intensity = rightmost 12 bits value [0-4095 decimal] third bit from right = direction of rotation; rightmost two bits = amount of change since last frame (divided by 16 = fraction of one rotation)

4. The computer must look for, receive, and process the input data.

5. The computer can now make decisions based on the inputs and send commands to the outputs. The eight outputs can be controlled by a two Byte word. The first Byte specifies the command and the second Byte designates the output port number:

Command First Byte
Power On 10010001
Power Off 10010000
Polarity Reverse 10010101
Polarity Left 10010100
Polarity Right 10010011
Power Level 10110nnn

Output Second Byte
A 00000001
B 00000010
C 00000100
D 00001000
E 00010000
F 00100000
G 01000000
H 10000000

6. In order to maintain communication, the computer sends "2" every two seconds.



Software:

I wrote this program using Visual C# 2010 Express to communicate with the Interface B using the above protocol. The application reads inputs as fast as necessary to keep the buffer low, usually around 60Hz. To keep data flow to a minimum, the software only sends output commands when they are changed. To address the keep-alive requirement, I incorporated a two-second timer to send the 0x02 message when it is running. The GUI (modeled to resemble the Interface B) can be used as a simple controller by itself with each output manipulated with the slider bars for power and the arrows or direction boxes to select Forward or Reverse. Also, when each output is active via tab, the standard arrow keys can be used to control the power and direction of the selected output. The inputs can be used by reading the appropriate data fields for each port corresponding to the type of sensor that is attached. 

Additionally, each output can be controlled via the keyboard in accordance with the following commands:

Output   A B C D E F G H
On/Off   1 2 3 4 5 6 7 8
Power Up   q w e r t y u i
Power Down   a s d f g h j k
Direction   z x c v b n m ,

Both the outputs and inputs can be controlled by the software by adding your own custom code in the noted area of the source code.

To use the program simply run the executable file, select the COM port to which the Interface B is connected, and press the Start button. While running, the Stop button turns off the outputs and stops communications (allowing the COM port to be changed). Press the Start button again to resume.

The program can be downloaded here LEGOInterfaceBexe.zip; this includes the executable. Simply extract and run the file.

The source code can be downloaded here LEGOInterfaceBsource.zip; this includes the Visual C# project files. Expand the zip file and place it in the Projects folder for Visual C# Express.



Resources:

Microsoft Visual C# Express http://www.microsoft.com/visualstudio/en-us/products/2010-editions/visual-csharp-express

A Real "Toy" Application http://drdobbs.com/embedded-systems/184410492

ROBOLAB Software http://education.lego.com/en-gb/products/mindstorms/2000069/

Using ROBOLAB with the Interface B http://www.legoengineering.com/knowledgemanager/questions/32/Using+RoboLab+with+Control+Lab+9751+(Interface+B)

9751 Instructions EN (4108660).pdf

9751 Warnings (821926).pdf

9751 Safety (879917-US).pdf

9751 Install (4113682).pdf

9751 Win95 Install (4113708).pdf

9751 License (4.122.268).pdf



Contact Information:

I hope you have as much fun and “Play Well” with your LEGO Interface B as I have. If you have any questions, please let me know at tom@lgauge.com.



Back