Custom I2C sensor problem
Custom I2C sensor problem
Hi,
I'm building a sensor with this 6dOF IMU board. So far I have it setup on a breadboard. I got the power down to 3.3V for the board, replaced the resistors on the board with 87K ones, wired the power- and datalines. I checked the powerlines, but I don't know how to check the datalines.
I used robotC to make a driver that is based on Xanders driver suite (common.h). But I don't get valid readings. At first the I2C bus has no error, but after the first read request to the sensor the port returns an error, -35. This code is not very specific, it is a general error. It is impossible to recover from this error, only switching off the NXT will help.
This is where I'm stuck.
Possible causes:
- bad connection
- wiring too long
- driver error
- firmware error (this board has i2c addresses like 0xd0)
I'm pretty sure I can rule out driver errors. I have debugged it extensively.
Any suggestions?
I'm building a sensor with this 6dOF IMU board. So far I have it setup on a breadboard. I got the power down to 3.3V for the board, replaced the resistors on the board with 87K ones, wired the power- and datalines. I checked the powerlines, but I don't know how to check the datalines.
I used robotC to make a driver that is based on Xanders driver suite (common.h). But I don't get valid readings. At first the I2C bus has no error, but after the first read request to the sensor the port returns an error, -35. This code is not very specific, it is a general error. It is impossible to recover from this error, only switching off the NXT will help.
This is where I'm stuck.
Possible causes:
- bad connection
- wiring too long
- driver error
- firmware error (this board has i2c addresses like 0xd0)
I'm pretty sure I can rule out driver errors. I have debugged it extensively.
Any suggestions?
My blog: nxttime.wordpress.com
-
- Posts: 1818
- Joined: 02 Oct 2010, 02:19
- Location: Michigan USA
- Contact:
Re: Custom I2C sensor problem
You said "I...replaced the resistors on the board with 87K ones", but did you literally replace them on the board? or did you just take them off, and add others to the circuit? (Are you using the pullups to the 3.3v? or 4.7?). Also note, when using the I2C bus at 3.3v, the pullups should be (IIRC) 47k.
In my experience with NXC, a physical error in an I2C bus doesn't usually (for me) cause an error until I attempt to read (sometimes I don't even get an error when I try writing to nothing, maybe always).
If your wiring is no longer than 1 meter, you should be okay, unless you are using some crazy wire.
The address of the hardware is totally irrelevant to it working, as you set the address in the NXT program (part of the "driver", I guess).
In my experience with NXC, a physical error in an I2C bus doesn't usually (for me) cause an error until I attempt to read (sometimes I don't even get an error when I try writing to nothing, maybe always).
If your wiring is no longer than 1 meter, you should be okay, unless you are using some crazy wire.
The address of the hardware is totally irrelevant to it working, as you set the address in the NXT program (part of the "driver", I guess).
Matt
http://mattallen37.wordpress.com/
I'm all for gun control... that's why I use both hands when shooting
http://mattallen37.wordpress.com/
I'm all for gun control... that's why I use both hands when shooting
Re: Custom I2C sensor problem
I cut the resistors off the board and added other resistors to the circuit. They are 87K, close to the recommended 82K. The resistors are connected to 3.3V.
(I also tried the sensor without pull-ups. Instead I used a port splitter and another sensor. The idea being that the other sensor would have pull-ups. But this didn't improve matters. I will try 47K resistors as well, but I'll have to get them first.
Is it normal that the NXT does not recover from a bus error? Is this an indication to the kind of problem I'm having?
(I also tried the sensor without pull-ups. Instead I used a port splitter and another sensor. The idea being that the other sensor would have pull-ups. But this didn't improve matters. I will try 47K resistors as well, but I'll have to get them first.
Is it normal that the NXT does not recover from a bus error? Is this an indication to the kind of problem I'm having?
My blog: nxttime.wordpress.com
-
- Posts: 1818
- Joined: 02 Oct 2010, 02:19
- Location: Michigan USA
- Contact:
Re: Custom I2C sensor problem
87k should be just fine for 4.7v operation, however, it may be too weak for 3.3v. I have used 100k on the normal voltage, with no problems. Unfortunately, you may have ruined the board by using another sensor with pullups to 4.7v, because the SDA and SCL were being pulled up to way higher than the VCC voltage (3.3v).aswin0 wrote:I cut the resistors off the board and added other resistors to the circuit. They are 87K, close to the recommended 82K. The resistors are connected to 3.3V.
(I also tried the sensor without pull-ups. Instead I used a port splitter and another sensor. The idea being that the other sensor would have pull-ups. But this didn't improve matters. I will try 47K resistors as well, but I'll have to get them first.
Is it normal that the NXT does not recover from a bus error? Is this an indication to the kind of problem I'm having?
I don't know if the NXT is supposed to recover when using ROBOTC, but I know it does with NXC.
Matt
http://mattallen37.wordpress.com/
I'm all for gun control... that's why I use both hands when shooting
http://mattallen37.wordpress.com/
I'm all for gun control... that's why I use both hands when shooting
Re: Custom I2C sensor problem
OK, I pulled the I2C lines up to 4.7V using the 87K resistors. The error is gone! Now all I need are some valid readings, because I only get zero's. I'll keep you informed.mattallen37 wrote:87k should be just fine for 4.7v operation, however, it may be too weak for 3.3v. I have used 100k on the normal voltage, with no problems. Unfortunately, you may have ruined the board by using another sensor with pullups to 4.7v, because the SDA and SCL were being pulled up to way higher than the VCC voltage (3.3v).
My blog: nxttime.wordpress.com
-
- Posts: 323
- Joined: 29 Sep 2010, 05:03
Re: Custom I2C sensor problem
Hmm. You may be pushing your luck a little here. The maximum ratings for the SCL and SDA pins on the gyro are VDD+0.5V (which with a 3.3V supply gives a max of 3.8V a lot less than 4.7V)! The accelerometer seems to have a limit of 3.6V (possibly 3.9V depending on how you read the spec)...
Andy
Andy
Re: Custom I2C sensor problem
aswin0 class subject, keep us informed please
Re: Custom I2C sensor problem
It is becoming a bit unclear for me. If I read the NXT docs I see that there is 4.7v on the VDD and 3.3 on the SDA and SCL. Lego recommends a 82k resistor as a pull up. This resistor will go from SDA/SCL to VDD, right. I thought the resistor needed such a high impedance because of the difference in voltage between the two. GloomyAndy, do you mean I should not pull-up to the 4.7V of the NXT port? If not, what kind of impedance should I use when pulling-up to the 3.3V of the sensor VDD? Apparently, the recommended 82k does not work.
My blog: nxttime.wordpress.com
-
- Posts: 1818
- Joined: 02 Oct 2010, 02:19
- Location: Michigan USA
- Contact:
Re: Custom I2C sensor problem
Your problem is likely the resistor values. Try 47k to 3.3v, that should do it. The NXT "3.3v" I2C pins CAN handle pullups to 4.7v, but don't risk it any more with the 3.3v max sensor board. I think your resistors are just too weak, that's why you need 47k's. If you don't have 47k's,another option, is to use two 87k's in parallel, to get 43.5k ohms (close enough to 47k), although you would need a total of four of them.
Matt
http://mattallen37.wordpress.com/
I'm all for gun control... that's why I use both hands when shooting
http://mattallen37.wordpress.com/
I'm all for gun control... that's why I use both hands when shooting
-
- Posts: 323
- Joined: 29 Sep 2010, 05:03
Re: Custom I2C sensor problem
Hi,
Well I'm not an expert on this but this is my take on things...
The ATmel ARM processor on the NXT runs at 3.3V and this is the voltage it will drive digital outputs at and what it uses as the reference voltage for the A/D converter (not the one used for most analogue sensors). The ATMel I/O lines are 5V tolerant so can accept 5V input. However the digital I/O lines are protected by additional circuitry on the NXT board (a couple of clamp diodes and a current limiting resistor), and so they do not actually see the higher voltages. This means that they can be used with the 4.7V line for i2c operations (though you will notice that the clock and data values never reach anything like 4.7V when being driven by the NXT). So normal practice is to add a resistor to pull the lines up to 4.7V. This resistor has to be a higher value than would normally be used because the current limiting resistor (which is part of the protection circuitry), prevents the NXT from driving the line low if a much lower resistor is used.
In your case you are using an external device that runs on 3.3V and that is not tolerant of higher input voltages. So in this case you need to drive the i2c at 3.3V. This web page:
http://www.tau.ac.il/~stoledo/lego/i2c-8591-lis3l02as4/
Seems to suggest that this should be fine and uses 82K pull ups. However other pages:
http://lejos.sourceforge.net/forum/view ... 410dde0c4e
Seem to suggest that a lower value resistor should be used for 3.3V. Either way I don't think it is a good idea to connect your pull ups to 4.7V or to connect this device to a bus (via a port splitter or mux), with other devices that operate at any voltage above 3.6V (above this is out of spec for your device). Unfortunately you may have already damaged the parts...
Good luck
Andy
Well I'm not an expert on this but this is my take on things...
The ATmel ARM processor on the NXT runs at 3.3V and this is the voltage it will drive digital outputs at and what it uses as the reference voltage for the A/D converter (not the one used for most analogue sensors). The ATMel I/O lines are 5V tolerant so can accept 5V input. However the digital I/O lines are protected by additional circuitry on the NXT board (a couple of clamp diodes and a current limiting resistor), and so they do not actually see the higher voltages. This means that they can be used with the 4.7V line for i2c operations (though you will notice that the clock and data values never reach anything like 4.7V when being driven by the NXT). So normal practice is to add a resistor to pull the lines up to 4.7V. This resistor has to be a higher value than would normally be used because the current limiting resistor (which is part of the protection circuitry), prevents the NXT from driving the line low if a much lower resistor is used.
In your case you are using an external device that runs on 3.3V and that is not tolerant of higher input voltages. So in this case you need to drive the i2c at 3.3V. This web page:
http://www.tau.ac.il/~stoledo/lego/i2c-8591-lis3l02as4/
Seems to suggest that this should be fine and uses 82K pull ups. However other pages:
http://lejos.sourceforge.net/forum/view ... 410dde0c4e
Seem to suggest that a lower value resistor should be used for 3.3V. Either way I don't think it is a good idea to connect your pull ups to 4.7V or to connect this device to a bus (via a port splitter or mux), with other devices that operate at any voltage above 3.6V (above this is out of spec for your device). Unfortunately you may have already damaged the parts...
Good luck
Andy
Who is online
Users browsing this forum: No registered users and 1 guest