Page 1 of 1

HMC6352 Problem

PostPosted: Sat Jun 12, 2010 6:17 pm
by jony john
hi all..i'm new in PIC..
i have place compass sensor HMC6352 in my project..
the problem is i don't know the sensor is still ok or not bcause while solder the 4 pin the temperature is about 250-300 Celsius..then when i download the program and the result is nothing happen..

my program:
CODE: SELECT_ALL_CODE
#include <16F877A.H>
#fuses HS, NOWDT, NOPROTECT, BROWNOUT, PUT, NOLVP
#use delay(clock=20000000)
#use i2c(Master, sda=PIN_C4, scl=PIN_C3, FORCE_HW)
#include <lcd_module.c>
#define HMC6352_I2C_WRITE_ADDRESS 0x42
#define HMC6352_I2C_READ_ADDRESS 0x43
#define HMC6352_GET_DATA_COMMAND 0x41
int16 heading;
void setup()
{
lcd_init();
}

int16 HMC6352_read_heading(void);
void clearLCD();
//===================================
void main()
{
setup();
clearLCD();
while(1)
{

//heading = HMC6352_read_heading();
//heading=heading/100;
//lcd_gotoxy(1,1);
printf(lcd_putc, "heading");
lcd_gotoxy(1,2);
printf(lcd_putc,"%lu", heading);
delay_ms(1000); }

}
//==================================
int16 HMC6352_read_heading(void)
{
int8 lsb;
int8 msb;

i2c_start();
i2c_write(HMC6352_I2C_WRITE_ADDRESS);
i2c_write(HMC6352_GET_DATA_COMMAND);
i2c_stop();

delay_ms(7);

i2c_start();
i2c_write(HMC6352_I2C_READ_ADDRESS);
msb = i2c_read();
lsb = i2c_read(0);
i2c_stop();

return((int16)lsb | ((int16)msb << 8 )) ;
}

//==================================================
void clearLCD()
{
printf(lcd_putc, "\f");
delay_ms(100);
}


i don't know neither the sensor or program is not function..

Re: HMC6352 Problem

PostPosted: Tue Jun 15, 2010 10:19 am
by shiyan
Most probably is your code :lol:

Sorry, I don like to check code.

Re: HMC6352 Problem

PostPosted: Tue Jun 15, 2010 2:52 pm
by ober
Please use the proper method to share your code if you really need to share it.

I don think is the soldering that cause the problem as you the pin you solder is at the breakout board, not the compass module itself. It should not cause major damage, except that your soldering is not good, the connection is not good enough causing the communication between PIC and compass module to fail, and hence nothing work.

Again, can you minimize the scope of the troubleshooting area by checking which part is functioning and which is not?
1. Check LCD first.
2. Check the I2C communication with compass module, if the hardware and other settings are correct, it will at least send back ACK when address is being send out by master.
3. Keep on going step by step.

Re: HMC6352 Problem

PostPosted: Tue Jun 15, 2010 2:53 pm
by sich
jony john WROTE:the problem is i don't know the sensor is still ok or not bcause while solder the 4 pin the temperature is about 250-300 Celsius..then when i download the program and the result is nothing happen..

Why did you read the temperature while soldering? And...what does it mean anyway?

Re: HMC6352 Problem

PostPosted: Wed Jun 16, 2010 3:02 pm
by jony john
thanks for all,,
my sensor is work properly..

regard:
JJ

Re: HMC6352 Problem

PostPosted: Tue Nov 23, 2010 10:00 pm
by ccperng
Sorry, actually the problem still exist. I juz went to lab and observe the waveform with the oscilloscope.
I am not getting the ACK from the sensor after i send the 0x42 slave address to it.

This is the portion of codes that I am using. I am using C#.
CODE: SELECT_ALL_CODE
 I2CDevice.Configuration myDeviceConfiguration;
        I2CDevice myCompass;
        I2CDevice.I2CTransaction[] myI2Command = new I2CDevice.I2CTransaction[2];
 
        byte[] myReadBuffer = new byte[2];
        int myBytesTransmitted = 0;
 
        // this constructor assumes the default factory Slave Address of 0x42
 
        public HMC6352Compass()
        {
            myDeviceConfiguration = new I2CDevice.Configuration(0x21, 100);
            myCompass = new I2CDevice(myDeviceConfiguration);
        }

Re: HMC6352 Problem

PostPosted: Wed Nov 24, 2010 10:04 am
by ober
Any root cause? It will be good if you could share the reason for the failure, let us know and learn .

Re: HMC6352 Problem

PostPosted: Thu Nov 25, 2010 2:24 pm
by ccperng
Any1 can help regarding this matter ah??