View unanswered posts | View active topics It is currently Sat Apr 21, 2018 2:07 am






Reply to topic  [ 4 posts ] 
EV3 Sensor Multiplexer 
Author Message
Expert

Joined: Thu Dec 01, 2011 12:07 am
Posts: 151
Post 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?

Code:
#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.
 *
 * THIS CODE WILL ONLY WORK WITH ROBOTC VERSION 4.10 AND HIGHER
 * \author Xander Soldaat (xander_at_botbench.com)
 * \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");
  sleep(2000);
  eraseDisplay();
  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);

          switch(muxedSensor[i].typeMode)
          {
             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);
                break;

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

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

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

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

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

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

           // 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]);
              break;

           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);
              break;

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

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

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


Sat Jan 31, 2015 10:32 pm
Profile
Site Admin
Site Admin
User avatar

Joined: Wed Mar 05, 2008 8:14 am
Posts: 3654
Location: Rotterdam, The Netherlands
Post 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

_________________
| Professional Conduit of Reasonableness
| (Title bestowed upon on the 8th day of November, 2013)
| My Blog: I'd Rather Be Building Robots
| ROBOTC 3rd Party Driver Suite: [Project Page]


Sun Feb 01, 2015 2:48 am
Profile WWW
Expert

Joined: Thu Dec 01, 2011 12:07 am
Posts: 151
Post 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.


Sun Feb 01, 2015 9:41 pm
Profile
Site Admin
Site Admin
User avatar

Joined: Wed Mar 05, 2008 8:14 am
Posts: 3654
Location: Rotterdam, The Netherlands
Post Re: EV3 Sensor Multiplexer
I am glad it did the trick for you :)

= Xander

_________________
| Professional Conduit of Reasonableness
| (Title bestowed upon on the 8th day of November, 2013)
| My Blog: I'd Rather Be Building Robots
| ROBOTC 3rd Party Driver Suite: [Project Page]


Mon Feb 02, 2015 1:43 am
Profile WWW
Display posts from previous:  Sort by  
Reply to topic   [ 4 posts ] 

Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  



Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.