Home

NXT Touch Sensor Multiplexer

HiTechnic NXT Touch Sensor Multiplexer 
Fo
r LEGOÒ MindstormsÒ NXT

 

 

Introduction

 

 

 

 

 

 

 

 

 

 

The NXT Touch Sensor Multiplexer allows up to 4 touch sensors to be connected to a single NXT sensor port.  An NXT program can read the state of each touch sensor or the state of all 4 touch sensors with a single read command.

Programming

Mindstorms NXT-G

This block checks each of the touch sensors connected to the Touch Sensor Multiplexer and sends out its result as logic signals (true or false) through data wires. If a touch sensor has been triggered, the block will send out a true signal; if it has not been triggered, the block will send a false signal. Use the radio buttons to decide which state each touch sensor or switch has to be in to produce an overall logic "true" signal.

You must drag at least one output data wire from this block's data hub to another block for any information to be sent.

The term Multiplexer is often shortened to "MUX".

Note: The Touch Sensor MUX only works with Touch Sensors. If other types of sensors are plugged into the Touch MUX they will not operate.

Display Settings

Image of block

  1. The number shows which NXT port is connected to the Touch Sensor Multiplexer. You can change this number in the configuration panel if you need to.
  2. The block's data hub will open automatically when the block is placed in the work area. At least one data wire must be dragged from the block's output plug to another block's data hub. (See the Data Hub section below for more information.)

Configuring the Touch Sensor Multiplexer Block

Image of configuration panel

  1. Choose the NXT port your Touch MUX is plugged into. By default, the block will be set to port 2 for a Touch Sensor Multiplexer. You can change this selection if you need to.
  2. Select the desired combination of Touch Sensor inputs that will be combined to create the overall logic output. In the default state, all four Touch Sensors must be triggered to create an overall true output. If a Touch Sensor input is not needed to contribute toward the overall logic output, then Ignore should be selected. If a Touch Sensor input is needed but in the untriggered state to contribute toward the overall logic output, then False should be selected.

    For example, with the setting shown in the following front panel, the overall logic output will be set to True when

    Touch Sensor 1 is pressed (True)
    and
    Touch Sensor 2 is not pressed (False)
    and
    Touch Sensor 3 is pressed (True)
    and
    Touch Sensor 4 is ignored (don't care if it is pressed or not)

Image of configuration panel

Touch MUX block Data Hub plugs

The connections to the Touch Sensor Multiplexer are mechanically configured as follows;

The connector identified by the "NXT" label should be wired to the desired NXT sensor port.

Up to four Touch Sensors can be wired to the connectors labeled 1 - 4.

This chart shows the different characteristics of the plugs on the Touch MUX block's data hub:

Plug

Data Type

Possible Range

What the Values Mean

Port

Port

Number

1 - 4

1 = Port 1, 2 = Port 2, 3 = Port 3, 4 = Port 4

Max/Min

Switch1

Logic

True/False

True = Touch Sensor pressed
False = Touch Sensor not pressed

Max/Min

Switch2

Logic

True/False

True = Touch Sensor pressed
False = Touch Sensor not pressed

Max/Min

Switch3

Logic

True/False

True = Touch Sensor pressed
False = Touch Sensor not pressed

Max/Min

Switch4

Logic

True/False

True = Touch Sensor pressed
False = Touch Sensor not pressed

Max/Min

Raw Value

Number

0 - 15

Raw (unscaled) value from the Touch MUX

Max/Min

Yes / No

Logic

True/False

Compare table result

Max/Min

Entry1

Number

0 - 2

Switch 1 Compare entry
0=Select True, 1=Select False, 2 = Select Ignore

Max/Min

Entry2

Number

0 - 2

Switch 2 Compare entry
0=Select True, 1=Select False, 2 = Select Ignore

Max/Min

Entry3

Number

0 - 2

Switch 2 Compare entry
0=Select True, 1=Select False, 2 = Select Ignore

Max/Min

Entry4

Number

0 - 2

Switch 2 Compare entry
0=Select True, 1=Select False, 2 = Select Ignore

The code for this program and other examples can be downloaded from the downloads page.

Other Programming Environments

NXC

The Touch Sensor Multiplexer can read from NXC by reading as shown in the following example. 

NXC Example code

value=1023-SensorRaw(INPUT_PORT);
switches=339*value;
switches/=1023-value;
switches+=5;
switches/=10;
if(switches&8) switch4=1; else switch4=0;
if(switches&4) switch3=1; else switch3=0;
if(switches&2) switch2=1; else switch2=0;
if(switches&1) switch1=1; else switch1=0;

 More information regarding NXC is available at http://bricxcc.sourceforge.net/nbc/.

 LabVIEW Toolkit vi

The Touch Sensor Multiplexer is supported from the NXT LabVIEW Toolkit.  A vi is available for download from the Download page. 

More information on LabView for MINDSTORMS is available at http://www.ni.com/academic/mindstorms/

 

RobotC

 

task main()
{
     SensorType[S3] = sensorHiTechnicTouchMux; // Configure the sensor.

 

         while (true)
         {
            int nButtonsMask;

             //
             // The sensor value is a 4-bit map indicating which of the possible four
            // touch sensors are pressed.
            //
           nButtonsMask = SensorValue[S3];

           if (nButtonsMask & 0x01)
             nxtDisplayTextLine(1, "Btn 1: Pressed");
           else
             nxtDisplayTextLine(1, "Btn 1:");

           if (nButtonsMask & 0x02)
             nxtDisplayTextLine(2, "Btn 2: Pressed");
           else
             nxtDisplayTextLine(2, "Btn 2:");

           if (nButtonsMask & 0x04)
             nxtDisplayTextLine(3, "Btn 3: Pressed");
           else
             nxtDisplayTextLine(3, "Btn 3:");

           if (nButtonsMask & 0x08)
             nxtDisplayTextLine(4, "Btn 4: Pressed");
           else
             nxtDisplayTextLine(4, "Btn 4:");
           wait1Msec(100);
         }
}

 

For more information go to http://www.robotc.net/content/lego_over/lego_over.html.  

 

Notes:

 

The latest version of the Touch Sensor Multiplexer block is available at www.hitechnic.com.   Go to the downloads page to download all the HiTechnic programming blocks.

 

Return to Products

 

 To contact us with questions or comments see Contact Us.                                                                                12.3

Copyright © 2001 - 2007 HiTechnic Products.    HiTechnic Products is a division of Dataport Systems, Inc.
Lightbricks, Hitechnic are registered trademarks of Dataport Systems, Inc  Not responsible for typographical errors.  All product specifications 
and prices are subject to change at any time.

LEGO, LEGO MindStorms, Robotics Invention System, RCX are trademarks of the LEGO Group.