NXT Compass

D396

Senior Member
I have a mindstorms nxt compass that I am trying to interface to my picaxe(18x) but when I do I get random values that dont change when I turn it. I have verified the wireing is correct. It was working at one point but now it is not. Did I fry it? I am using the example code provided with PE. Any Ideas. Thanks.
 

hippy

Technical Support
Staff member
It was working at one point but now it is not. Did I fry it? I am using the example code provided with PE. Any Ideas. Thanks.
If it was working and now isn't then something has gone wrong or changed, perhaps you have fried it but it could be something else. The supplied example code is written for the 20X2 so perhaps post your full circuit and the code you have modified for use with the 18X.

Have you tested if the 18X works with other I2C devices ?
 

D396

Senior Member
Here is the code
Code:
' Hitechnic NXT Compass Sensor (part MS1034)

symbol heading_2degree = b0
symbol heading_adder = b1
symbol heading = w1	

' Wires on NXT jack plug.
' Wire colours may vary. Pin 1 is always end nearest latch.
' 1 White	No connect
' 2 Black	0V
' 3 Red	0V
' 4 Green	V+ (4.5V or 5V)
' 5 Yellow	SCL
' 6 Blue	SDA
' Do not use i2c pullup resistor - already provided within sensor.


init:

	'Slave address is $02
	hi2csetup i2cmaster $02, i2cslow, i2cbyte

	'Optional configuration
	hi2cout $41,($00)		; normal mode
	'hi2cout $41,($43)	; hard iron calibrate mode
	pause 100

main:
	; read values
	hi2cin $42,(heading_2degree)	', heading_adder
	
	heading = heading_2degree * 2 '+ heading_adder
		
	; debug display
	debug
	; wait 1 second then loop
	pause 1000
	goto main
Ill post the circuit in a minute.
 

hippy

Technical Support
Staff member
Circuit. It does work with other I2C devices.
A proper schematic would help, or at least remove wires and components which don't connect to anything or aren't used. The problem with photos is that they don't show everything; power supply, reset pull-up.

What power supply are you using ? If batteries it may be worthwhile trying with a fresh set.
 

D396

Senior Member
Never mind. My camera refues to take more pictures. I have It wired up like it says though.
 
Top