Netduino home hardware projects downloads community

Jump to content


The Netduino forums have been replaced by new forums at community.wildernesslabs.co. This site has been preserved for archival purposes only and the ability to make new accounts or posts has been turned off.

TheIceManProgrammeth

Member Since 12 Feb 2013
Offline Last Active Sep 15 2018 03:54 PM
-----

Posts I've Made

In Topic: Pull Up, Pull Down, Pulling my hair out!

22 February 2015 - 10:45 PM

Thanks Paul. Got readings from both the magnet and accelerometer now but I'm intrigued as to why the standard I2C stuff didn't work. Think one of the other posters mentioned repeated-start condition so going to experiment with that to see if I can see what is wrong with the standard transaction based stuff.

 

Will post all results to the wiki once I've finished.

 

Seems so easy now it's working properly!


In Topic: I2C on original netduino not reading multiple bytes

21 February 2015 - 11:02 PM

I had the same issue. Try amending:

 

byte write = { AddressOfFirstRegisterIneed };

 

to

 

byte write = { AddressOfFirstRegisterIneed | (1 << 7) };


In Topic: Pull Up, Pull Down, Pulling my hair out!

21 February 2015 - 10:45 PM

Ok update on this one. I eventually started to get some readings when I switched the I2C sensor code to the toolbox MultiI2c but only for the magnet not the accelerometer. No resistors needed and worked using the sensor shield I bought so haven't wasted money after all.

 

Will post the code when I get the accelerometer working!

 

Thanks to Paul for his suggestions and I've certainly learnt a lot more about how I2C works!


In Topic: Pull Up, Pull Down, Pulling my hair out!

20 February 2015 - 10:44 AM

Haha thanks Paul well this is the sensor for the heading so it could end up anywhere in Berkshire if it doesn't work! ;-)
 
So the code sends 8bytes to be populated by the sensor and then checks if the number of bytes coming back is equal to the buffer.

            lock (_slaveDevice)

            {

                // the i2c data is received here from the device.

                int transferred = _slaveDevice.Execute(readXAction, transactionTimeout);

 

                // make sure the data was received.

                if (transferred != readBuffer.Length)

                   throw new Exception("Could not read from device.");

            }

When I use the code above transferred is always 0. When I use the same _slaveDevice.Execute method for the write it returns 2 for the init and 1 for the pre-read send. Adding the resistors has no impact (I've placed one between the power and the SDA and one one betwen the SCL and power). Even without anything connected to the netduino the write returns 2 and 1 from the method and the read still returns 0.

 

So what I can't get my head round is why is the netduino saying the write worked when clearly there was nothing attached to it? Your earlier post suggested the ACK was being wrongly interpreted but since there is nothing connected to the pin where did the ACK come from?

 

Thanks for any suggestions you can give me.


In Topic: Pull Up, Pull Down, Pulling my hair out!

19 February 2015 - 11:03 PM

Cool hopefully you will see one of my netduino projects flying around the Reading area soon!

 

So I tried the i2C again and still nothing.

 

With absolutely nothing attached to the netduino the write seems to work sending 2 bytes for the init and 1 for the pre-read. The read returns 0. This is exactly the same result when I plug in the sensor with or without resistors between them and the board.

 

I did notice the arduino library code for the sensor was slightly different to the Netduino conversion but even changing those had no effect and would explain why the sensor seems to have no impact on the results whatsoever.

 

Pretty frustrating. Is there any way to test the i2c using something simpler?

 

Thanks again in advance for any help. I'm sure it's probably something silly.


home    hardware    projects    downloads    community    where to buy    contact Copyright © 2016 Wilderness Labs Inc.  |  Legal   |   CC BY-SA
This webpage is licensed under a Creative Commons Attribution-ShareAlike License.