Download Print this page

Parallax 27911 Manual page 4

Gyroscope module kickstart

Advertisement

GOSUB I2C_Write_Reg
' Set up "block data update" mode
I2C_REG = CTRL_REG4
I2C_VAL = $80
GOSUB I2C_Write_Reg
' Send the get continuous output command
I2C_REG = CTRL_REG1
I2C_VAL = $1F
GOSUB I2C_Write_Reg
DO
GOSUB Gyro_Get_Raw
' Divide X Y Z, by 114 to reduce noise
IF (X.BIT15) THEN
X = (ABS X) / 114
X = -X
ELSE
X = X / 114
ENDIF
IF (Y.BIT15) THEN
Y = (ABS Y) / 114
Y = -Y
ELSE
Y = Y / 114
ENDIF
IF (Z.BIT15) THEN
Z = (ABS Z) / 114
Z = -Z
ELSE
Z = Z / 114
ENDIF
DEBUG HOME, "RAW X = ",11, SDEC X, CR
DEBUG "RAW Y = ",11, SDEC Y, CR
DEBUG "RAW Z = ",11, SDEC Z, CR
PAUSE 250
LOOP
Gyro_Get_Raw:
GOSUB Wait_For_Data_Ready
GOSUB I2C_Start
I2C_DATA = WRITE_DATA
GOSUB I2C_Write
I2C_DATA = OUT_X_INC
GOSUB I2C_Write
GOSUB I2C_Stop
GOSUB I2C_Start
I2C_DATA = READ_DATA
Copyright © Parallax Inc.
' Get XYZ data
' Display data
' Read the data starting
'
at pointer register
Page 4 of 12

Advertisement

loading
Need help?

Need help?

Do you have a question about the 27911 and is the answer not in the manual?