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.

TankMaster

Member Since 08 Mar 2011
Offline Last Active Feb 01 2015 01:37 PM
-----

Posts I've Made

In Topic: Strange data received from SRF02 I2C

25 June 2013 - 06:34 PM

Yes, two 10k resistors i parallel should correspond to a single 5k resistor. Well, it was just a thought.

 

Looking again at your code and comparing to the user manual you referred to, it seems you're are doing the reads wrong. You should read location 2 and 3 separately to get the high and low byte respectively. As it is now, you issue a series of four transactions where the read buffer gets overwritten by the the second read transaction. Your read buffer is 2 bytes but I think it only need be one byte since first you should read the high byte and then you read the low byte (the order does not seem to matter).

 

Also, I believe the location counter (address counter) auto-increments for each read performed so you could probably do something like this instead (here, the read buffer is still 2 bytes long):

xActions = new I2CDevice.I2CTransaction[]{	I2CDevice.CreateWriteTransaction(new byte[] { 0x02 }),	I2CDevice.CreateReadTransaction(RegisterValue),}int c = srf02.Execute(xActions, 1000);Debug.Assert(c > 0, "I2C write/read failed!");int val = (RegisterValue[0] << 8)|RegisterValue[1];

As you know, the Netduino is 5V tolerant and I wonder if the the LLC is really necessary - have you tried without it?

 

Hmm, seems like I have not understood this from the beginning... So LSB shall be skipped? Then why is both MSB and LSB available (Range High byte/MSB and Range Low byte/LSB)... I'm getting correct results now when only reading the MSB and doing the shift etc with it :) Why did you changed so that 2 is the number that means that the I2C operation has failed? I know that the N+ is 5V tolerant, but only the pins and the circuit board in my interpretation, I have never understood that the logic supports it as well...

 

Thanks for your time and help! :)


In Topic: Strange data received from SRF02 I2C

25 June 2013 - 03:11 PM

I agree, the byte order is equal to that of the Arduino code.

 

In my experience floating pins can sometimes result in strange phenomena and I try to avoid them even if it theoretically shouldn't matter. I normally use 100k pull-downs on unused pins though.

 

You could try using stronger I2C pull-ups, say 4k7 as see if that helps.

 

Okay, but how do I do that when I have the 10k's already on the LLC board? I tried to add resistors in parallel connected as pull-ups, together with the wire from/to the LLC on each voltage side, to achieve in theory an approx. 4.7k ohm resistor for SDA & SDL on both of the voltage sides. Is this not correct? I still get the wrong output data with this setup... Feels like I'm walking in the mist right now ^^


In Topic: Strange data received from SRF02 I2C

25 June 2013 - 10:46 AM

Perhaps you got the msb/lsb conversion wrong or the values are signed? The ratio between inches and centimetres seem correct most of the time. I trust the I2C pull-up resistors are in place. Got any pins floating?

 

I think the bitwise operations are right, not so much experience from it but the examples I have found used the one I have. The data result is 16 bit unsigned, so it must be that bitwise operation above that is right... The Arduino equivalent I found where this: http://arduino.cc/en...urceblock&num=1

reading = Wire.read();  // receive high byte (overwrites previous reading)reading = reading << 8;    // shift high byte to be high 8 bitsreading |= Wire.read(); // receive low byte as lower 8 bits

The LLC has 10k pull-ups, and as an extra precaution I have now as well connected the remaining pins on the LLC to ground, but that didn't give any difference (which it shouldn't do right? As the lines are separated, or?).


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.