Welcome, Guest. Please Login.
Surveyor Corporation Surveyor SRV-1
Home Help Search Login

Surveyor Robotics Forum

Welcome to the user support forum for Surveyor SRV-1 robots, SRV-1 robot controllers and SVS stereo vision systems. To register for this forum, please send an email to support@surveyor.com which includes your desired forum user name, your registration email address, and a brief explanation of why you wish to join, and we will create a forum account for you.

Please note that there is a Search button in the forum toolbar for forum topics. Another effective search method for the entire surveyor.com site is to use Google, e.g. "xyz site://www.surveyor.com" where "xyz" is the search topic.



Pages: 1
Send Topic Print
i2c compass from HiTechnic (Read 1541 times)
avardy
YaBB Newbies
*




Posts: 12
i2c compass from HiTechnic
03/02/12 at 7:49am
 
I am trying to integrate the HiTechnic compass which was designed for the Lego NXT kit:
 
http://www.hitechnic.com/cgi-bin/commerce.cgi?preadd=action&key=NMC1034
 
The communication with this device is I2C and the voltage levels appear to be compatible with the SRV-1's 3.3V power and logic levels.  I don't fully understand I2C but it appears that devices come with their own default address.  The address for this compass appears to be 0x02.  I have tried reading from it using the picoC command readi2c(0x02, 0x42), but the command seems to hang.  Using the standard SRV-1 protocol command 'irab' doesn't seem to work either because the address 0x02 does not map onto a standard ASCII character.
 
I have seen some posts about re-mapping I2C addresses, but I am unclear how this is done or even if that is what I need to do.  Any tips or advice would be appreciated!
 
Andrew
Back to top
 
 
Email   IP Logged
tjump
Global Moderator
*****




Posts: 411
Re: i2c compass from HiTechnic
Reply #1 - 03/02/12 at 12:10pm
 
I'm guessing that when you think picoC hangs it is not really hanging, you just never exit picoC. When you write picoC code you must include an exit(); function or the SRV will never regain control from picoC.
 
Now, depending on which firmware version you are using, the exit function may or may not need a value inside the parenthesis. So, you will either need:
 
exit():
 
or
 
exit(0);
 
Let's start with this and see if we get beyond your hanging issue and then talk about the need for a printf statement to verify returns from the sensor.
 
 
T. Jump
Back to top
 
 
  IP Logged
avardy
YaBB Newbies
*




Posts: 12
Re: i2c compass from HiTechnic
Reply #2 - 03/03/12 at 7:16am
 
Thanks very much for the reply!  Here is the program I am executing:
 
int low;
for (int i=0; i<10; i++) {
    printf("i: %d\n", i);
    if (i >= 5) {
       low = readi2c(0x02, 0x42);
//        printf("low: %d\n", low);
       printf("Read something\n");
    }
    delay(500);
}
 
printf("battery status: %d\n", battery());
exit(0);
 
The purpose of the outer loop is to show that we have some output produced to the console prior to calling 'readi2c'.  Here is the output:
 
i: 2
i: 3
i: 4
i: 5
 
I have no idea why I never see "i: 1" but that seems to be a consistent issue, perhaps related to my own Java program for talking to the SRV-1.  The main point is that there is no response to 'readi2c'.  If I comment out the 'readi2c' line then things proceed as expected.
 
Things I've tried:
 
- I tried using another I2C device (with a different address) and still cannot get a response.  I am using the address of 0x02 as this is reported online as the I2C address of this compass.  From what I can tell, it does not conflict with the I2C address map of the SRV-1.  However, there seems to be some wierdness around these addresses that I don't understand.
 
- I made an attempt to talk to the camera via I2C, but this also didn't work out  (I tried this with and without the compass, and tried talking to the compass with and without the camera).  
 
-I have re-checked my wiring...  I have pin 14 on the header connected to the device's SCL line and pin 15 connected to SDA.  The compass expects 4.3V power (from the Lego NXT) while I am only supplying 3.3V from the SRV-1.  However, I have a very knowledgable colleague who reverse engineered the compass and tells me that all of the logic on-board is actually 3.3V.
 
Any information on the SRV-1 addressing system would be appreciated!  Or perhaps suggestions of things to try in order to isolate the problem.
Back to top
 
 
Email   IP Logged
tjump
Global Moderator
*****




Posts: 411
Re: i2c compass from HiTechnic
Reply #3 - 03/03/12 at 4:21pm
 
Do you have the SCL and SDA lines crossed?
 
Do you have a common ground from the device to the SRV?
 
Are you supplying correct V+ to the device?
 
Does the V+ you supply to the device output the correct V+ needed for the i2c network of the SRV?  
 
T. Jump
Back to top
 
 
  IP Logged
Pages: 1
Send Topic Print