Sunday, December 6, 2009

HiTechnic Sensor Multiplexer Review Part 2

I spent the weekend messing around with programming the SMUX in RobotC. It was pretty intimidating at first, but after I found the sample programs and the drivers found on the HiTechnic web site, it was just a matter of spending some time staring at the code.

The first thing I found was Xander Soldaat’s “HTSMUX-Tutorial-LATEST.pdf” file found linked on the HiTechnic site. Reading this file actually scared me because it gets into the internals of the SMUX. This document does little more than confuse the lightweight programmer, but if you are a heavyweight, this document is for you. I am not a programmer, so I just look for the easiest way to use the code and hardware.

Then I downloaded the RobotC Drivers and Examples found on the HiTechnic downloads page. I spent some time looking at the SMUX examples and felt a heavy relief. All of the hard core programming has been set up in drivers, and the sample programs do a great job of showing how to access and use the drivers. Xander has done a great job of making the sample programs easy to understand. All of the programs are very similar, so switching back and forth for different sensors is pretty easy once you figure out his methods.  There is also a great video showing how to set up the drivers so they can be easily accessed within your RobotC programming environment.

The only real problem that I encountered was some of the timing issues. I hooked up four sensors; an acceleration sensor, an ultrasonic sensor, a sound sensor, and a light sensor. I put them all in a loop and took readings from all of them every 50ms and had great success. The problem that I encountered was initializing a couple of the sensors. I tried to set the light sensor in both Active and Inactive modes (light on and light off). I found that I had to put a 200ms WAIT statement after changing the mode. If I didn’t do that, the light wouldn’t respond and the previous mode would be used. No big deal, but it took some work to figure it out. The sound sensor has a mode selection of dB and dBA. Knowing that the light sensor had an issue, I assumed that the sound sensor would be similar and I added the same 200ms WAIT statement.

UPDATE: I discovered that this problem is an issue that currently exists in RobotC 2.0 and not with the SMUX and drivers.  I found that I was modifying the code, but new program was not being properly downloaded, thus the Light sensor was not getting the updated program to toggle the light on the sensor.  Xander has been gracious enough to work with me to identify the problem. 

RobotC has issued the following statement on the subject:
There is one primary known issue that we are working on, involving the "Compile and Download" command. The issue seems to be caused by ROBOTC incrementally downloading the program to the NXT and a memory issue on the PC-side where it is not recognizing changes in the program. We're close to a fix and an updated release - but in the mean time, try a suggested work around:

1. Open or modify your program inside of ROBOTC.
2. Save your program by going to "File - Save" (or use ctrl-S keyboard shortcut)
3. Go to "Robot - Compile Program" (or the F7 keyboard shortcut) - This step forces ROBOTC to regenerate the code from scratch.
4. Now go to "Robot - Compile and Download" (or the F5 keyboard shortcut) to download your program to the NXT.
5. Repeat these steps whenever you make modifications to your code.
HiTechnic has not released NXT-G blocks yet, and I look forward to seeing how they work. I hope it will give me even more insight that I can carry over to RobotC.

None of the legacy sensors are supported on the SMUX.  The HiTechnic IRLink is not supported because you cannot send commands though the SMUX, but that is not necessarily a bad thing since you still have three other ports available.

In an earlier post, I mentioned that there is an indicator light on the battery box. I was wrong. There are actually two indicator lights and they are actually on the SMUX. The green indicator shows that the battery box on/off switch is on and the red light shows that the NXT is turned on and connected. The SMUX will not operate unless both lights are on. Both lights turn off when the NXT is powered down. It’s actually a pretty handy feature.

Overall, I like the HiTechnic SMUX. I would recommend it, at least if you are a RobotC user.

No comments:

Post a Comment