Go to Post There is a really bad trap most people fall into, when presented with data they tend to trust it. This is dangerous. - Andrew Schreiber [more]
Home
Go Back   Chief Delphi > Technical > Programming > Java
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 16-03-2013, 19:41
timoho98 timoho98 is offline
Registered User
FRC #2813
 
Join Date: Mar 2013
Location: Saratoga
Posts: 4
timoho98 is an unknown quantity at this point
AXDL345_I2C java problems

Our team has been trying to solve an issue with our accelerometer in Java. We have been able to get it to work on LabView and on an Arduino, but we are having problems on getting it to work in Java, while using an 8-slot CRIO. We think the issue might be an older CRIO that is not compatible with the I2C support on the latest Java libraries, but we can't test it on the newer CRIO because it is currently sealed in our bag. Do you know of any support sites for this Java library, or have any information about the compatibility with the older CRIO?
Reply With Quote
  #2   Spotlight this post!  
Unread 16-03-2013, 20:08
Ginto8's Avatar
Ginto8 Ginto8 is offline
Programming Lead
AKA: Joe Doyle
FRC #2729 (Storm)
Team Role: Programmer
 
Join Date: Oct 2010
Rookie Year: 2010
Location: Marlton, NJ
Posts: 174
Ginto8 is a glorious beacon of lightGinto8 is a glorious beacon of lightGinto8 is a glorious beacon of lightGinto8 is a glorious beacon of lightGinto8 is a glorious beacon of light
Re: AXDL345_I2C java problems

What kind of issues are you having? I was able to get that accelerometer working earlier in the season on our test bed (which is an 8-slot cRIO) without a problem.
__________________
I code stuff.
Reply With Quote
  #3   Spotlight this post!  
Unread 16-03-2013, 21:39
timoho98 timoho98 is offline
Registered User
FRC #2813
 
Join Date: Mar 2013
Location: Saratoga
Posts: 4
timoho98 is an unknown quantity at this point
Re: AXDL345_I2C java problems

We are not able to read values from the accelerometer although we are able to do so on the arduino as well as through the labview sample code.
Reply With Quote
  #4   Spotlight this post!  
Unread 16-03-2013, 22:34
Ginto8's Avatar
Ginto8 Ginto8 is offline
Programming Lead
AKA: Joe Doyle
FRC #2729 (Storm)
Team Role: Programmer
 
Join Date: Oct 2010
Rookie Year: 2010
Location: Marlton, NJ
Posts: 174
Ginto8 is a glorious beacon of lightGinto8 is a glorious beacon of lightGinto8 is a glorious beacon of lightGinto8 is a glorious beacon of lightGinto8 is a glorious beacon of light
Re: AXDL345_I2C java problems

Are you getting nonsensical values? Are you getting some sort of exception? I don't really know what problem you're having.

As a reference, we initialized the accelerometer like this:
Code:
ADXL345_I2C _accelerometer = new ADXL345_I2C(1,ADXL345_I2C.DataFormat_Range.k2G);
and read from it like this:
Code:
double yAccel = _accelerometer.getAcceleration(ADXL345_I2C.Axes.kY);
__________________
I code stuff.
Reply With Quote
  #5   Spotlight this post!  
Unread 17-03-2013, 00:18
timoho98 timoho98 is offline
Registered User
FRC #2813
 
Join Date: Mar 2013
Location: Saratoga
Posts: 4
timoho98 is an unknown quantity at this point
Re: AXDL345_I2C java problems

We pretty much have the same code as you have posted, I currently do not have access to it at the moment so I cant post it. But our main problem is that when we do output the axes values it returns a 0 which we are assuming is nothing being returned at all. We stuck a probe into it just to see if it was getting data and it was sending the right address I presume "0x3A" as well as NACK's and are confused as to why.

thanks for trying to help us
Reply With Quote
  #6   Spotlight this post!  
Unread 17-03-2013, 11:31
stevwa64 stevwa64 is offline
Registered User
AKA: Steve Wart
FRC #2813 (Prospect GearHeads)
Team Role: Mentor
 
Join Date: Mar 2013
Rookie Year: 2012
Location: Saratoga
Posts: 3
stevwa64 is an unknown quantity at this point
Re: AXDL345_I2C java problems

One difference is we didn't try k2G when we initialized it. We tried k4G and k16G, but neither of those worked for us. Any pointers to docs on what those values mean?
Reply With Quote
  #7   Spotlight this post!  
Unread 17-03-2013, 20:13
Ginto8's Avatar
Ginto8 Ginto8 is offline
Programming Lead
AKA: Joe Doyle
FRC #2729 (Storm)
Team Role: Programmer
 
Join Date: Oct 2010
Rookie Year: 2010
Location: Marlton, NJ
Posts: 174
Ginto8 is a glorious beacon of lightGinto8 is a glorious beacon of lightGinto8 is a glorious beacon of lightGinto8 is a glorious beacon of lightGinto8 is a glorious beacon of light
Re: AXDL345_I2C java problems

Here's the datasheet. The k2G, k4G etc. tell the accelerometer what value should be counted as 1 (k1G being normal gravitational acceleration, k2G being twice that, etc.).
__________________
I code stuff.
Reply With Quote
  #8   Spotlight this post!  
Unread 23-03-2013, 16:27
potatoshane potatoshane is offline
Registered User
FRC #2813
 
Join Date: Feb 2013
Location: San Jose
Posts: 33
potatoshane will become famous soon enough
Re: AXDL345_I2C java problems

It is still not working

Here is the code
Quote:
package edu.wpi.first.wpilibj.templates;


import edu.wpi.first.wpilibj.ADXL345_I2C;
import edu.wpi.first.wpilibj.DriverStationLCD;
import edu.wpi.first.wpilibj.SimpleRobot;
import edu.wpi.first.wpilibj.Timer;
import java.util.Date;

public class RobotTemplate extends SimpleRobot {

ADXL345_I2C accelerometer;

public RobotTemplate()
{
DriverStationLCD.getInstance().println(DriverStati onLCD.Line.kUser2, 1, "Initializing...");
DriverStationLCD.getInstance().updateLCD();
// erase the line before the next time it gets called
DriverStationLCD.getInstance().println(DriverStati onLCD.Line.kUser2, 1, " ");
}

/**
* This function is called once each time the robot enters autonomous mode.
*/
public void autonomous() {

Timer.delay(0.05);
}

/**
* This function is called once each time the robot enters operator control.
*/
public void operatorControl() {

accelerometer = new ADXL345_I2C(1, ADXL345_I2C.DataFormat_Range.k2G);


// I2C i2c = accelerometer.getI2C();
// if (i2c.addressOnly()) {
// DriverStationLCD.getInstance().println(DriverStati onLCD.Line.kUser3, 1, "No Data");
// DriverStationLCD.getInstance().println(DriverStati onLCD.Line.kUser4, 1, "");
// }

DriverStationLCD lcd = DriverStationLCD.getInstance();

// lcd.println(DriverStationLCD.Line.kUser1, 1, (new Date()).toString());
// lcd.println(DriverStationLCD.Line.kUser2, 1, "Starting operator control");
// lcd.updateLCD();

//this.getWatchdog().setEnabled(false);
while(true) {

double x = accelerometer.getAcceleration(ADXL345_I2C.Axes.kX) ;
double y = accelerometer.getAcceleration(ADXL345_I2C.Axes.kY) ;
double z = accelerometer.getAcceleration(ADXL345_I2C.Axes.kZ) ;

lcd.println(DriverStationLCD.Line.kUser1, 1, (new Date()).toString());
lcd.println(DriverStationLCD.Line.kUser2, 1, "X: " + x);
lcd.println(DriverStationLCD.Line.kUser3, 1, "Y: " + y);
lcd.println(DriverStationLCD.Line.kUser4, 1, "Z: " + z);
lcd.updateLCD();

Timer.delay(0.05);
}
}
}
Reply With Quote
  #9   Spotlight this post!  
Unread 25-03-2013, 03:32
jhersh jhersh is offline
National Instruments
AKA: Joe Hershberger
FRC #2468 (Appreciate)
Team Role: Mentor
 
Join Date: May 2008
Rookie Year: 1997
Location: Austin, TX
Posts: 1,006
jhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond repute
Re: AXDL345_I2C java problems

My recommendation is that you call SetCompatibilityMode(true); on the I2C object.

-Joe
Reply With Quote
  #10   Spotlight this post!  
Unread 30-03-2013, 14:57
timoho98 timoho98 is offline
Registered User
FRC #2813
 
Join Date: Mar 2013
Location: Saratoga
Posts: 4
timoho98 is an unknown quantity at this point
Re: AXDL345_I2C java problems

Thanks setting Compatitbilitymode(true) solved our problems and we are now getting back values. We had to go into the wpilibj source and change the ADXL_345 class file and recompile it
Reply With Quote
  #11   Spotlight this post!  
Unread 31-03-2013, 10:03
Mike Bortfeldt Mike Bortfeldt is offline
Registered User
FRC #1126 (& 1511)
Team Role: Mentor
 
Join Date: Oct 2004
Rookie Year: 2004
Location: Rochester, NY
Posts: 119
Mike Bortfeldt has much to be proud ofMike Bortfeldt has much to be proud ofMike Bortfeldt has much to be proud ofMike Bortfeldt has much to be proud ofMike Bortfeldt has much to be proud ofMike Bortfeldt has much to be proud ofMike Bortfeldt has much to be proud ofMike Bortfeldt has much to be proud of
Re: AXDL345_I2C java problems

Quote:
Originally Posted by jhersh View Post
My recommendation is that you call SetCompatibilityMode(true); on the I2C object.

-Joe
Joe,

Could you explain exactly what SetCompatabilityMode does? That corrected a sporatic communication issue I had with an Arduino as well and I would like to understand why. The documentation is, shall we say, sketchy.

Thanks,
Mike
Reply With Quote
  #12   Spotlight this post!  
Unread 31-03-2013, 14:09
jhersh jhersh is offline
National Instruments
AKA: Joe Hershberger
FRC #2468 (Appreciate)
Team Role: Mentor
 
Join Date: May 2008
Rookie Year: 1997
Location: Austin, TX
Posts: 1,006
jhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond repute
Re: AXDL345_I2C java problems

Quote:
Originally Posted by Mike Bortfeldt View Post
Joe,

Could you explain exactly what SetCompatabilityMode does? That corrected a sporatic communication issue I had with an Arduino as well and I would like to understand why. The documentation is, shall we say, sketchy.

Thanks,
Mike
Hi Mike,

The Digital I/O from the 9403 module is registered... meaning it takes several clock cycles in the FPGA for a digital write to be read back in. When using I2C over an interface like this, that means that the checking for clock skewing is expensive time-wise. As a result, the I2C implementation in the FPGA attempts to optimize this by only checking for clock skewing in "typical" parts of the waveform. Of course in the I2C spec, devices are allowed to skew the clock almost anywhere. The compatibility mode checks for clock skewing everywhere required by the spec and is thus "compatible" with that spec. The result is that your I2C transfer speed is slower (if I recall transactions take approx 60% longer), but you can talk to any I2C device, not just "typical sensors".

I hope this clears up any gaps in the documentation (are you talking about WPILibJ doxygen?).

Cheers,
-Joe

Last edited by jhersh : 31-03-2013 at 14:12.
Reply With Quote
  #13   Spotlight this post!  
Unread 01-04-2013, 11:07
Mike Bortfeldt Mike Bortfeldt is offline
Registered User
FRC #1126 (& 1511)
Team Role: Mentor
 
Join Date: Oct 2004
Rookie Year: 2004
Location: Rochester, NY
Posts: 119
Mike Bortfeldt has much to be proud ofMike Bortfeldt has much to be proud ofMike Bortfeldt has much to be proud ofMike Bortfeldt has much to be proud ofMike Bortfeldt has much to be proud ofMike Bortfeldt has much to be proud ofMike Bortfeldt has much to be proud ofMike Bortfeldt has much to be proud of
Re: AXDL345_I2C java problems

Thanks Joe! That description really helps a lot, both in understanding why SetCompatabilityMode works and why it was set up the way it was. As for the documentation, I'm assuming it was the WPILibJ, but as I don't have the team laptop, I'm not positive. I just remember it saying something like the funtion "enables compatibility mode".

Thanks,
Mike
Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 03:25.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi