View unanswered posts | View active topics It is currently Wed Oct 22, 2014 3:58 am






Reply to topic  [ 1 post ] 
Mindsensors RXMux Driver 
Author Message
Moderator
Moderator
User avatar

Joined: Wed Jan 31, 2007 3:39 am
Posts: 299
Location: San Diego, California. USA
Post Mindsensors RXMux Driver
Hey Everyone

Here is my driver I made for the Mindsensors RXMux. This sensor lets you hook up 4 RCX style sensors to the NXT and multiplex between them. Here is the driver and sample code:

Mindsensors RXMux Driver and Examples.zip 1.37 Kb

Enjoy! B-)
Scott

Driver Code:
Code:
/*

RXMux Demo Program and Driver
Written  by Scott Briscoe   01/26/2008
Modified by Nitin Patil         02/05/2008
Modified by Scott Briscoe   11/03/2008

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Registry Information:

0x7E    RXMux Address

0xFF    No Channel
0xFE    Channel 1
0xFd    Channel 2
0xFB    Channel 3
0xF7    Channel 4

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
RXmuxChannel(const tSensors RXMuxPort, byte RXMuxChannel,
TSensorTypes ChannelSensorType, TSensorModes ChannelSensorMode)


RXMuxPort: Port where RXMux is connected.
RXMuxChannel: RXMux Channel you want to select.
                     * use numbers 1 through 4
ChannelSensorType: Sensor type of the sensor on the chosen channel.
                     * use RobotC defined sensor types
                           * sensorReflection
                           * sensorTouch
                           * sensorTemperature
                           * sensorRotation
ChannelSensorMode:   Sensor mode of the sensor on the chosen channel.
                     * use RobotC defined sensor modes
                           * modeBoolean
                           * modeDummy
                           * modeEdgeCount
                           * modePercentage
                           * modePulseCount
                           * modeRaw
                           * modeRotation
                           * modeTemperatureC
                           * modeTemperatureF

Example:   RXmuxChannel(S1, 1, sensorReflection, modePercentage);
Will set port S1 to a light sensor on channel 1 and set the port to read the sensor in percent mode.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
*/

void RXmuxOff(const tSensors RXMuxPort)                 //Turn RXMux off, Channel 0
{
   SensorType[RXMuxPort] = sensorI2CCustom9V;
   byte RXMuxMSG[] =   {2, 0x7E, 0xFF};                   // Array message to send

  while (nI2CStatus[RXMuxPort] == STAT_COMM_PENDING)
  {
     wait1Msec(2);                                       // Wait for I2C bus to be ready
  }
  sendI2CMsg(RXMuxPort, RXMuxMSG[0], 0);                // Send the message
}

void RXmuxChannel(const tSensors RXMuxPort, byte RXMuxChannel,
    TSensorTypes ChannelSensorType,TSensorModes ChannelSensorMode)
{
   if (RXMuxChannel==1) RXMuxChannel = 0xFE;             //Set RXMux channel 1-4
   else if (RXMuxChannel==2) RXMuxChannel = 0xFD;
   else if (RXMuxChannel==3) RXMuxChannel = 0xFB;
   else if (RXMuxChannel==4) RXMuxChannel = 0xF7;

   SensorType[RXMuxPort] = sensorI2CCustom9V;
   byte RXMuxMSG[] =   {2, 0x7E, RXMuxChannel};           // Array message to send

  while (nI2CStatus[RXMuxPort] == STAT_COMM_PENDING)
  {
     wait1Msec(2);                                       // Wait for I2C bus to be ready
  }
  sendI2CMsg(RXMuxPort, RXMuxMSG[0], 0);                // Send the message
   wait1Msec(5);                                             // have to have wait or sensor wont read proper values
  SensorType[RXMuxPort] = ChannelSensorType;            // Sensor Type on the chosen channel
  SensorMode[RXMuxPort] = ChannelSensorMode;                  // Sensor Mode on the chosen channel

}


_________________
Mmmm Legos B-)

My Robot Projects:
http://www.freewebs.com/robotprojects/


Thu Nov 13, 2008 7:48 pm
Profile WWW
Display posts from previous:  Sort by  
Reply to topic   [ 1 post ] 

Who is online

Users browsing this forum: No registered users and 2 guests


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.