View Full Version : Gyro + accelometer C++ Programing
this year we are finally going to use the gyro and accelometer, both of them are hocked up right but neither of them are working.
the gyro is hooked up to crio module 1 slot 1
and the accelometer is hooked up to the I2C port.
we tried to program them but neither are working
anyone got some example code
p.s. sorry if there is another post about this i running late for a meeting and needed to post it quickly before i forgot
basicxman
30-01-2011, 19:24
Could you please post the source code you are trying?
I don't have the computer now but for the gyro we did
gyro.reset
gyro.get angle()
Is there anything special you have to do to see it the driver station?
basicxman
30-01-2011, 19:41
I don't have the computer now but for the gyro we did
gyro.reset
gyro.get angle()
Is there anything special you have to do to see it the driver station?
That code is incorrect,
gyro.Reset();
gyro.GetAngle();
Like I said I dont have the computer...
basicxman
30-01-2011, 20:00
Is there anything special you have to do to see it the driver station?
DriverStationLCD *display = DriverStationLCD::GetInstance();
char text[255];
sprintf(text, "Gyro Value: %f", gyro.GetAngle());
display->Clear();
display->PrintfLine(DriverStationLCD::kUser_Line1, text);
display->UpdateLCD();
Or if you mean the display on the Dashboard, take a look at the DashboardData sender in some of the example projects (such as Vision tracking).
Alan Anderson
30-01-2011, 20:02
Only call Reset() when you want to reset the gyro to its initial state. If you do it every time you try to read GetAngle(), you will always read zero.
Thanks ala
Will it automatically show up on the driver station (the compus thingie)
basicxman
30-01-2011, 20:21
Thanks ala
Will it automatically show up on the driver station (the compus thingie)
That's the dashboard, and no it won't. Take a look at the example project DashboardDataExample.
what about the accelometer we have it pluged into the I2C Port in our programing i think we did something like this
acc.(I2C);
and it did not work
basicxman
30-01-2011, 20:29
what about the accelometer we have it pluged into the I2C Port in our programing i think we did something like this
acc.(I2C);
and it did not work
That shouldn't have compiled, here are the available functions for the ADXL345 accelerometer: http://mmrambotics.ca/wpilib/class_a_d_x_l345___i2_c.html
You are initializing these objects too correct? Please post full source code when you can, it will be much easier for us to help you.
tommarow around 4 central time i will post my code here
vBulletin® v3.6.4, Copyright ©2000-2017, Jelsoft Enterprises Ltd.