<?xml version="1.0" encoding="UTF-8"?>
<!-- generator="bbPress/1.0.2" -->
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title>LeafLabs Garden &#187; User Favorites: DaemonMaker</title>
		<link><a href='http://forums.leaflabs.com/profile.php?id=1264'>1264</a></link>
		<description>A place to share, learn, and grow...</description>
		<language>en-US</language>
		<pubDate>Fri, 22 Jan 2016 00:17:18 +0000</pubDate>
		<generator>http://bbpress.org/?v=1.0.2</generator>
		<textInput>
			<title><![CDATA[Search]]></title>
			<description><![CDATA[Search all topics from these forums.]]></description>
			<name>q</name>
			<link>http://forums.leaflabs.com/search.php</link>
		</textInput>
		<atom:link href="http://forums.leaflabs.com/rss.php?profile=1264" rel="self" type="application/rss+xml" />

		<item>
			<title>4rdu1n0 on "libmaple i2c API"</title>
			<link>http://forums.leaflabs.com/topic.php?id=28&amp;page=7#post-20268</link>
			<pubDate>Thu, 11 Oct 2012 23:51:02 +0000</pubDate>
			<dc:creator>4rdu1n0</dc:creator>
			<guid isPermaLink="false">20268@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;Hi,&#60;/p&#62;
&#60;p&#62;I'm trying to interface an L3G4200D gyro (from sparkfun) with a Maple board. I tried to adapt some example code written for and Arduino but it isn't working at all. Here's the code:&#60;/p&#62;
&#60;pre&#62;&#60;code&#62;#include &#38;lt;Wire.h&#38;gt;

#define CTRL_REG1 0x20
#define CTRL_REG2 0x21
#define CTRL_REG3 0x22
#define CTRL_REG4 0x23
#define CTRL_REG5 0x24

int L3G4200D_Address = 105;

int x;
int y;
int z;

void setup()
{
  Wire.begin();

  SerialUSB.println(&#38;quot;starting up L3G4200D&#38;quot;);
  setupL3G4200D(2000);

  delay(1500);
}

void loop()
{
   getGyroValues();

  SerialUSB.print(&#38;quot;X:&#38;quot;);
  SerialUSB.print(x);

  SerialUSB.print(&#38;quot; Y:&#38;quot;);
  SerialUSB.print(y);

  SerialUSB.print(&#38;quot; Z:&#38;quot;);
  SerialUSB.println(z);

  delay(100);
}

void getGyroValues()
{
  byte xMSB = readRegister(L3G4200D_Address, 0x29);
  byte xLSB = readRegister(L3G4200D_Address, 0x28);
  x = ((xMSB &#38;lt;&#38;lt; 8) &#124; xLSB);

  byte yMSB = readRegister(L3G4200D_Address, 0x2B);
  byte yLSB = readRegister(L3G4200D_Address, 0x2A);
  y = ((yMSB &#38;lt;&#38;lt; 8) &#124; yLSB);

  byte zMSB = readRegister(L3G4200D_Address, 0x2D);
  byte zLSB = readRegister(L3G4200D_Address, 0x2C);
  z = ((zMSB &#38;lt;&#38;lt; 8) &#124; zLSB);
}

int setupL3G4200D(int scale)
{
  writeRegister(L3G4200D_Address, CTRL_REG1, 0b00001111);

  writeRegister(L3G4200D_Address, CTRL_REG2, 0b00000000);

  writeRegister(L3G4200D_Address, CTRL_REG3, 0b00001000);

  if(scale == 250)
  {
    writeRegister(L3G4200D_Address, CTRL_REG4, 0b00000000);
  }
  else if(scale == 500)
  {
    writeRegister(L3G4200D_Address, CTRL_REG4, 0b00010000);
  }
  else
  {
    writeRegister(L3G4200D_Address, CTRL_REG4, 0b00110000);
  }

  writeRegister(L3G4200D_Address, CTRL_REG5, 0b00000000);
}

void writeRegister(int deviceAddress, byte address, byte val)
{
    Wire.beginTransmission(deviceAddress);
    Wire.send(address);
    Wire.send(val);
    Wire.endTransmission();
}

int readRegister(int deviceAddress, byte address)
{
    int v;
    Wire.beginTransmission(deviceAddress);
    Wire.send(address);
    Wire.endTransmission();

    Wire.requestFrom(deviceAddress, 1);

    while(!Wire.available())
    {
        SerialUSB.println(&#38;quot;waiting&#38;quot;);
    }

    v = Wire.receive();
    return v;
}&#60;/code&#62;&#60;/pre&#62;
&#60;p&#62;I changed the SDA and SCL to 9 and 5 in the library and there are pull-up resistors built into the breakout board. Any ideas why this isn't working?
&#60;/p&#62;</description>
		</item>
		<item>
			<title>mbolivar on "Reseting to &#34;Factory Defaults&#34;"</title>
			<link>http://forums.leaflabs.com/topic.php?id=178#post-5556</link>
			<pubDate>Wed, 06 Jul 2011 11:57:26 +0000</pubDate>
			<dc:creator>mbolivar</dc:creator>
			<guid isPermaLink="false">5556@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;samtal,&#60;/p&#62;
&#60;p&#62;see here for why you don't need to select a serial port after the first time you upload a new bootloader:&#60;/p&#62;
&#60;p&#62;&#60;a href=&#34;http://forums.leaflabs.com/topic.php?id=891#post-5468&#34; rel=&#34;nofollow&#34;&#62;http://forums.leaflabs.com/topic.php?id=891#post-5468&#60;/a&#62;
&#60;/p&#62;</description>
		</item>
		<item>
			<title>samtal on "Reseting to &#34;Factory Defaults&#34;"</title>
			<link>http://forums.leaflabs.com/topic.php?id=178#post-5520</link>
			<pubDate>Tue, 05 Jul 2011 07:08:05 +0000</pubDate>
			<dc:creator>samtal</dc:creator>
			<guid isPermaLink="false">5520@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;Worked for me too.&#60;br /&#62;
Thanks.&#60;br /&#62;
Strange, but I could not belive I can try to program the Maple if it was not recognized as a serial port (there was no port number to use for the IDE).&#60;br /&#62;
It works nice and clean, the port number showed up after program load (I used one of the example programs fore that).&#60;br /&#62;
samtal
&#60;/p&#62;</description>
		</item>
		<item>
			<title>crenn on "libmaple i2c API"</title>
			<link>http://forums.leaflabs.com/topic.php?id=28&amp;page=7#post-5389</link>
			<pubDate>Thu, 23 Jun 2011 18:15:32 +0000</pubDate>
			<dc:creator>crenn</dc:creator>
			<guid isPermaLink="false">5389@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;By replacing line 50 of this file &#60;a href=&#34;http://crennsmind.com/Code/Maple/Debugging/I2C/I2C_Test.pde&#34; rel=&#34;nofollow&#34;&#62;http://crennsmind.com/Code/Maple/Debugging/I2C/I2C_Test.pde&#60;/a&#62; with:&#60;/p&#62;
&#60;blockquote&#62;&#60;p&#62;&#60;code&#62;i2c_disable(I2C2);&#60;/code&#62;&#60;/p&#62;&#60;/blockquote&#62;
&#60;p&#62;The micro doesn't trigger ASSERT and continues to work. I'd say it's a suitable workaround:&#60;br /&#62;
&#60;a href=&#34;http://crennsmind.com/Code/Maple/Debugging/I2C/I2C_Errors.txt&#34; rel=&#34;nofollow&#34;&#62;http://crennsmind.com/Code/Maple/Debugging/I2C/I2C_Errors.txt&#60;/a&#62;
&#60;/p&#62;</description>
		</item>
		<item>
			<title>crenn on "libmaple i2c API"</title>
			<link>http://forums.leaflabs.com/topic.php?id=28&amp;page=7#post-5383</link>
			<pubDate>Thu, 23 Jun 2011 04:40:53 +0000</pubDate>
			<dc:creator>crenn</dc:creator>
			<guid isPermaLink="false">5383@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;I'm still having problems and I can't seem to isolate the problem yet, however I might be able to point in the right direction. The tests are run on my Maple Mini board unless stated otherwise.&#60;br /&#62;
The first test I ran was just sending commands to the electronic speed controllers (ESCs) with no delays. Here's the code:&#60;br /&#62;
&#60;a href=&#34;http://crennsmind.com/Code/Maple/Debugging/I2C/Running_Motors.pde&#34; rel=&#34;nofollow&#34;&#62;http://crennsmind.com/Code/Maple/Debugging/I2C/Running_Motors.pde&#60;/a&#62;&#60;/p&#62;
&#60;p&#62;The next test ran was the same test with the delayMicroseconds uncommented, it causes the problem to not occur for some time, but I suspect it will happen eventually (I'll explain why later)&#60;/p&#62;
&#60;p&#62;I also ran a test with an i2c sensor module, and had a similar outcome, here's the code for that test:&#60;br /&#62;
&#60;a href=&#34;http://crennsmind.com/Code/Maple/Debugging/I2C/I2C_Test_ADXL.pde&#34; rel=&#34;nofollow&#34;&#62;http://crennsmind.com/Code/Maple/Debugging/I2C/I2C_Test_ADXL.pde&#60;/a&#62;&#60;br /&#62;
&#60;a href=&#34;http://crennsmind.com/Code/Maple/Debugging/I2C/I2C-Error-ADXL.png&#34; rel=&#34;nofollow&#34;&#62;http://crennsmind.com/Code/Maple/Debugging/I2C/I2C-Error-ADXL.png&#60;/a&#62;&#60;br /&#62;
The above test is run on the Maple with an ADXL345.&#60;/p&#62;
&#60;p&#62;Then I ran another set of code to attempt to recover from the bug, but the program still halts (ASSERT triggers, although the LED doesn't show that it does). For small amounts of periodic data, a delay of 3uS can be used, however 4uS will give a long running time. Here's the code running and serial outputs for the last test:&#60;br /&#62;
&#60;a href=&#34;http://crennsmind.com/Code/Maple/Debugging/I2C/I2C_Test.pde&#34; rel=&#34;nofollow&#34;&#62;http://crennsmind.com/Code/Maple/Debugging/I2C/I2C_Test.pde&#60;/a&#62;&#60;br /&#62;
&#60;a href=&#34;http://crennsmind.com/Code/Maple/Debugging/I2C/I2C-Error-ESC.png&#34; rel=&#34;nofollow&#34;&#62;http://crennsmind.com/Code/Maple/Debugging/I2C/I2C-Error-ESC.png&#60;/a&#62; -- Original testing&#60;br /&#62;
&#60;a href=&#34;http://crennsmind.com/Code/Maple/Debugging/I2C/I2C-Error-ESC_New.png&#34; rel=&#34;nofollow&#34;&#62;http://crennsmind.com/Code/Maple/Debugging/I2C/I2C-Error-ESC_New.png&#60;/a&#62; -- No delay between messages&#60;br /&#62;
&#60;a href=&#34;http://crennsmind.com/Code/Maple/Debugging/I2C/I2C-Error-ESC_New-3uS.png&#34; rel=&#34;nofollow&#34;&#62;http://crennsmind.com/Code/Maple/Debugging/I2C/I2C-Error-ESC_New-3uS.png&#60;/a&#62; -- Delay between messages of 3uS&#60;br /&#62;
&#60;a href=&#34;http://crennsmind.com/Code/Maple/Debugging/I2C/I2C-Error-ESC_New-4uS.png&#34; rel=&#34;nofollow&#34;&#62;http://crennsmind.com/Code/Maple/Debugging/I2C/I2C-Error-ESC_New-4uS.png&#60;/a&#62; -- Delay between messages of 4uS&#60;/p&#62;
&#60;p&#62;I've also made minor changes to the i2c files which can be gotten from here:&#60;br /&#62;
&#60;a href=&#34;http://crennsmind.com/Code/Maple/Debugging/I2C/v11-modified.zip&#34; rel=&#34;nofollow&#34;&#62;http://crennsmind.com/Code/Maple/Debugging/I2C/v11-modified.zip&#60;/a&#62;&#60;/p&#62;
&#60;p&#62;I'll also note that for Running_Motors, the LED pulsates when ASSERT is triggered, but neither of the other tests have the LED pulsating after halting. Sadly, I can't debug further due to the lack of a JTAG debugger. Another thing I should mention is, earlier I caused a small bug with my modification of i2c.c but that has been fixed.&#60;/p&#62;
&#60;p&#62;Summary of findings:&#60;br /&#62;
-There is a I2C_STATE_ERROR which is preventing the&#60;br /&#62;
-I2C pins when I2C is halted, are high&#60;br /&#62;
-The ESC has a bidirectional voltage level converter between it and the mini.&#60;br /&#62;
-Making a small delay increases the run time/number of messages sent (4uS, I got fed up and pulled the power on the ESC which disabled it)&#60;br /&#62;
-The ESC has been ruled out as a cause (although apparently there can be issues with it)&#60;br /&#62;
-The I2C device cannot be reset to allow recovery&#60;/p&#62;
&#60;p&#62;I'd like to try to get this bug fixed, although I'm not exactly sure where to look. I'd also like to have a function which will allow the I2C device to be reset completely so that I can recover from this bug or any other incidences.&#60;/p&#62;
&#60;p&#62;Also, current version of the Wire library can be had from here:&#60;br /&#62;
&#60;a href=&#34;http://crennsmind.com/Code/Maple/Wire-Snapshot-110623.zip&#34; rel=&#34;nofollow&#34;&#62;http://crennsmind.com/Code/Maple/Wire-Snapshot-110623.zip&#60;/a&#62;&#60;/p&#62;
&#60;p&#62;EDIT: Perry has told me to try i2c_disable() (I should have looked at the i2c.h inline functions, not just the i2c.c defined functions) when I attempt to recover from the bug. I'll be running a quick test in the morning to see if this will allow me to restart the I2C.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>poslathian on "libmaple i2c API"</title>
			<link>http://forums.leaflabs.com/topic.php?id=28&amp;page=7#post-5367</link>
			<pubDate>Tue, 21 Jun 2011 12:53:40 +0000</pubDate>
			<dc:creator>poslathian</dc:creator>
			<guid isPermaLink="false">5367@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;sweet! dont forget to send us a pull request when you are ready.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>crenn on "libmaple i2c API"</title>
			<link>http://forums.leaflabs.com/topic.php?id=28&amp;page=7#post-5364</link>
			<pubDate>Tue, 21 Jun 2011 01:12:40 +0000</pubDate>
			<dc:creator>crenn</dc:creator>
			<guid isPermaLink="false">5364@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;Ok, here are the results from the test this morning (a bit delayed, sorry about that).&#60;/p&#62;
&#60;p&#62;The Wire library has been fixed in terms of suddenly becoming slow after x time (I had left a line calling SerialUSB for debugging purposes). Timeouts occur as they should, and will trigger ASSERT on the next attempt to send data. I have to have around a 5uS delay before I can have continuous communication with the ESC, if I have anything less than this (I've only tested 2uS, not 3 or 4uS), ASSERT is triggered. I still need to discover why this is (investigation for tomorrow morning), which will involve making a test program to print out the exit states. Of i2c_master_xfer();. My thoughts is, it could be taking longer than 1ms which is the timeout period I've set, if so, I will quickly find it tomorrow.&#60;/p&#62;
&#60;p&#62;Currently I'm working on getting data from a timer channel set for input capture to measure a PWM signal. I've implemented a 'lighter' EXTI routine (due to problems with getting enough timer channels on the mini without using USB and other peripheral pins), and will be attempting later to see if I can't get it even more efficient.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>crenn on "libmaple i2c API"</title>
			<link>http://forums.leaflabs.com/topic.php?id=28&amp;page=7#post-5360</link>
			<pubDate>Mon, 20 Jun 2011 15:57:44 +0000</pubDate>
			<dc:creator>crenn</dc:creator>
			<guid isPermaLink="false">5360@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;Last I checked, Arduino's Wire implementation was actually using the TWI interface on the ATMEGAs. I'll be reporting back after I run a few tests this morning.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>poslathian on "libmaple i2c API"</title>
			<link>http://forums.leaflabs.com/topic.php?id=28&amp;page=7#post-5355</link>
			<pubDate>Mon, 20 Jun 2011 11:59:26 +0000</pubDate>
			<dc:creator>poslathian</dc:creator>
			<guid isPermaLink="false">5355@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;that is to say, that it is implicitly delayed
&#60;/p&#62;</description>
		</item>
		<item>
			<title>poslathian on "libmaple i2c API"</title>
			<link>http://forums.leaflabs.com/topic.php?id=28&amp;page=6#post-5354</link>
			<pubDate>Mon, 20 Jun 2011 11:59:15 +0000</pubDate>
			<dc:creator>poslathian</dc:creator>
			<guid isPermaLink="false">5354@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;well the arduino version is bit banged, and probably not running at the 400KHz rate no?
&#60;/p&#62;</description>
		</item>
		<item>
			<title>crenn on "libmaple i2c API"</title>
			<link>http://forums.leaflabs.com/topic.php?id=28&amp;page=6#post-5351</link>
			<pubDate>Mon, 20 Jun 2011 09:28:37 +0000</pubDate>
			<dc:creator>crenn</dc:creator>
			<guid isPermaLink="false">5351@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;No, the same I2C device (it's a Brushless DC ESC) works with the same code on the Arduino, and currently I don't have any delays running for the current program, but some delays will occur due to calculations.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>anton on "libmaple i2c API"</title>
			<link>http://forums.leaflabs.com/topic.php?id=28&amp;page=6#post-5349</link>
			<pubDate>Mon, 20 Jun 2011 04:16:53 +0000</pubDate>
			<dc:creator>anton</dc:creator>
			<guid isPermaLink="false">5349@http://forums.leaflabs.com/</guid>
			<description>&#60;blockquote&#62;&#60;p&#62;I'm having issues when I don't use a delay between sending messages, it will quickly stop sending messages without a delay.&#60;/p&#62;&#60;/blockquote&#62;
&#60;p&#62;Can the problem be connected with the internal delay of the sensor?
&#60;/p&#62;</description>
		</item>
		<item>
			<title>crenn on "libmaple i2c API"</title>
			<link>http://forums.leaflabs.com/topic.php?id=28&amp;page=6#post-5348</link>
			<pubDate>Mon, 20 Jun 2011 02:14:28 +0000</pubDate>
			<dc:creator>crenn</dc:creator>
			<guid isPermaLink="false">5348@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;Continuation of the I2C discussion from this thread: &#60;a href=&#34;http://forums.leaflabs.com/topic.php?id=861&#34; rel=&#34;nofollow&#34;&#62;http://forums.leaflabs.com/topic.php?id=861&#60;/a&#62;&#60;/p&#62;
&#60;p&#62;Well, after doing a little bit of fiddling, it seems everything is working for the hardware I2C apart from my wire library implementation. I noticed that before it wasn't timing out if a NACK condition during addressing is generated (bad!), and I've made a couple of other little changes including to remove a goto function call. I'll list the changes made when I get home (I'm on a train currently). But the good news is, I2C hardware low level appears to be working flawlessly. However, I haven't done one test which caused issues last time, I'll be performing that test tomorrow.&#60;/p&#62;
&#60;p&#62;I'll be trying to find the bug within my Wire implementation, however I think I know what the issue is and will test tomorrow. If so, documentation and a release should be soon if I believe it's stable.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>crenn on "libmaple i2c API"</title>
			<link>http://forums.leaflabs.com/topic.php?id=28&amp;page=6#post-5033</link>
			<pubDate>Tue, 07 Jun 2011 04:19:25 +0000</pubDate>
			<dc:creator>crenn</dc:creator>
			<guid isPermaLink="false">5033@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;Eventually, it currently has bugs in it (including not being able to work with v0.0.10 or later), and I won't get more time to fix it until tomorrow night. I've got an exam tomorrow afternoon, and another piece of assessment due the Monday after. I'll post in this thread when I've finished the library and I'll try to push it to leaflabs for approval.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>anton on "libmaple i2c API"</title>
			<link>http://forums.leaflabs.com/topic.php?id=28&amp;page=6#post-5021</link>
			<pubDate>Tue, 07 Jun 2011 00:05:27 +0000</pubDate>
			<dc:creator>anton</dc:creator>
			<guid isPermaLink="false">5021@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;crenn, do you intend to add your Wire lib in master libmaple branch?
&#60;/p&#62;</description>
		</item>

	</channel>
</rss>
