I’m also using the LSM303DLH, it’s being controlled by a PIC18F46K22 on 3v.
The accelero is working perfectly but it seems like the magneto is not updating it’s axes. I thought the problem was the continues mode or not reading all 6bytes in the same i2c transmission. But I does not seem to work whatever i do.
Help!
[code]void magneto_init()
{
// setup magnetometer
i2c_start();
/*
i2c_writeSlaveAddress(SLAVE_ADDRESS_M, I2C_WRITE);
i2c_writeData(CRA_REG_M);
i2c_writeData(0b00010100); // set data output rate to 30Hz
i2c_restart();*/
i2c_writeSlaveAddress(SLAVE_ADDRESS_M, I2C_WRITE);
i2c_writeData(MR_REG_M);
i2c_writeData(0b00000000); // go from sleep mode to continuous mode
/*
i2c_restart();
i2c_writeSlaveAddress(SLAVE_ADDRESS_M, I2C_WRITE);
i2c_writeData(CRB_REG_M);
i2c_writeData(0b00000000);
i2c_restart();
i2c_writeSlaveAddress(SLAVE_ADDRESS_M, I2C_WRITE);
i2c_writeData(SR_REG_M);
i2c_writeData(0b00000100); // the 1 means internal voltage regulator enabled
*/
i2c_stop();
Hello,
Thanks for your help.
I using OR-AVR-M128-S controller and OR-USB-UART for my robots (in Russian). Programming language - jscript + hta.
I solved the problem. The problem in low voltage ~ 1,6v. Voltage 4,5v solve the problem.
Thank you.
TeHuster i think problem in line:
i2c_writeData(OUT_X_H_M||0b10000000); // OUT_X_H_M with MSb 1 for stream
try:
i2c_writeData(0x03); // the register is autoincremented after each read
Page 26 documentation (Magnetic signal interface reading/writing):
To minimize the communication between the master and magnetic digital interface of the
LSM303DLH, the address pointer is updated automatically without master intervention.