Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   C/C++ (http://www.chiefdelphi.com/forums/forumdisplay.php?f=183)
-   -   Gyro + accelometer C++ Programing (http://www.chiefdelphi.com/forums/showthread.php?t=90547)

tomy 30-01-2011 18:10

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

Re: Gyro + accelometer C++ Programing
 
Could you please post the source code you are trying?

tomy 30-01-2011 19:39

Re: Gyro + accelometer C++ Programing
 
I don't have the computer now but for the gyro we did


Code:

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

Re: Gyro + accelometer C++ Programing
 
Quote:

Originally Posted by tomy (Post 1011970)
I don't have the computer now but for the gyro we did


Code:

gyro.reset
        gyro.get angle()

Is there anything special you have to do to see it the driver station?

That code is incorrect,
Code:

gyro.Reset();
gyro.GetAngle();


tomy 30-01-2011 19:56

Re: Gyro + accelometer C++ Programing
 
Like I said I dont have the computer...

basicxman 30-01-2011 20:00

Re: Gyro + accelometer C++ Programing
 
Quote:

Originally Posted by tomy (Post 1011970)
Is there anything special you have to do to see it the driver station?

Code:

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

Re: Gyro + accelometer C++ Programing
 
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.

tomy 30-01-2011 20:14

Re: Gyro + accelometer C++ Programing
 
Thanks ala
Will it automatically show up on the driver station (the compus thingie)

basicxman 30-01-2011 20:21

Re: Gyro + accelometer C++ Programing
 
Quote:

Originally Posted by tomy (Post 1012002)
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.

tomy 30-01-2011 20:27

Re: Gyro + accelometer C++ Programing
 
what about the accelometer we have it pluged into the I2C Port in our programing i think we did something like this

Code:

acc.(I2C);
and it did not work

basicxman 30-01-2011 20:29

Re: Gyro + accelometer C++ Programing
 
Quote:

Originally Posted by tomy (Post 1012018)
what about the accelometer we have it pluged into the I2C Port in our programing i think we did something like this

Code:

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...45___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.

tomy 30-01-2011 20:35

Re: Gyro + accelometer C++ Programing
 
tommarow around 4 central time i will post my code here


All times are GMT -5. The time now is 12:36.

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