View unanswered posts | View active topics It is currently Sat Oct 25, 2014 1:32 pm






Reply to topic  [ 10 posts ] 
Sensor Multiplexer 
Author Message
Rookie

Joined: Fri Dec 02, 2011 6:21 pm
Posts: 5
Post Sensor Multiplexer
Hello,

Does someone have a step-by-step tutorial on how to install the HiTechnic Sensor Multiplexer (NOT the HiTechnic TOUCH Multiplexer)? If you do, could you please post it on the forum? Thank you in advance.


Fri Dec 16, 2011 10:56 am
Profile
Guru
User avatar

Joined: Sun Nov 15, 2009 5:46 am
Posts: 1347
Post Re: Sensor Multiplexer
1. Download Xander's driver suite if you haven't already (http://botbench.com/blog/robotc-driver-suite/)
2. Make sure you installed a 9V battery in the Sensor MUX and turn the power ON.
3. In your code, include Xander's Sensor MUX driver:
Code:
#include "..\XanderDriverSuite\drivers\HTSMUX-driver.h"    //Use the path where you put Xander's drivers

4. Connect the Sensor MUX upstream port (not any of the ports labeled 1, 2, 3, 4) to one of the sensor ports of the NXT (S1-S4).
5. Connect whatever sensors you want to use to the Sensor MUX ports 1-4.
6. Add the following lines to your code below the include line in step 3 above.
Code:
// Assuming the Sensor MUX is connected to NXT sensor port 4 (S4)
// Assuming the following sensors are connected to the Sensor MUX ports:
// Port 1: Gyro
// Port 2: Sonar
// Port 3: IRSeeker
// Port 4: Touch
#include "..\XanderDriverSuite\drivers\HTGYRO-driver.h"    //for gyro sensor
#include "..\XanderDriverSuite\drivers\LEGOUS-driver.h"    //for sonar sensor
#include "..\XanderDriverSuite\drivers\HTIRS2-driver.h"    //for IR seeker sensor
#include "..\XanderDriverSuite\drivers\LEGOTS-driver.h"    //for touch sensor
#define gyroSensor              msensor_S4_1
#define sonarSensor             msensor_S4_2
#define irSeekerSensor          msensor_S4_3
#define touchSensor             msensor_S4_4

7. Call Xander's driver to access the sensors.
Code:
HTGYROstartCal(gyroSensor);
int gyroRotation = HTGYROreadRot(gyroSensor);
int distanceInCM = USreadDist(sonarSensor);
int irACDirection = HTIRS2readACDir(irSeekerSensor);
bool limitSWActive = TSreadState(touchSensor);


Fri Dec 16, 2011 5:10 pm
Profile
Moderator
Moderator
User avatar

Joined: Wed Mar 05, 2008 8:14 am
Posts: 3227
Location: Rotterdam, The Netherlands
Post Re: Sensor Multiplexer
Thanks MHTS :) I saw this mail this morning but I was on my way out for the day. I couldn't have explained it better myself :)

- 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]


Sat Dec 17, 2011 7:04 pm
Profile WWW
Rookie

Joined: Thu Nov 29, 2012 2:16 pm
Posts: 3
Post Re: Sensor Multiplexer
Hi, I am new to robotc, and I am using the multiplexer to add two force sensors. Could somebody explain to me how to "Call Xander's driver to access the sensors" for the force sensor? Everything else seems to be in working order. thanks


Thu Nov 29, 2012 2:20 pm
Profile
Guru
User avatar

Joined: Sun Nov 15, 2009 5:46 am
Posts: 1347
Post Re: Sensor Multiplexer
arendyl wrote:
Hi, I am new to robotc, and I am using the multiplexer to add two force sensors. Could somebody explain to me how to "Call Xander's driver to access the sensors" for the force sensor? Everything else seems to be in working order. thanks

Please refer to Xander's sample code hitechnic-force-SMUX-test1.c.
To play with this sample code, connect the Sensor MUX to NXT Sensor port 1 (S1) and connect the force sensor to port 1 of the Sensor MUX. Compile and run Xander's test program and notice the force reading on the LCD display. If that works, then you can look at the source code of the sample regarding how to call Xander's driver to do the same.


Thu Nov 29, 2012 2:38 pm
Profile
Rookie

Joined: Thu Nov 29, 2012 2:16 pm
Posts: 3
Post Re: Sensor Multiplexer
MHTS wrote:
arendyl wrote:
Hi, I am new to robotc, and I am using the multiplexer to add two force sensors. Could somebody explain to me how to "Call Xander's driver to access the sensors" for the force sensor? Everything else seems to be in working order. thanks

Please refer to Xander's sample code hitechnic-force-SMUX-test1.c.
To play with this sample code, connect the Sensor MUX to NXT Sensor port 1 (S1) and connect the force sensor to port 1 of the Sensor MUX. Compile and run Xander's test program and notice the force reading on the LCD display. If that works, then you can look at the source code of the sample regarding how to call Xander's driver to do the same.


The force sensor works fine on its own, i just want to know how to reference it with as connected to the Sensor MUX, like you represented with these
Code:
 HTGYROstartCal(gyroSensor);
int gyroRotation = HTGYROreadRot(gyroSensor);
int distanceInCM = USreadDist(sonarSensor);
int irACDirection = HTIRS2readACDir(irSeekerSensor);
bool limitSWActive = TSreadState(touchSensor);


Thu Nov 29, 2012 3:34 pm
Profile
Guru
User avatar

Joined: Sun Nov 15, 2009 5:46 am
Posts: 1347
Post Re: Sensor Multiplexer
If you look at Xander's sample code, excerpt below:
Code:
task main() {
  int _force = 0;

  nNxtButtonTask  = -2;

  eraseDisplay();
  nxtDisplayCenteredTextLine(0, "HiTechnic");
  nxtDisplayCenteredBigTextLine(1, "Force");
  nxtDisplayCenteredTextLine(3, "SMUX Test");
  nxtDisplayCenteredTextLine(5, "Connect SMUX to");
  nxtDisplayCenteredTextLine(6, "S1 and sensor to");
  nxtDisplayCenteredTextLine(7, "SMUX Port 1");
  wait1Msec(2000);

  while(true) {
    // Read the sensor value
    _force = HTFreadSensor(HTFORCE);

    nxtDisplayClearTextLine(3);
    nxtDisplayClearTextLine(4);
    nxtDisplayTextLine(3, "Force:  %4d", _force);
    wait1Msec(50);
  }
}

Then you will see the line (extracted below). That's how you read the sensor.
Code:
    _force = HTFreadSensor(HTFORCE);


Thu Nov 29, 2012 4:41 pm
Profile
Rookie

Joined: Thu Nov 29, 2012 2:16 pm
Posts: 3
Post Re: Sensor Multiplexer
MHTS wrote:
If you look at Xander's sample code, excerpt below:
Code:
task main() {
  int _force = 0;

  nNxtButtonTask  = -2;

  eraseDisplay();
  nxtDisplayCenteredTextLine(0, "HiTechnic");
  nxtDisplayCenteredBigTextLine(1, "Force");
  nxtDisplayCenteredTextLine(3, "SMUX Test");
  nxtDisplayCenteredTextLine(5, "Connect SMUX to");
  nxtDisplayCenteredTextLine(6, "S1 and sensor to");
  nxtDisplayCenteredTextLine(7, "SMUX Port 1");
  wait1Msec(2000);

  while(true) {
    // Read the sensor value
    _force = HTFreadSensor(HTFORCE);

    nxtDisplayClearTextLine(3);
    nxtDisplayClearTextLine(4);
    nxtDisplayTextLine(3, "Force:  %4d", _force);
    wait1Msec(50);
  }
}

Then you will see the line (extracted below). That's how you read the sensor.
Code:
    _force = HTFreadSensor(HTFORCE);


ah. great, thanks. still learning the ropes


Fri Nov 30, 2012 12:34 am
Profile
Rookie

Joined: Mon Feb 10, 2014 1:01 pm
Posts: 1
Post Re: Sensor Multiplexer
I feel this may need to be updated somewhat. I cannot find the Xander's Driver file, only the RobotC drivers file versions.


Mon Feb 10, 2014 1:03 pm
Profile
Moderator
Moderator
User avatar

Joined: Wed Mar 05, 2008 8:14 am
Posts: 3227
Location: Rotterdam, The Netherlands
Post Re: Sensor Multiplexer
This is current information. You can download the latest driver files from here: https://github.com/botbench/rdpartyrobotcdr. Info on how to do this can be found here: http://botbench.com/blog/2013/12/13/rob ... ow-on-git/

= 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]


Sat Feb 15, 2014 1:01 am
Profile WWW
Display posts from previous:  Sort by  
Reply to topic   [ 10 posts ] 

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.