From Saturday, Nov 23rd 7:00 PM CST - Sunday, Nov 24th 7:45 AM CST, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
From Saturday, Nov 23rd 7:00 PM CST - Sunday, Nov 24th 7:45 AM CST, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
01-18-2010 12:10 PM
I see from various discussions on Cheif Delphi and my personal experience that teams are having a hard time talking to the I2C accelerometer that was included in the 2010 KOP. There was also no supporting documentation for it in the material I downloaded. Using the data sheet from Analog Devices and some mods to the code from the compass class in the WPI library I thought we had a solution but no luck. Is there anything we should know about as far as the NI implementation of a I2C driver or the WPI I2C Class that isn't obvious?
Has anyone got it working? Did the compass code from last year ever work? There are so many layers of abstraction in the WPI library that is a real head ache to try to track down anything.
At this point I am only interested in C or C++ solutions and not a running commentary on the pros and cons of using LabVIew vs C/C++.
Thanks in advance and Good luck programmers and mentors.
Brian
01-19-2010 03:25 PM
There isn't anything especially tricky about the C++ implementation of the I2C class in WPILib. The only thing a little bit tedious about the sensor is that it starts up with measurements disabled... so you have to turn it on.
I've written up a quick example of what it should look like, but don't have hardware here to test it. This should at least get you started. A tested version of this will be added to WPILib in the next update.
Cheers!
-Joe
01-20-2010 01:22 AM
I've tested the implementation and fixed a bug in what I initally posted. I've attached the fixed files.
Also in testing, I discovered a bug in the current I2C class for C++. Please see the information here for how to fix it in the mean time (until the next update). This is required to make the ADXL345 work as well.
Cheers!
-Joe
01-20-2010 08:31 AM
Thanks for taking the lead on this Joe....We'll test it out tonite and give you an update...
Brian
Programming Mentor Team 1714
Sr Firmware Engineer
Rockwell Automation
01-20-2010 12:47 PM
One more question....How do I change I2C.cpp....Thinking I would create an alternate I2C.cpp file and make the fix, I looked at the WPI1764.zip file and examined the I2C.cpp file and did not find the bit wise or vs logical or bug you mentioned at at firstforge..Do we have access to the WPI files(I see include files but not code files) or code via the windriver ide? Or do we have to wait for the update.
This is what I2C::Write() looks like in the library I have...Is it the wrong stuff?
void I2C::Write(UINT8 registerAddress, UINT8 data)
{
Synchronized sync(m_semaphore);
m_module->m_fpgaDIO->writeI2CConfig_Address(m_deviceAddress, &status);
m_module->m_fpgaDIO->writeI2CConfig_Register(registerAddress, &status);
m_module->m_fpgaDIO->writeI2CConfig_DataToSend(data, &status);
m_module->m_fpgaDIO->writeI2CConfig_Read(false, &status);
UINT8 transaction = m_module->m_fpgaDIO->readI2CStatus_Transaction(&status);
m_module->m_fpgaDIO->strobeI2CStart(&status);
while(transaction == m_module->m_fpgaDIO->readI2CStatus_Transaction(&status)) taskDelay(1);
while(!m_module->m_fpgaDIO->readI2CStatus_Done(&status)) taskDelay(1);
}
Thanks,
Brian
01-20-2010 01:08 PM
The code that you posted is from last year and does not work with the current FPGA (rev 1.3.0).
Here is a link to the current source code snapshot: http://firstforge.wpi.edu/sf/frs/do/viewRelease/projects.wpilib/frs.wpilib_c_source_snapshot.wpilib_...
You can also access the source code in the svn server here: http://firstforge.wpi.edu/sf/scm/do/listRepositories/projects.wpilib/scm You will need to be logged in to first forge to access the svn server.
Cheers!
-Joe
01-20-2010 07:54 PM
well....we can download the code but we keep
getting a no robot code message on the driver console.we also cannot see any debug data on the laptop.
This is true even with un modified default code.
an old laptop with old libraries lets up down load and everything is ok....
we are using v19 of the crio image...we did the latest workbench update (I think it was the latest it is the one on the web site list of mandatory updates.
any clues??
Brian
01-21-2010 01:58 AM
Run what code? The code I posted here is library routines. It is not an example program. It doesn't run stand-alone.
You need to create one of these objects in your code and call the get method on it.
-Joe
01-22-2010 08:12 AM
Hi Joe,
All is working now... ...we re-imaged the cRIO and made sure ALL the updates were installed...
Thanks for all the help and especially thanks for your patience....Hopefully your posts will be time stamped on the PM side of midnite soon...
If not let me know where to send the Starbucks gift card.
Brian
01-23-2010 02:12 PM
Hi, I am fairly new to programming, and I have been having a similar problem with the accelerometer. I downloaded the sample code but I cannot figure out what to do after that. Can someone please give me a list of instructions.