| Author |
Message |
|
arhtech
Rookie
Joined: Wed Feb 29, 2012 2:56 pm Posts: 10
|
 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 |
|
 |
|
MHTS
Guru
Joined: Sun Nov 15, 2009 5:46 am Posts: 1023
|
 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: 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. 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 |
|
 |
|
arhtech
Rookie
Joined: Wed Feb 29, 2012 2:56 pm Posts: 10
|
 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 |
|
 |
|
MHTS
Guru
Joined: Sun Nov 15, 2009 5:46 am Posts: 1023
|
 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 |
|
 |
|
arhtech
Rookie
Joined: Wed Feb 29, 2012 2:56 pm Posts: 10
|
 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 |
|
 |
|
mightor
Moderator
Joined: Wed Mar 05, 2008 8:14 am Posts: 2906 Location: Rotterdam, The Netherlands
|
 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
_________________| Some people, when confronted with a problem, think, "I know, I'll use threads," | and then two they hav erpoblesms. (@nedbat)| My Blog: I'd Rather Be Building Robots| ROBOTC 3rd Party Driver Suite: [ Project Page]
|
| Wed Nov 21, 2012 12:37 am |
|
 |
|
arhtech
Rookie
Joined: Wed Feb 29, 2012 2:56 pm Posts: 10
|
 Re: SMUX Help
Will do. Thanks!
|
| Wed Nov 21, 2012 10:47 am |
|
|