Shop OBEX P1 Docs P2 Docs Learn Events
Help needed to connect I2C sensors to propeller — Parallax Forums

Help needed to connect I2C sensors to propeller

ios78ios78 Posts: 4
edited 2011-10-04 21:34 in Propeller 1
Hi,

I've been recently learning more about the Parallax Propeller and programming in spin. I've found the GadgetGangster website tutorials very educational in my learning.

I've just recently purchased a Triple Axis Magnetometer Breakout - HMC5883L (http://www.sparkfun.com/products/10530) and 9 Degrees of Freedom - Sensor Stick (http://www.sparkfun.com/products/10724) from Sparkfun. Both use I2C for communication, and I have found it very difficult to find information on how to connect and read the data from these sensors, despite the Propeller Object Exchange having a few example such as http://obex.parallax.com/objects/562/ and http://obex.parallax.com/objects/729/, and forum items such as http://forums.parallax.com/showthread.php?131022-Propeller-DCM-Now-with-source.

Any help would be much appreciated.
Ios78

Comments

  • Cluso99Cluso99 Posts: 18,069
    edited 2011-10-03 20:16
    ios78: Firstly, welcome to the fabulous Prop chip.

    I am in the process of building a QuadCopter and there is a build log over on the Builders Forum http://forums.parallax.com/showthread.php?133372-Ken-s-QuadCopter-Build-Log-(now-includes-videos)

    Currently I am using the Wii gyros and accelerometers. Perhaps the code for them my give you a guide, but they are not the chips you have. I have the ITG3200 and others but decided to go the cheaper route, at least for starters.

    Try posting your code (zip it with PropTool) and asking specific questions. Perhaps others will chime in with more experience in this area.
  • ios78ios78 Posts: 4
    edited 2011-10-03 21:22
    Wow!, thanks for the welcome Cluso99.

    This is probably a silly question, but,...
    If someone could have a quick look at the schematics at http://www.sparkfun.com/products/10530 or http://www.sparkfun.com/products/10724 - can I just confirm with someone that the pull ups on these PCBs are all that are needed for I2C communication with a prop chip - or do I need to install seperate resisters (4.7k) between the SCL and SDO lines and 3.3v, or anything else. Also, if I have a 1K resister between the Prop and the SCL and SDO lines, would this be a problem?

    I'm actually trying to run JasonDorie's Propeller DCM code. He has been very helpful on PM and email, but I still can't make it work, and I'm split as to whether or not its a hardware or code issue. I'll put up some more detailed information about the issue shortly.

    Many thanks
    Ios78
  • Cluso99Cluso99 Posts: 18,069
    edited 2011-10-03 23:46
    ios78: I have just obtained permission to post the ITG3200 code by Jason. It is here http://forums.parallax.com/showthread.php?133372-Ken-s-QuadCopter-Build-Log-(now-includes-videos)&p=1040950#post1040950 The file is called Jason_QuadCopter.zip and there is an ITG-3200.spin which has I2C in spin and a faster version ITG-3200-pasm.spin.

    The first sparkfun link does not say if the pullups are installed - I presume they are. The second link (9DOF) has the pullups and also a 5V to 3V3 regulator. Both these pcbs actually run on 3V3 so no series resistors are necessary. For the 9DOF pcb, you will need to supply 5V to the pcb. It may be possible to short the input to output of the regulator, but it is not wise since we do not know what regulator is used (some regulators may not be shorted this way without potential damage.

    First up, you need to confirm that you are actually reading the gyro, etc. best to just display what you are reading to the serial port and use PST (Parallax serial terminal). BTW you cannot use a standard terminal program as they usually toggle DTR and this resets the prop chip.
  • ios78ios78 Posts: 4
    edited 2011-10-04 19:30
    Thank so much for your help Cluso99. The Quadcopter project you guys are working on looks awesome. Although I myself fly r/c airplanes, unfortunately I have no experience with helicopters or quads. Is it difficult to fly a quad? Can it be flown without stabilisation? (goes to show how little I know about quads!! lol)

    I've made some progress overnight with my earlier problem. I've finally managed to read values from the 6dof board using the following code in the repeat loop of the Main subroutine;

    Dbg.dec( Gyro.GetRX )
    Dbg.tx ( 32 )
    Dbg.dec( Gyro.GetRY )
    Dbg.tx ( 32 )
    Dbg.dec( Gyro.GetRZ )
    Dbg.tx ( 13 )

    Dbg.dec( Gyro.GetAX )
    Dbg.tx ( 32 )
    Dbg.dec( Gyro.GetAY )
    Dbg.tx ( 32 )
    Dbg.dec( Gyro.GetAZ )
    Dbg.tx ( 13 )

    HOWEVER,... the first three values (i.e. RX, RY, RZ) all produce values of zero, which I assume means that I'm now correctly receiving data from the accelerometers, but still not receiving data from the magnatometer.

    I've also been successful in using JasonDorie's application to show the "cube", but what happens when I move the breadboard around is that the cube updates/moves, but has a few seconds of lag in it's movement relative to the board and moves slowly. Maybe I need to make a short video to demonstrate this. Also, rotations about an axis, i.e. if the breadboard is on the table and rotated whilst still flat on the table, do not produce movement in the application.

    I think I've just got the DeviceID wrong, but having said that, I've tried the values which I thought were correct based on the spec sheet and info on sparkfun's schamatic.

    PropStick_6dof_DCM.jpg
    600 x 800 - 131K
  • Cluso99Cluso99 Posts: 18,069
    edited 2011-10-04 21:34
    I used to fly model airplanes but I never got far enough to attempt to land one :(
    That is why the quad is so interesting. By using a gyro, etc, a large portion of the control is done with by software. I am not sure that you can fly a quad without a gyro???

    With my Wii, I certainly receive values for the gyro when I move it, but I dont have anything useful from the accelerometers yet.

    I have been trying to go about my development systematically. First proving my gyro was working, next my escs and motors (all done so far). Now I am trying to simplify the ESC driver by rewriting it. Once that is done I intend to check that my receiver is being read by the prop. Once that is done I will combine the code with Jasons and hope for the best.
Sign In or Register to comment.