Shop OBEX P1 Docs P2 Docs Learn Events
I2c hmc5843 — Parallax Forums

I2c hmc5843

electric550electric550 Posts: 122
edited 2009-08-28 06:20 in Propeller 1
Hello I am new to I2C I am planning on ordering the HMC5843. I am planning on attempting to run the device in parallel with the EEProm using 10k pullups due to lack of IO pins. I was wondering if anyone has used this device or if anyone has any suggestions on this topic. I am a bit confused as to how the addressing works, for the chips and I am not sure if they would be compatible on the same bus or how to begin to set them up. Anyways if anyone has some suggestions I would greatly appreciate the help. Thanks!

Comments

  • electric550electric550 Posts: 122
    edited 2009-05-25 20:23
    I am also concerned that I have no way of setting up the devices on boot up. So the prop does its own thing on boot up before any program has a chance to setup the device addresses. I am not sure how that works or if it would allow for both of the devices. Anyways thanks again!
  • Mike GreenMike Green Posts: 23,101
    edited 2009-05-25 20:49
    I2C devices are required to "behave themselves". They have to have some kind of address, either fixed internally or set by device select pins. Your HMC5843 has a device address ($3C?) as described in its datasheet which you will have to become familiar with. I2C addresses are set up for the kind of situation you describe where there might be some EEPROMs and some other I2C devices, all on the same I/O bus pins and everything is supposed to work. The boot EEPROM will always have the address $A0.

    The Demo Board and some other Propeller development boards has a pullup resistor on SDA, but not SCL. You may need to use a pullup resistor to Vdd on both lines. The HMC5843 has an optional built-in pullup which you can use for SCL. It turns out that the Protoboard has both pullups already connected.
  • electric550electric550 Posts: 122
    edited 2009-05-25 21:40
    Well that is good news. I assume you mean $3C from the bottom of page 18 from the example sending 3 bytes? I noticed the identification registers on 16 and 17. They seem to have different default values than the example but I don't know if those are the same registers. I noticed that there is the Basic_I2C_Driver on OBEX, I might have to see if that can at least be a basis for some code that would work with this. Anyways thanks again for the Help.
  • TimmooreTimmoore Posts: 1,031
    edited 2009-05-25 21:49
    I haven't used the HMC5843 but I have used the HMC6343. That needed slave clock stretching support that the Basic_I2C_driver doesn't support. I found without that support the first value read correctly but then I wouldn't get consistent values read. Putting a logic analyser on it shows what is happening - the HMC6343 pulls the clock low after the device address is written, this means when the propeller is writing the register to read outm, the hmc6343 wasn't ready to read it. I would expect that this device will need the same support.
  • electric550electric550 Posts: 122
    edited 2009-05-25 22:37
    Yes the protocols look similar. I was looking at the HMC6343...it is pretty expensive. How is the resolution on it. I think I was disappointed in the documentation of that sensor for the price. It looks like the mag and accel data can be extracted but some details on the accel are left out. How do you like it? Have you gotten raw mag and accel out of it? How accurate is it? Thanks for the info!
  • TimmooreTimmoore Posts: 1,031
    edited 2009-05-25 23:22
    Yes, the docs for the hmc6343 are bad. I have found it works without problem though there are a couple of people on this forum who have had problems with it.
    I have it currently running alongside a lis3lv02dl accelometer and a cmps03 compass and have been cross-checking the results and they are similar - the compass heading for both flat matches (with an offset due to the way I mounted them). The accelometer values track - though it doesn't doc the acc ranges I have heard is +-1G, when I double the hmc6343 values it tracks the lis3lv02dl values.
    The raw mag values are meant to be +-1Gauss though I haven't tried checking it, but I can read them ok.
    It is pretty sensitive to mag fields - I have a servo about 4" way and it detects it - the heading of both the hmc6343 and cmp03 vary about +-0.5 degrees depending on what the servos doing. I haven't tried more powerfull mag fields though. Also I have found both the hmc6343 and cmp03 vary by that much just on 1 read to the next without the servos running - I haven't played with the filters - they are at default values. Without the servo the varation looks pretty much random, with teh servos it tracks the servo movement (its a pan/tilt system).
    Not totally convinced its worth the extra money over a non-tilt compensated compass and some software effort with a separate accelometer but it does work without problem (as long as you have clock stretching, the original basic_i2c_driver gives crazy results and I tried another computer whos I2C implementation doesn't support clock stretching and it also gave crazy results).
  • electric550electric550 Posts: 122
    edited 2009-05-26 01:23
    Well that clock issue is odd. I guess I I will have a look at it when it gets here thanks for the heads up. I think I am just going to stick with the HMC 5843 and hope that it is pretty accurate. I am also hoping that it will work in parallel with the EEProm. I am going to end up using 4 10k resistors for pull ups two on the EEProm and 2 on the HMC5843.
  • TimmooreTimmoore Posts: 1,031
    edited 2009-05-26 01:29
    You only need 1 set of pull-ups per bus and you want to check the board you are using, it may already have the pull-ups. e.g. the proto board already has them.
    Let me know when it arrives and I can send you my version of basic_i2c_drover that supports clock stretching.
    Multiple devices on 1 I2C bus, shouldn't be a problem - the current board I am working on have 14 I2C devices - 12 (include eeprom) on the booteeprom bus. The only reason the other 2 are on a different I2C bus is 1 has the same address as the eeprom and is not changable.
  • electric550electric550 Posts: 122
    edited 2009-05-26 02:12
    wow that sounds pretty complicated. The addressing of I2C is pretty interesting. Yea I would love to see the code, I will let you know when it gets here. I am making my own board so I am putting the resistors in myself. Thanks for the heads up I was not paying attention about the resistors two per bus is all that is needed thank you...two less parts. yes.
  • mmsyammsya Posts: 1
    edited 2009-08-28 06:20
    Hi all,

    I am using the hmc5843 and do not know how to set/reset the hmc5843. Any help please?

    Thanks,
    John.
Sign In or Register to comment.