|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
| Thread Tools | Rate Thread | Display Modes |
|
#16
|
|||
|
|||
|
Re: Accelerometer Showing All Zeros
no just one, we tried both sets of 4 pins and both showed 0.
|
|
#17
|
|||
|
|||
|
Which physical slot of the cRio is the DIO module in.
By looking at your code it is in either slot 6 of 8 slot cRIO, or slot 4 of 4 slot cRIO. |
|
#18
|
|||
|
|||
|
Re: Accelerometer Showing All Zeros
Our team is having the same problem. We have the Accelerometer wired up correctly to the I2C slot, and the Digital Module is in cRIO slot 2. The ode should be working but we still get all 0's. I'll post our code below, maybe that may be the issue.
Code:
/*----------------------------------------------------------------------------*/
/* Copyright (c) FIRST 2008. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
/*----------------------------------------------------------------------------*/
package edu.wpi.first.wpilibj.templates;
import edu.wpi.first.wpilibj.ADXL345_I2C;
import edu.wpi.first.wpilibj.IterativeRobot;
import edu.wpi.first.wpilibj.Joystick;
import edu.wpi.first.wpilibj.Victor;
/**
* The VM is configured to automatically run this class, and to call the
* functions corresponding to each mode, as described in the IterativeRobot
* documentation. If you change the name of this class or the package after
* creating this project, you must also update the manifest file in the resource
* directory.
*/
public class RobotTemplate extends IterativeRobot {
Victor leftVict, rightVict;
Joystick leftJoy, rightJoy;
Driver robot;
ADXL345_I2C Accelerometer;
/**
* This function is run when the robot is first started up and should be
* used for any initialization code.
*/
public void robotInit() {
System.out.println("Call init method");
Accelerometer = new ADXL345_I2C(1,ADXL345_I2C.DataFormat_Range.k2G);
// leftVict = new Victor(1);
// rightVict = new Victor(2);
//
// leftJoy = new Joystick(1);
// rightJoy = new Joystick(2);
//
// robot = new Driver(leftJoy, rightJoy, leftVict, rightVict);
}
/**
* This function is called periodically during autonomous
*/
public void autonomousPeriodic() {
}
/**
* This function is called periodically during operator control
*/
public void teleopPeriodic() {
// robot.drive();
//vict.set(leftJoy.getAxis(Joystick.AxisType.kY));
//jag.set(leftJoy.getAxis(Joystick.AxisType.kY));
System.out.println("Acceleration = " + Accelerometer.getAcceleration(ADXL345_I2C.Axes.kX));
}
}
}
|
|
#19
|
|||
|
|||
|
Re: Accelerometer Showing All Zeros
Sorry I didn't respond before, I forgot to check this thread. We're still having problems. The cable we got in the kit was broken, and we tried to fix it but ended up breaking it more. We have a different ribbon cable that was bought last year, but that doesn't seem to fix the issue.
|
|
#20
|
|||
|
|||
|
Re: Accelerometer Showing All Zeros
Actually, sorry, we got it to work. I replaced the round cable with a ribbon cable and moved the pwm's to the outside set of I2C ports. I think moving it to the outside is what actually fixed it, but I did both. Thanks everyone for your help!
|
|
#21
|
|||
|
|||
|
Re: Accelerometer Showing All Zeros
Actually, it definitely is the ribbon cable. Team 3504 switched out the cable but kept everything the same and it worked. So make sure you use the ribbon cable!
|
|
#22
|
||||
|
||||
|
Re: Accelerometer Showing All Zeros
This seems to be a common symptom, and there are probably many different underlying problems. In the case of 3504, the round cable (from prior years' KoP) was the issue. It seems to have signal integrity problems for any digital signals that change very quickly or that may not work properly in the face of noise.
It probably isn't a bad idea to keep the distance this cable has to span reasonably short and follow the suggestion in the instructions on how to rework the ribbon cable and shorten it if you're doing the rework anyway. |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|