Menu

Initializing a parrallax compass

Help
2015-07-30
2015-10-11
1 2 3 4 > >> (Page 1 of 4)
  • Edward LaBudde

    Edward LaBudde - 2015-07-30

    I have a project that needs a compass. It uses I2C to communicate how do I do this? setup the module for continues output mode by writing (0x3C) 0x00 to the MODE register (0x02).

     
  • Anobium

    Anobium - 2015-07-30

    Attach the datasheet, I can then advise.

    I2C is relatively easy. Are you planning to use Hardware I2C or Software I2C? or both?
    Do you know the speed of the I2C bus? A URL to product may help me also.

    Anobium

     

    Last edit: Anobium 2015-07-30
  • Edward LaBudde

    Edward LaBudde - 2015-07-30

    Anobium, Here are all I have found. Planning s/w I2C. Thanks, Ed.

     
  • Edward LaBudde

    Edward LaBudde - 2015-07-30

    For got this

     
  • Anobium

    Anobium - 2015-07-31

    Thank you. We have a driver for this device. Please update to the latest driver here, DOWNLOAD HERE. Please place this file in your GCB 'include' folder.

    I also just published a demonstration file to the code respository, DOWNLOAD HERE. The demonstration shows a simple read of the threee axis on a serial terminal - you can change this to any display type of course. I wrote this last year for someone and this covers the primitives of initialsation and read only. If you can improve the driver and the demonstration please let us have the file back others to use.

    If you have any issues with these files do not hesitate to ask - as I never got any formal feedback on the driver last year if ok, or not.

    Since last year we have added all the maths functions you will be needing like TAN, SIN etc. Look at the Help File for examples etc.

    Let us know how you get on.

    Anobium

     
  • Edward LaBudde

    Edward LaBudde - 2015-07-31

    Anobium, you guys are very smart. I will give you feedback in a few months when I work on it. Thanks, Ed.

     
  • Edward LaBudde

    Edward LaBudde - 2015-09-03

    Hi all, tried out the driver ran into some problems. First had to remove the locate command. Second had to change HI2c to I2C and add the I2cStart commad to get it to work. Problem is allways return FF for the high or low bit. What am I doing wrong

     
  • Anobium

    Anobium - 2015-09-03

    OK here goes. I am truly flying a little blind and I do have your device.

    But, I need you to download the driver again, see here. Place in your include directory.

    Then, try this code attached.
    I have made a few changes.

    You need to check a few things.
    1. Why the ocstune? I am just wondering.
    2. Check the address of the device. It is can be different. If so, change in the program - I had added the #define for you.
    3. The example I provided used hardware I2C and you are using software I2C - you were not setting up properly. You will lots of information in the help file.
    4. I did remove all the CALLs. They, are not requried.
    5. I removed the I2CStart. This is not required.

    I think the main issues were - i2c was probably not setup correctly but more importantly I think the init of the compass was happening before the init of i2c.... this was incorrect in the .h file - I could not test.... all theory. :-)

    Let us know the results.

     
  • Edward LaBudde

    Edward LaBudde - 2015-09-03

    Ocstune to trim frequency to be exact. How do I check the device address?
    With the changes it now reads 00, what next? Thanks, Ed.

     
  • Anobium

    Anobium - 2015-09-03

    If you cannot determine the address from the datasheet or the device I recommend you use the I2CDiscoveryRoutines to determine this device address. This will also validate your configuration and the pullup resistors are all ok.

    Look in the \GCB@Syn\GreatCowBasic\Demos\I2C Solutions\I2C Discovery folder for the a software discovery demo. Take a copy and move to another folder. Then, edit and get this work via your LCD. When we have validated the I2C address then we can move back to the sensor.

    Make sense?

     
  • Edward LaBudde

    Edward LaBudde - 2015-09-03

    Datasheet says 0x3d is read 0x3c is write. Used 0x3d still gets 00. Wj\hat next? Thanks, Ed.

     
  • Anobium

    Anobium - 2015-09-03

    I would get i2c discovery working. This will validate the connectivity.

    Do you have the correct pull-up resistors? Lines crossed? Discovery will help determine connectivity.

    I know the i2cdiscovery works - I can validate this here. Once you can see the device using the discovery code then we can be confident that we have comms.

     
  • Edward LaBudde

    Edward LaBudde - 2015-09-03

    I tried low byte it is FF high is 00.

     
  • Anobium

    Anobium - 2015-09-03

    OK. What others tool do you have? How did you determine the FF?

     
  • Edward LaBudde

    Edward LaBudde - 2015-09-03

    High modified discover see attach get these errors
    ompiled.asm:387:Error [113] Symbol not previously defined (TRISC).
    compiled.asm:395:Error [113] Symbol not previously defined (TRISC).
    compiled.asm:398:Error [113] Symbol not previously defined (TRISC).
    compiled.asm:403:Error [113] Symbol not previously defined (TRISC).
    compiled.asm:408:Error [113] Symbol not previously defined (TRISC).
    compiled.asm:419:Error [113] Symbol not previously defined (TRISC).
    compiled.asm:421:Error [113] Symbol not previously defined (TRISC).
    compiled.asm:441:Error [113] Symbol not previously defined (TRISC).
    compiled.asm:444:Error [113] Symbol not previously defined (TRISC).
    compiled.asm:454:Error [113] Symbol not previously defined (TRISC).
    compiled.asm:455:Error [113] Symbol not previously defined (TRISC).
    compiled.asm:457:Error [113] Symbol not previously defined (TRISC).
    compiled.asm:460:Error [113] Symbol not previously defined (TRISC).
    compiled.asm:467:Error [113] Symbol not previously defined (TRISC).
    compiled.asm:469:Error [113] Symbol not previously defined (TRISC).
    compiled.asm:472:Error [113] Symbol not previously defined (TRISC).
    compiled.asm:474:Error [113] Symbol not previously defined (TRISC).
    compiled.asm:481:Error [113] Symbol not previously defined (TRISC).
    compiled.asm:482:Error [113] Symbol not previously defined (TRISC).

     
  • Anobium

    Anobium - 2015-09-03

    Did you change the ports? I thought you were using portb.

     
  • Edward LaBudde

    Edward LaBudde - 2015-09-03

    You are right now OK but nothing but Jibberish on LCD can not determine any address Any Ideas?

     
  • Anobium

    Anobium - 2015-09-03

    Edit the source please. Edit out the extra HSerPrintCRLF on line 63.
    Is the LCD showing 'Software I2C Device Search'? If not, we need that working first.

     
  • Edward LaBudde

    Edward LaBudde - 2015-09-03

    Ok I get message s/w search. Having probelms with the LCD. getting late will resume tomorrow AM

     
  • Edward LaBudde

    Edward LaBudde - 2015-09-04

    Hi I give up. I do not uderstand why we should doubt the datasheet address. Has anyone got your code to work with a real device or am I the first one

     
  • Anobium

    Anobium - 2015-09-04

    The driver was provided by a conributor. I validated the code prior to inclusion in the release.

    Can you describe you circuit? A diagram would be best. Show resistors and any key device dependent passive devices.

    I still recommend getting the discover code working as this will ensure you connectivity circuit is correct. The discovery code scans the bus and find any device on the bus - if it does not find the device then the issue may be elsewhere.

    Can you let me know what version of GCB you are using? We have resolved a lot of issues with the I2C protocol.

     
  • Edward LaBudde

    Edward LaBudde - 2015-09-04

    Verion Great Cow BASIC (0.9 22/9/2013) No passive parts just 16F88 chip and compass module wired as per datasheet.

     
  • Anobium

    Anobium - 2015-09-04

    You must upgrade. I2C that old will not work as expected.

    You are correct this module is equipped with 4.7 kΩ pull-up resistors on the SDA line and a 2.2K resistor on the SCL line. There is no need for any external hardware to operate.

     
  • Edward LaBudde

    Edward LaBudde - 2015-09-04

    where do I find it?

     
  • Edward LaBudde

    Edward LaBudde - 2015-09-04

    Why do I need to update I2C.h when it has its own include <hmc5883l.h></hmc5883l.h>

     

    Last edit: Edward LaBudde 2015-09-04
1 2 3 4 > >> (Page 1 of 4)

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.