Go to Post There are certain questions that one never, ever should ask. - dlavery [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Closed Thread
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 30-10-2014, 07:15
2B || !2B's Avatar
2B || !2B 2B || !2B is offline
/* No Comment */
FRC #1559 (DevilTech)
Team Role: Programmer
 
Join Date: Apr 2013
Rookie Year: 2013
Location: New York
Posts: 19
2B || !2B is a jewel in the rough2B || !2B is a jewel in the rough2B || !2B is a jewel in the rough2B || !2B is a jewel in the rough
I2C advice

Hi everyone! I have been tasked with creating a master class (Java) for all things I2C because the last time we used it, the robot had some major lag issues, and once the sensor crashed the robot so hard it stopped moving during competition. The device I will be communicating with is the GY85 accelerometer/compass/gyro sensor. Is there anything I should know? Any fun stories? (Any and all information is appreciated!)
__________________
There are no brakes on the software train
  #2   Spotlight this post!  
Unread 31-10-2014, 10:45
Chadfrom308's Avatar
Chadfrom308 Chadfrom308 is offline
Slave to the bot
AKA: Chad Krause
FRC #0308 (The Monsters)
Team Role: Driver
 
Join Date: Jan 2013
Rookie Year: 2011
Location: Novi
Posts: 272
Chadfrom308 is a splendid one to beholdChadfrom308 is a splendid one to beholdChadfrom308 is a splendid one to beholdChadfrom308 is a splendid one to beholdChadfrom308 is a splendid one to beholdChadfrom308 is a splendid one to beholdChadfrom308 is a splendid one to behold
Re: I2C advice

I've only heard of a couple teams that have gotten I2C to work well (besides the accelerometer). What I would personally do is get an arduino and a CAN shield and read the sensors using I2C on arduino and then send the data over CAN. I am on a Formula SAE team and we are doing something similar to this and it works really well.

Also, Teensy 3.1 has CAN built in (minus a microchip for the i/o for CAN) and that has something like 22 analog ins, so if you are reading lots of sensors (like the Formula team I am on) you could use that to read sensors too.

Also, I love your name
  #3   Spotlight this post!  
Unread 31-10-2014, 11:45
dash121 dash121 is offline
Registered User
FRC #4085
 
Join Date: Oct 2014
Location: Reynoldsburg Ohio
Posts: 23
dash121 is an unknown quantity at this point
Cool Re: I2C advice

ProTip: Learn binary and put the numbers on the System.out in netbeans so then its less calculation for the computer.

We got a MaxBotix I2C sonar sensor because our first sensor got shocked because we didn't keep it in the proper equipment. It worked well with little problems!
  #4   Spotlight this post!  
Unread 01-11-2014, 08:30
2B || !2B's Avatar
2B || !2B 2B || !2B is offline
/* No Comment */
FRC #1559 (DevilTech)
Team Role: Programmer
 
Join Date: Apr 2013
Rookie Year: 2013
Location: New York
Posts: 19
2B || !2B is a jewel in the rough2B || !2B is a jewel in the rough2B || !2B is a jewel in the rough2B || !2B is a jewel in the rough
Re: I2C advice

I didn't think about using an Arduino, but that's a good idea!

I couldn't tell you how many times the sensor's been hot-plugged accidentally by the death spirals that were supposed to be a closed loop drive system! I can't believe it still works...
__________________
There are no brakes on the software train
  #5   Spotlight this post!  
Unread 01-11-2014, 09:05
RufflesRidge RufflesRidge is offline
Registered User
no team
 
Join Date: Jan 2012
Location: USA
Posts: 989
RufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant future
Re: I2C advice

Quote:
Originally Posted by Chadfrom308 View Post
I've only heard of a couple teams that have gotten I2C to work well (besides the accelerometer). What I would personally do is get an arduino and a CAN shield and read the sensors using I2C on arduino and then send the data over CAN. I am on a Formula SAE team and we are doing something similar to this and it works really well.

Also, Teensy 3.1 has CAN built in (minus a microchip for the i/o for CAN) and that has something like 22 analog ins, so if you are reading lots of sensors (like the Formula team I am on) you could use that to read sensors too.
Have you tried writing to non-Jaguar CAN devices on the cRIO? Or to arbitrary CAN devices on the roboRIO? WPILib does not currently have any user APIs for arbitrary CAN devices/traffic. This seems substantially harder than just getting I2C to work on the roboRIO itself.
  #6   Spotlight this post!  
Unread 02-11-2014, 07:28
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: I2C advice

Quote:
Originally Posted by 2B || !2B View Post
!lI have been tasked with creating a master class (Java) for all things I2C because the last time we used it, the robot had some major lag issues, and once the sensor crashed the robot so hard it stopped moving during competition.
I don't think you want the try to make some generic "master class" where you attempt to handle more than just the device in question. The class provided is already the master class!

Quote:
Originally Posted by Chadfrom308 View Post
I've only heard of a couple teams that have gotten I2C to work well (besides the accelerometer). What I would personally do is get an arduino and a CAN shield and read the sensors using I2C on arduino and then send the data over CAN. I am on a Formula SAE team and we are doing something similar to this and it works really well.

Also, Teensy 3.1 has CAN built in (minus a microchip for the i/o for CAN) and that has something like 22 analog ins, so if you are reading lots of sensors (like the Formula team I am on) you could use that to read sensors too.
That sounds like a pretty complex solution to a simple problem. There would have to be some extenuating circumstances to warrant such a design.

Quote:
Originally Posted by 2B || !2B View Post
I couldn't tell you how many times the sensor's been hot-plugged accidentally by the death spirals that were supposed to be a closed loop drive system! I can't believe it still works...
Most simple sensors like I2C sensors don't care if you hot-plug them. They just see it as powering up.

Quote:
Originally Posted by RufflesRidge View Post
Have you tried writing to non-Jaguar CAN devices on the cRIO? Or to arbitrary CAN devices on the roboRIO? WPILib does not currently have any user APIs for arbitrary CAN devices/traffic. This seems substantially harder than just getting I2C to work on the roboRIO itself.
LabVIEW has a generic API for accessing CAN. If Java doesn't, that may be a bug.
  #7   Spotlight this post!  
Unread 03-11-2014, 14:31
2B || !2B's Avatar
2B || !2B 2B || !2B is offline
/* No Comment */
FRC #1559 (DevilTech)
Team Role: Programmer
 
Join Date: Apr 2013
Rookie Year: 2013
Location: New York
Posts: 19
2B || !2B is a jewel in the rough2B || !2B is a jewel in the rough2B || !2B is a jewel in the rough2B || !2B is a jewel in the rough
Re: I2C advice

Are you referring to a master I2C class, or a master GY-85 class? The FIRST I2C class kept hanging up the robot because it would start another transaction when another was already active. I'm just making this class to make sure that doesn't happen, and to make the code look cleaner and nicer to read in general.
__________________
There are no brakes on the software train
  #8   Spotlight this post!  
Unread 03-11-2014, 14:46
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: I2C advice

Quote:
Originally Posted by 2B || !2B View Post
Are you referring to a master I2C class, or a master GY-85 class? The FIRST I2C class kept hanging up the robot because it would start another transaction when another was already active. I'm just making this class to make sure that doesn't happen, and to make the code look cleaner and nicer to read in general.
Perhaps I'm reading too much into your choice of name. I think you should attempt to write a class that is capable of interacting with the sensor you care about and nothing more. Speculative generality is your enemy. It will add complexity and give you nothing positive in return. You can always refactor in the future when you have new requirements.

I'm surprised that the Java class allowed more than one write at a time to the I2C bus. I haven't looked to see if that is a bug or a misunderstanding. Certainly on the new roboRIO that should not be possible due to the Linux device driver that must be talked to on the new system. Your class should not need to deal with this level of synchronization.
  #9   Spotlight this post!  
Unread 03-11-2014, 15:02
2B || !2B's Avatar
2B || !2B 2B || !2B is offline
/* No Comment */
FRC #1559 (DevilTech)
Team Role: Programmer
 
Join Date: Apr 2013
Rookie Year: 2013
Location: New York
Posts: 19
2B || !2B is a jewel in the rough2B || !2B is a jewel in the rough2B || !2B is a jewel in the rough2B || !2B is a jewel in the rough
Re: I2C advice

Sorry for my vague-ness. Words are hard !
__________________
There are no brakes on the software train
  #10   Spotlight this post!  
Unread 03-11-2014, 16:57
Chadfrom308's Avatar
Chadfrom308 Chadfrom308 is offline
Slave to the bot
AKA: Chad Krause
FRC #0308 (The Monsters)
Team Role: Driver
 
Join Date: Jan 2013
Rookie Year: 2011
Location: Novi
Posts: 272
Chadfrom308 is a splendid one to beholdChadfrom308 is a splendid one to beholdChadfrom308 is a splendid one to beholdChadfrom308 is a splendid one to beholdChadfrom308 is a splendid one to beholdChadfrom308 is a splendid one to beholdChadfrom308 is a splendid one to behold
Re: I2C advice

Quote:
Originally Posted by jhersh View Post
That sounds like a pretty complex solution to a simple problem. There would have to be some extenuating circumstances to warrant such a design.
Well I've always heard of hangs and program crashes because of bad i2c code., never CAN. And it is easier to get all of your sensor data from 1 source (CAN) and you can pre process the data. That's the way I would do it. It also allows you to develop code faster (you only have to compile arduino code, not the whole robot code).

It seems like i2c isn't really fully developed on the cRIO or the roboRIO. Bit that's just what I have heard
  #11   Spotlight this post!  
Unread 03-11-2014, 21:17
RufflesRidge RufflesRidge is offline
Registered User
no team
 
Join Date: Jan 2012
Location: USA
Posts: 989
RufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant future
Re: I2C advice

Quote:
Originally Posted by 2B || !2B View Post
The FIRST I2C class kept hanging up the robot because it would start another transaction when another was already active.
Quote:
Originally Posted by jhersh View Post
I'm surprised that the Java class allowed more than one write at a time to the I2C bus. I haven't looked to see if that is a bug or a misunderstanding.
The transaction method in the cRIO Java code is synchronized, you cannot execute two transactions at once.

Quote:
Originally Posted by Chadfrom308 View Post
It seems like i2c isn't really fully developed on the cRIO or the roboRIO. Bit that's just what I have heard
Speculation and FUD seems unhelpful. Perhaps we should stick to actual data and not hearsay? Especially when it comes to a system that's still in Beta, in the hands of 90 teams, and which has no current bugs filed against the I2C software from a quick glance at the Beta tracker.
  #12   Spotlight this post!  
Unread 03-11-2014, 22:10
Chadfrom308's Avatar
Chadfrom308 Chadfrom308 is offline
Slave to the bot
AKA: Chad Krause
FRC #0308 (The Monsters)
Team Role: Driver
 
Join Date: Jan 2013
Rookie Year: 2011
Location: Novi
Posts: 272
Chadfrom308 is a splendid one to beholdChadfrom308 is a splendid one to beholdChadfrom308 is a splendid one to beholdChadfrom308 is a splendid one to beholdChadfrom308 is a splendid one to beholdChadfrom308 is a splendid one to beholdChadfrom308 is a splendid one to behold
Re: I2C advice

Quote:
Originally Posted by RufflesRidge View Post
Speculation and FUD seems unhelpful. Perhaps we should stick to actual data and not hearsay? Especially when it comes to a system that's still in Beta, in the hands of 90 teams, and which has no current bugs filed against the I2C software from a quick glance at the Beta tracker.
I understand that, but if I2C freezes the whole robot, then that is a big problem. CAN won't freeze your whole robot, and a lot of things already run off CAN. If the arduino freezes, it probably won't freeze your robot. I am just trying to stay on the safe side, and that is what we will be doing next year if we use I2C for something.
  #13   Spotlight this post!  
Unread 03-11-2014, 23:08
Joe Ross's Avatar Unsung FIRST Hero
Joe Ross Joe Ross is offline
Registered User
FRC #0330 (Beachbots)
Team Role: Engineer
 
Join Date: Jun 2001
Rookie Year: 1997
Location: Los Angeles, CA
Posts: 8,567
Joe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond repute
Re: I2C advice

There were a few problems with I2C on the cRIO that caused people problems.
  • The cRIO software expected an 8 bit address, whereas most people were used to a 7 bit address. The roboRIO now uses a 7 bit address.
  • The cRIO's clock skewing behavior caused problems for some devices. It always supported a "compatibility" mode to solve those issues, and was enabled by default in 2014. This is no longer necessary on the roboRIO.
  • If the device stopped communicating in the middle of a transaction, the cRIO software would be stuck in an infinite loop waiting for data. http://firstforge.wpi.edu/sf/go/artf1726 This is not present on the roboRIO.

Quote:
Originally Posted by Chadfrom308 View Post
Well I've always heard of hangs and program crashes because of bad i2c code., never CAN.
I think many people have complained about the CAN implementation on the cRIO.

Quote:
Originally Posted by RufflesRidge View Post
Speculation and FUD seems unhelpful. Perhaps we should stick to actual data and not hearsay? Especially when it comes to a system that's still in Beta, in the hands of 90 teams, and which has no current bugs filed against the I2C software from a quick glance at the Beta tracker.
To be fair, only 3 of the 90 teams have reported testing I2C.
  #14   Spotlight this post!  
Unread 04-11-2014, 15:40
Chadfrom308's Avatar
Chadfrom308 Chadfrom308 is offline
Slave to the bot
AKA: Chad Krause
FRC #0308 (The Monsters)
Team Role: Driver
 
Join Date: Jan 2013
Rookie Year: 2011
Location: Novi
Posts: 272
Chadfrom308 is a splendid one to beholdChadfrom308 is a splendid one to beholdChadfrom308 is a splendid one to beholdChadfrom308 is a splendid one to beholdChadfrom308 is a splendid one to beholdChadfrom308 is a splendid one to beholdChadfrom308 is a splendid one to behold
Re: I2C advice

Quote:
Originally Posted by Joe Ross View Post
There were a few problems with I2C on the cRIO that caused people problems.
  • The cRIO software expected an 8 bit address, whereas most people were used to a 7 bit address. The roboRIO now uses a 7 bit address.
  • The cRIO's clock skewing behavior caused problems for some devices. It always supported a "compatibility" mode to solve those issues, and was enabled by default in 2014. This is no longer necessary on the roboRIO.
  • If the device stopped communicating in the middle of a transaction, the cRIO software would be stuck in an infinite loop waiting for data. http://firstforge.wpi.edu/sf/go/artf1726 This is not present on the roboRIO.



I think many people have complained about the CAN implementation on the cRIO.
Ooh sounds like I2C is going to be a good way of communicating this year! I am excited! I love how easy I2C is to set up on an arduino, but I have never gotten it to work on a cRIO. Hopefully that will be a lot easier this year!

And I meant that I haven't heard of CAN crashing the whole robot.
Closed Thread


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 02:44.

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