View unanswered posts | View active topics It is currently Fri Oct 31, 2014 3:25 pm






Reply to topic  [ 7 posts ] 
SMUX Help 
Author Message
Rookie

Joined: Wed Feb 29, 2012 2:56 pm
Posts: 10
Post SMUX Help
I've been using the SMUX drivers made by Xander Soldaat, but I can't figure out the code. I read through his tutorial and I now know a lot about how the SMUX works, but he never says what the actual code for using it is. I looked at his example programs and couldn't find what I needed. I simply need to know how include a sensor on the SMUX as a sensor in an 'if' condition. Thanks!


Tue Nov 20, 2012 4:24 pm
Profile
Guru
User avatar

Joined: Sun Nov 15, 2009 5:46 am
Posts: 1347
Post Re: SMUX Help
Xander's sample code for the sensors on the SMUX is pretty self explanatory. What kind of sensors are you putting on the SMUX? Each of the sensor drivers has specific functions to access the reading of the sensor. For example, if you plugged a gyro into the SMUX, then take a look at hitechnic-gyro-SMUX-test1.c. You will see the code calling the function:
Code:
HTGYROreadRot(HTGYRO)

That's how you access it. To enable a gyro to use SMUX, you need to include the SMUX driver. Then you need to define the SMUX port number.
Code:
#include "..\RobotCDrivers\drivers\hitechnic-sensormux.h"
#define gyroSensor       msensor_S4_1

Of course your include path may be different from the above. And also adjust your SMUX port number as appropriate.


Tue Nov 20, 2012 5:18 pm
Profile
Rookie

Joined: Wed Feb 29, 2012 2:56 pm
Posts: 10
Post Re: SMUX Help
OK, I have it down now. Thanks!
If you don't mind answering one more question, the readings are a little off. I had to set my threshold at 90 to make it respond, even though I was holding it right up to a light and then completely covering the sensor. I read something about calibration issues with the SMUX. Any advice on fixing that?


Tue Nov 20, 2012 7:36 pm
Profile
Guru
User avatar

Joined: Sun Nov 15, 2009 5:46 am
Posts: 1347
Post Re: SMUX Help
You haven't really told me what sensor you are trying to read but I am guessing the LEGO light sensor from what you said. How do you declare the sensor type and how do you read the sensor value? There are several ways to read the sensor value. Take a look at Xander's sample code Lego-light-SMUX-test1.c. In fact, why don't you compile Xander's sample program to test your light sensor and see if it gives you reasonable readings. If it does, then compare how you read the sensor to how Xander reads the sensor. Xander's light sensor driver provides the function LSvalRaw or LSvalNorm to read the values. His code takes care of if the sensor is on an SMUX or directly hooked to the NXT sensor port and set the correct sensor type. It will also provide functions you can call to set the low and high threshold so that LSvalNorm will normalize the value (scale the raw value to a range of 0 to 100 with 0 equals to the low raw value and 100 equals to the high raw value).


Tue Nov 20, 2012 9:40 pm
Profile
Rookie

Joined: Wed Feb 29, 2012 2:56 pm
Posts: 10
Post Re: SMUX Help
Yes, I'm using the light sensor. Should've mentioned that. I did run Lego-light-SMUX-test1.c and I'm getting odd readings. The values (both raw and normal) are lower when closer to light, higher when farther away, but lower again when I completely cover the sensor. The same applies regardless of whether the sensor is in active or passive mode. It reads fine when it is plugged directly into the NXT.


Wed Nov 21, 2012 12:03 am
Profile
Online
Moderator
Moderator
User avatar

Joined: Wed Mar 05, 2008 8:14 am
Posts: 3240
Location: Rotterdam, The Netherlands
Post Re: SMUX Help
There are currently issues with casting ubytes in ROBOTC 3.54, you should consider using 3.55 beta, which is available here: viewtopic.php?f=52&t=5122

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


Wed Nov 21, 2012 12:37 am
Profile WWW
Rookie

Joined: Wed Feb 29, 2012 2:56 pm
Posts: 10
Post Re: SMUX Help
Will do. Thanks!


Wed Nov 21, 2012 10:47 am
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 7 posts ] 

Who is online

Users browsing this forum: mightor 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.