EV3 Sensor Multiplexer
Page 1 of 1

Author:  CARBOT [ Sat Jan 31, 2015 10:32 pm ]
Post subject:  EV3 Sensor Multiplexer

I am using RobotC 4.28 with a Mindsensors EV3 Sensor Multiplexer on an EV3.
The example program mindsensors-ev3smux-test1.c works straight up and with different sensor arrangements on port S1.
I am trying to get it to work on a different port.
I changed 'S1' to 'S3' in the 7 places as below but I get sensor port configuration messages.
Is there something else I need to do to use the sensor mux on a different port?

#pragma config(Sensor, S3,     ,               sensorEV3_GenericI2C)
//*!!Code automatically generated by 'ROBOTC' configuration wizard               !!*//

#include "mindsensors-ev3smux.h"

 * Credits:
 * - Big thanks to Mindsensors for providing me with the hardware necessary to write and test this.
 * License: You may use this code as you wish, provided you give credit where its due.
 * \author Xander Soldaat (
 * \date 14 December 2014

// The SMUX can have up to 3 sensors attached to it.
tMSEV3 muxedSensor[3];

// Configure your sensor type here.  The following are available:
// colorReflectedLight
// colorAmbientLight
// colorMeasureColor
// gyroAngle
// gyroRate
// infraRedProximity
// infraRedBeacon
// infraRedRemote
// sonarCM
// sonarInches
// sonarPresence
// touchStateBump

tEV3SensorTypeMode typeMode[3] = {touchStateBump, colorReflectedLight, colorReflectedLight};

task main()
  displayCenteredTextLine(0, "Mindsensors");
  displayCenteredBigTextLine(1, "EV3 SMUX");
  displayCenteredTextLine(3, "Test 1");
  if (!initSensor(&muxedSensor[0], msensor_S3_1, typeMode[0]))
     writeDebugStreamLine("initSensor() failed! for msensor_S3_1");

  if (!initSensor(&muxedSensor[1], msensor_S3_2, typeMode[1]))
     writeDebugStreamLine("initSensor() failed! for msensor_S3_2");

  if (!initSensor(&muxedSensor[2], msensor_S3_3, typeMode[2]))
     writeDebugStreamLine("initSensor() failed! for msensor_S3_3");

  while (true)
       for (int i = 0; i < 3; i++)
         if (!readSensor(&muxedSensor[i]))
            writeDebugStreamLine("readSensor() failed! for %d", i);

             case touchStateBump:
               displayTextLine(i*3, "Chan[%d]: Touch", i+1);
               displayTextLine(i*3 + 1, "Touch: %s, Bumps: %d", muxedSensor[i].touch ? "yes" : "no ", muxedSensor[i].bumpCount);

             case colorReflectedLight:
               displayTextLine(i*3, "Chan[%d]: Ref Light", i+1);
               displayTextLine(i*3 + 1, "Value: %d", muxedSensor[i].light);

             case colorAmbientLight:
               displayTextLine(i*3, "Chan[%d]: Amb Light", i+1);
               displayTextLine(i*3 + 1, "Value: %d", muxedSensor[i].light);

             case colorMeasureColor:
               displayTextLine(i*2, "Chan[%d]: Color", i+1);
               displayTextLine(i*2 + 1, "Color: %d", muxedSensor[i].color);

           case gyroAngle:
               displayTextLine(i*3, "Chan[%d]: Gyro", i+1);
               displayTextLine(i*3 + 1, "Angle: %d", muxedSensor[i].angle);

           case gyroRate:
               displayTextLine(i*3, "Chan[%d]: Gyro", i+1);
               displayTextLine(i*3 + 1, "Rate: %d", muxedSensor[i].rate);

           case infraRedProximity:
               displayTextLine(i*3, "Chan[%d]: IR Prox", i+1);
               displayTextLine(i*3 + 1, "Distance: %d", muxedSensor[i].distance);

           // Only beacon data (proximity and heading) for channel 1 is displayed
           case infraRedBeacon:
               displayTextLine(i*3, "Chan[%d]: IR Beac", i+1);
               displayTextLine(i*3 + 1, "Prox: %d, Head: %d", muxedSensor[i].beaconProx[0], muxedSensor[i].beaconHeading[0]);

           case infraRedRemote:
               displayTextLine(i*3, "Chan[%d]: IR Rem ", i+1);
               displayTextLine(i*3 + 1, "1: %02d, 2: %02d, 3: %02d, 1: %02d", muxedSensor[i].touch ? "yes" : "no ", muxedSensor[i].bumpCount);

           case sonarCM:
               displayTextLine(i*3, "Chan[%d]: US CM", i+1);
               displayTextLine(i*3 + 1, "Distance: %d", muxedSensor[i].distance);

            case sonarInches:
               displayTextLine(i*3, "Chan[%d]: US Inch", i+1);
               displayTextLine(i*3 + 1, "Distance: %d", muxedSensor[i].distance);

           case sonarPresence:
               displayTextLine(i*3, "Chan[%d]: US Pres", i+1);
               displayTextLine(i*3 + 1, "Present: %s", muxedSensor[i].presence ? "yes" : "no ");
        displayTextLine(i*3 +2, " ");

Author:  mightor [ Sun Feb 01, 2015 2:48 am ]
Post subject:  Re: EV3 Sensor Multiplexer

Hi there,

Your code is working fine for me. One thing I noticed with the SMUX is that you need to make really, really sure that the cable between in and the EV3 is jammed right into the socket on the sensor side. Try that and let me know if that makes a difference.

= Xander

Author:  CARBOT [ Sun Feb 01, 2015 9:41 pm ]
Post subject:  Re: EV3 Sensor Multiplexer

All 4 connectors were in far enough to be held by the locking tab. I pushed each in and it worked, pulled them and it did not. It did the same thing with the Lego and Mindsensors cables. I am hoping a zip tie will hold them in place. Thanks for your help, let me know if you ever make it to the Detroit area.

Author:  mightor [ Mon Feb 02, 2015 1:43 am ]
Post subject:  Re: EV3 Sensor Multiplexer

I am glad it did the trick for you :)

= Xander

Page 1 of 1 All times are UTC - 5 hours [ DST ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group